11name : Build and Release
22
3+ permissions :
4+ contents : write
5+
36on :
47 push :
58 branches : [ main ]
912
1013jobs :
1114 build :
12- name : Build for ${{ matrix.os }} (${{ matrix.arch }})
15+ name : Build for ${{ matrix.os }}
1316 runs-on : ${{ matrix.os }}
1417 strategy :
1518 matrix :
1619 include :
1720 # Windows
1821 - os : windows-latest
19- arch : amd64
2022 goos : windows
2123 goarch : amd64
2224 suffix : .exe
23- - os : windows-latest
24- arch : 386
25- goos : windows
26- goarch : 386
27- suffix : .exe
2825
2926 # Linux
3027 - os : ubuntu-latest
31- arch : amd64
3228 goos : linux
3329 goarch : amd64
3430 suffix : ' '
35- - os : ubuntu-latest
36- arch : 386
37- goos : linux
38- goarch : 386
39- suffix : ' '
40- - os : ubuntu-latest
41- arch : arm64
42- goos : linux
43- goarch : arm64
44- suffix : ' '
4531
4632 # macOS
4733 - os : macos-latest
48- arch : amd64
4934 goos : darwin
5035 goarch : amd64
5136 suffix : ' '
52- - os : macos-latest
53- arch : arm64
54- goos : darwin
55- goarch : arm64
56- suffix : ' '
57-
58- # FreeBSD
59- - os : ubuntu-latest
60- arch : amd64
61- goos : freebsd
62- goarch : amd64
63- suffix : ' '
64- - os : ubuntu-latest
65- arch : 386
66- goos : freebsd
67- goarch : 386
68- suffix : ' '
6937
7038 steps :
7139 - name : Checkout code
7240 uses : actions/checkout@v4
73- with :
74- fetch-depth : 0
7541
7642 - name : Set up Go
7743 uses : actions/setup-go@v5
7844 with :
7945 go-version : ' 1.25'
80- cache : true
81-
82- - name : Get version from tag
83- id : get_version
84- run : |
85- if [[ "${{ github.ref }}" == refs/tags/* ]]; then
86- VERSION="${GITHUB_REF#refs/tags/}"
87- else
88- VERSION="dev-$(git rev-parse --short HEAD)"
89- fi
90- echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
91- echo "version=$VERSION" >> $GITHUB_ENV
9246
9347 - name : Build
9448 run : |
95- # 设置构建参数
49+ # 设置输出文件名
9650 OUTPUT_NAME="qdbexploit${{ matrix.suffix }}"
97- BUILD_FLAGS="-ldflags='-X main.version=${{ env.version }} -s -w'"
98-
99- # 创建输出目录
100- mkdir -p dist
10151
10252 # 执行构建
103- GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} go build $BUILD_FLAGS -o "dist/${ OUTPUT_NAME} " .
53+ GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} go build -o "$ OUTPUT_NAME" .
10454
10555 # 为 Unix 系统添加可执行权限
10656 if [[ "${{ matrix.goos }}" != "windows" ]]; then
107- chmod +x "dist/${ OUTPUT_NAME} "
57+ chmod +x "$ OUTPUT_NAME"
10858 fi
10959
11060 # 显示构建信息
111- echo "Built: dist/${ OUTPUT_NAME} "
61+ echo "Built: $ OUTPUT_NAME"
11262 echo "Platform: ${{ matrix.goos }}/${{ matrix.goarch }}"
113- file "dist/${OUTPUT_NAME}" || true
11463
11564 - name : Upload artifact
11665 uses : actions/upload-artifact@v4
11766 with :
118- name : qdbexploit-${{ matrix.goos }}-${{ matrix.goarch }}
119- path : dist/
67+ name : qdbexploit-${{ matrix.goos }}
68+ path : qdbexploit${{ matrix.suffix }}
12069 retention-days : 7
12170
12271 release :
@@ -133,67 +82,6 @@ jobs:
13382 with :
13483 path : artifacts
13584
136- - name : List downloaded artifacts
137- run : |
138- find artifacts -type f -name "qdbexploit*" | sort
139-
140- - name : Create release archive
141- run : |
142- # 创建临时目录
143- mkdir -p release
144-
145- # 复制所有构建产物
146- find artifacts -type f -name "qdbexploit*" -exec cp {} release/ \;
147-
148- # 创建 README 文件
149- cat > release/README.md << 'EOF'
150- # QuestDB Exploit 发布文件
151-
152- 此目录包含 QuestDB Exploit 工具的多平台可执行文件。
153-
154- ## 文件说明
155-
156- - `qdbexploit` - Linux/macOS/FreeBSD 可执行文件
157- - `qdbexploit.exe` - Windows 可执行文件
158-
159- ## 平台支持
160-
161- | 文件名 | 操作系统 | 架构 |
162- |--------|----------|------|
163- | qdbexploit | Linux | amd64, 386, arm64 |
164- | qdbexploit | macOS | amd64, arm64 |
165- | qdbexploit | FreeBSD | amd64, 386 |
166- | qdbexploit.exe | Windows | amd64, 386 |
167-
168- ## 使用说明
169-
170- 1. 下载对应平台的文件
171- 2. 添加可执行权限(Unix 系统):
172- ```bash
173- chmod +x qdbexploit
174- ```
175- 3. 运行工具:
176- ```bash
177- ./qdbexploit -h
178- ```
179-
180- ## 版本信息
181-
182- 构建时间: $(date)
183- 提交哈希: ${{ github.sha }}
184- EOF
185-
186- # 创建压缩包
187- tar -czf qdbexploit-binaries.tar.gz -C release .
188- zip -r qdbexploit-binaries.zip release/
189-
190- # 显示文件列表
191- echo "=== 发布文件列表 ==="
192- ls -la *.tar.gz *.zip
193- echo ""
194- echo "=== 压缩包内容 ==="
195- tar -tzf qdbexploit-binaries.tar.gz | head -20
196-
19785 - name : Create GitHub Release
19886 uses : softprops/action-gh-release@v1
19987 with :
@@ -207,17 +95,15 @@ jobs:
20795 - **构建时间**: $(date -u +"%Y-%m-%dT%H:%M:%SZ")
20896
20997 ## 包含的平台
210- - **Windows**: amd64, 386
211- - **Linux**: amd64, 386, arm64
212- - **macOS**: amd64, arm64
213- - **FreeBSD**: amd64, 386
98+ - **Windows**: amd64
99+ - **Linux**: amd64
100+ - **macOS**: amd64
214101
215102 ## 使用说明
216- 1. 下载对应的压缩包
217- 2. 解压文件
218- 3. 运行对应的可执行文件
103+ 1. 下载对应平台的文件
104+ 2. 运行工具
219105
220- ### Unix 系统(Linux/macOS/FreeBSD )
106+ ### Unix 系统(Linux/macOS)
221107 ```bash
222108 chmod +x qdbexploit
223109 ./qdbexploit -h
@@ -227,11 +113,7 @@ jobs:
227113 ```cmd
228114 qdbexploit.exe -h
229115 ```
230-
231- ## 文件说明
232- 压缩包中包含所有平台的二进制文件,请根据您的操作系统选择对应的文件。
233116 files : |
234- qdbexploit-binaries.tar.gz
235- qdbexploit-binaries.zip
117+ artifacts/**/qdbexploit*
236118 draft : false
237119 prerelease : false
0 commit comments