-
Notifications
You must be signed in to change notification settings - Fork 0
289 lines (242 loc) · 7.08 KB
/
release.yml
File metadata and controls
289 lines (242 loc) · 7.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
name: "Release"
permissions:
contents: write
concurrency:
group: release-${{ github.ref_name }}
cancel-in-progress: true
on:
workflow_dispatch:
env:
GO_VERSION: "1.25"
jobs:
prepare:
name: "🔧 Prepare"
runs-on: ubuntu-latest
steps:
- name: 🛎️ Checkout
uses: actions/checkout@v6
with:
ref: main
fetch-depth: 1
- uses: ./.github/actions/init-go
with:
go-version: ${{ env.GO_VERSION }}
- uses: ./.github/actions/tidy-all-and-generate
- name: 📦 Upload source
uses: actions/upload-artifact@v4
with:
name: src-gen
path: .
test-garble:
name: "🧪 Garble test [${{ matrix.os }}]"
needs: [ prepare ]
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest, macos-latest, windows-latest ]
steps:
- name: 🛎️ Checkout
uses: actions/checkout@v6
with:
ref: main
fetch-depth: 1
- name: 📥 Download source
uses: actions/download-artifact@v4
with:
name: src-gen
path: .
- uses: ./.github/actions/init-go
with:
go-version: ${{ env.GO_VERSION }}
- uses: ./.github/actions/run-tests
with:
use-garble: 'true'
bump-version:
name: "📦 Minor version bump"
needs: [ test-garble ]
runs-on: ubuntu-latest
steps:
- name: 🛎️ Checkout
uses: actions/checkout@v6
with:
ref: main
fetch-depth: 0
- uses: ./.github/actions/github-setup-user
- uses: ./.github/actions/init-go
with:
go-version: ${{ env.GO_VERSION }}
- name: 📦 Increment minor version
shell: bash
env:
GOFLAGS: -mod=mod
run: |
set -Eeuo pipefail
new_ver=$(./_run/scripts/sys.sh --increment --minor)
echo "New version: $new_ver"
mkdir -p target tmp
go generate ./...
git add _run/values/ver.txt
git commit -m "minor(${new_ver}): release"
git push origin HEAD:main
- uses: ./.github/actions/generate-build-env
- name: 📦 Upload source
uses: actions/upload-artifact@v4
with:
name: src-bumped
path: .
build:
name: "🛠️ Build all platforms"
needs: [ bump-version ]
runs-on: ubuntu-latest
steps:
- name: 🛎️ Checkout
uses: actions/checkout@v6
with:
ref: main
fetch-depth: 1
- name: 📥 Download source
uses: actions/download-artifact@v4
with:
name: src-bumped
path: .
- name: 🗒️ Source env
shell: bash
run: cat build_env.txt >> $GITHUB_ENV
- uses: ./.github/actions/init-go
with:
go-version: ${{ env.GO_VERSION }}
- name: 📦 Install garble
shell: bash
run: go install mvdan.cc/garble@latest
- name: 🛠️ Cross-compile all targets
shell: bash
run: |
set -Eeuo pipefail
mkdir -p dist
# format: GOOS/GOARCH[/variant]
targets=(
windows/amd64
windows/arm64
windows/arm/7
windows/386
linux/amd64
linux/arm64
linux/arm/7
linux/arm/6
linux/386
linux/mips/softfloat
linux/mipsle/softfloat
linux/mips64
linux/mips64le
linux/ppc64
linux/ppc64le
linux/riscv64
linux/s390x
darwin/amd64
darwin/arm64
freebsd/amd64
freebsd/arm64
freebsd/arm/6
freebsd/arm/7
freebsd/386
openbsd/amd64
openbsd/arm64
openbsd/arm/6
openbsd/arm/7
openbsd/386
netbsd/amd64
netbsd/arm64
netbsd/arm/6
netbsd/arm/7
netbsd/386
android/amd64
android/arm64
android/arm/7
android/386
)
NDK_BIN="${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/linux-x86_64/bin"
ANDROID_API=21
for target in "${targets[@]}"; do
IFS='/' read -r os arch variant <<< "$target"
export GOOS="$os"
export GOARCH="$arch"
export CGO_ENABLED=0
unset GOARM GOMIPS CC
suffix=""
tag="${os}-${arch}"
if [[ "$os" == "windows" ]]; then
suffix=".exe"
fi
if [[ "$arch" == "arm" && -n "$variant" ]]; then
export GOARM="$variant"
tag="${os}-armv${variant}"
elif [[ ("$arch" == "mips" || "$arch" == "mipsle") && -n "$variant" ]]; then
export GOMIPS="$variant"
fi
# android/amd64, android/arm, android/386 require CGO (external linker)
if [[ "$os" == "android" && "$arch" != "arm64" ]]; then
export CGO_ENABLED=1
case "$arch" in
amd64) export CC="${NDK_BIN}/x86_64-linux-android${ANDROID_API}-clang" ;;
arm) export CC="${NDK_BIN}/armv7a-linux-androideabi${ANDROID_API}-clang" ;;
386) export CC="${NDK_BIN}/i686-linux-android${ANDROID_API}-clang" ;;
esac
fi
outname="${BUILD_NAME}-${tag}${suffix}"
echo "→ ${outname}"
garble -tiny build -ldflags="-s -w" -o "dist/${outname}" ./
done
echo ""
echo "=== Built $(ls dist/ | wc -l) binaries ==="
ls -lhS dist/
- name: 📦 Upload binaries
uses: actions/upload-artifact@v4
with:
name: binaries
if-no-files-found: error
path: dist/
release:
name: "🚀 Release"
needs: [ bump-version, build ]
runs-on: ubuntu-latest
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: 🛎️ Checkout
uses: actions/checkout@v6
with:
ref: main
fetch-depth: 0
- name: 📥 Download source
uses: actions/download-artifact@v4
with:
name: src-bumped
path: .
- name: 🗒️ Source env
shell: bash
run: cat build_env.txt >> $GITHUB_ENV
- name: 📥 Download binaries
uses: actions/download-artifact@v4
with:
name: binaries
path: dist
- uses: ./.github/actions/github-setup-user
- name: 🏷️ Tag and release
shell: bash
run: |
set -Eeuo pipefail
git tag -a "${BUILD_VER}" -m "Release ${BUILD_VER}"
git push origin "${BUILD_VER}"
gh release create "${BUILD_VER}" dist/* \
--title "${BUILD_VER}" \
--generate-notes
- name: 🧹 Cleanup artifacts
if: always()
uses: geekyeggo/delete-artifact@v5
with:
name: |
src-gen
src-bumped
binaries
failOnError: false