-
Notifications
You must be signed in to change notification settings - Fork 0
373 lines (335 loc) · 11.8 KB
/
Copy pathrelease.yml
File metadata and controls
373 lines (335 loc) · 11.8 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
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
name: Publish signed release
on:
push:
tags:
- v*
permissions:
contents: write
concurrency:
group: release-${{ github.ref }}
cancel-in-progress: false
jobs:
verify-version:
name: Verify release version
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v7
- name: Match tag to package version
shell: bash
run: |
set -euo pipefail
package_version="$(node -p "require('./package.json').version")"
test "${GITHUB_REF_NAME}" = "v${package_version}" || {
echo "Tag ${GITHUB_REF_NAME} does not match package version v${package_version}."
exit 1
}
- name: Test updater manifest safeguards
run: node --test scripts/lib/updater-manifest.test.mjs
quality:
name: Format, lint, test, and build
needs: verify-version
runs-on: ubuntu-22.04
timeout-minutes: 30
steps:
- name: Checkout full history
uses: actions/checkout@v7
with:
fetch-depth: 0
- name: Install Linux system dependencies
run: |
sudo apt-get update
sudo apt-get install -y \
libwebkit2gtk-4.1-dev \
libappindicator3-dev \
librsvg2-dev \
patchelf
- name: Set up Node.js
uses: actions/setup-node@v6
with:
node-version: 22
cache: npm
- name: Set up Rust
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- name: Restore Rust cache
uses: swatinem/rust-cache@v2
with:
workspaces: src-tauri -> target
- name: Install frontend dependencies
run: npm ci
- name: Run complete checks
run: npm run check
create-release:
name: Create draft release
needs:
- verify-version
- quality
runs-on: ubuntu-latest
outputs:
release_id: ${{ steps.release.outputs.release_id }}
steps:
- name: Checkout full history
uses: actions/checkout@v7
with:
fetch-depth: 0
- name: Generate changelog from commits
env:
NOTES_PATH: ${{ runner.temp }}/release-notes.md
shell: bash
run: |
set -euo pipefail
node scripts/generate-changelog.mjs \
--auto-from \
--auto-from-ref "${GITHUB_SHA}^" \
--to "${GITHUB_SHA}" \
--version "${GITHUB_REF_NAME}" \
--repository "${GITHUB_REPOSITORY}" \
--output "${NOTES_PATH}" \
--strict
- name: Create or reuse one draft
id: release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NOTES_PATH: ${{ runner.temp }}/release-notes.md
shell: bash
run: |
set -euo pipefail
release_id="$(
gh api "repos/${GITHUB_REPOSITORY}/releases?per_page=100" \
--jq ".[] | select(.tag_name == \"${GITHUB_REF_NAME}\" and .draft == true) | .id" \
| head -n 1
)"
if [[ -z "${release_id}" ]]; then
release_id="$(
gh api --method POST "repos/${GITHUB_REPOSITORY}/releases" \
-f tag_name="${GITHUB_REF_NAME}" \
-f target_commitish="${GITHUB_SHA}" \
-f name="BiliRec Control ${GITHUB_REF_NAME}" \
-f body="$(cat "${NOTES_PATH}")" \
-F draft=true \
-F prerelease=false \
--jq '.id'
)"
else
gh api --method PATCH \
"repos/${GITHUB_REPOSITORY}/releases/${release_id}" \
-f name="BiliRec Control ${GITHUB_REF_NAME}" \
-f body="$(cat "${NOTES_PATH}")" \
-F draft=true \
-F prerelease=false \
>/dev/null
fi
echo "release_id=${release_id}" >> "${GITHUB_OUTPUT}"
build-release:
name: ${{ matrix.name }}
needs:
- verify-version
- quality
- create-release
strategy:
fail-fast: false
matrix:
include:
- name: Windows x64
os: windows-latest
target: x86_64-pc-windows-msvc
rust_targets: x86_64-pc-windows-msvc
bundles: nsis,msi
platform: windows
archive: windows-x64
- name: Windows ARM64
os: windows-11-arm
target: aarch64-pc-windows-msvc
rust_targets: aarch64-pc-windows-msvc
bundles: nsis
platform: windows
archive: windows-arm64
- name: Linux x64
os: ubuntu-22.04
target: x86_64-unknown-linux-gnu
rust_targets: x86_64-unknown-linux-gnu
bundles: appimage,deb,rpm
platform: linux
archive: linux-x64
- name: Linux ARM64
os: ubuntu-22.04-arm
target: aarch64-unknown-linux-gnu
rust_targets: aarch64-unknown-linux-gnu
bundles: appimage,deb,rpm
platform: linux
archive: linux-arm64
- name: macOS Intel
os: macos-15-intel
target: x86_64-apple-darwin
rust_targets: x86_64-apple-darwin
bundles: app,dmg
platform: macos
archive: macos-x64
- name: macOS Apple Silicon
os: macos-15
target: aarch64-apple-darwin
rust_targets: aarch64-apple-darwin
bundles: app,dmg
platform: macos
archive: macos-arm64
- name: macOS Universal
os: macos-15
target: universal-apple-darwin
rust_targets: aarch64-apple-darwin,x86_64-apple-darwin
bundles: app,dmg
platform: macos
archive: macos-universal
runs-on: ${{ matrix.os }}
timeout-minutes: 75
steps:
- name: Checkout
uses: actions/checkout@v7
- name: Install Linux system dependencies
if: matrix.platform == 'linux'
run: |
sudo apt-get update
sudo apt-get install -y \
libwebkit2gtk-4.1-dev \
libappindicator3-dev \
librsvg2-dev \
patchelf \
libfuse2 \
xdg-utils \
rpm \
zip
- name: Set up Node.js
uses: actions/setup-node@v6
with:
node-version: 22
cache: npm
- name: Set up Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.rust_targets }}
- name: Restore Rust cache
uses: swatinem/rust-cache@v2
with:
workspaces: src-tauri -> target
- name: Install frontend dependencies
run: npm ci
- name: Build and upload signed release packages
uses: tauri-apps/tauri-action@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }}
TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }}
with:
releaseId: ${{ needs.create-release.outputs.release_id }}
tagName: ${{ github.ref_name }}
releaseDraft: true
prerelease: false
updaterJsonPreferNsis: true
uploadUpdaterJson: false
args: --target ${{ matrix.target }} --bundles ${{ matrix.bundles }}
- name: Create Windows portable ZIP
if: matrix.platform == 'windows'
shell: pwsh
run: |
$version = node -p "require('./package.json').version"
$binary = "src-tauri/target/${{ matrix.target }}/release/bilirec-control.exe"
if (-not (Test-Path -LiteralPath $binary)) {
throw "Portable executable not found: $binary"
}
New-Item -ItemType Directory -Path dist -Force | Out-Null
Compress-Archive `
-LiteralPath $binary, "PORTABLE.md" `
-DestinationPath "dist/BiliRec-Control-$version-${{ matrix.archive }}-portable.zip" `
-CompressionLevel Optimal `
-Force
- name: Create Linux portable ZIP
if: matrix.platform == 'linux'
shell: bash
run: |
set -euo pipefail
version="$(node -p "require('./package.json').version")"
appimage="$(find "src-tauri/target/${{ matrix.target }}/release/bundle/appimage" -maxdepth 1 -type f -name '*.AppImage' -print -quit)"
test -n "$appimage"
mkdir -p dist
zip -j "dist/BiliRec-Control-${version}-${{ matrix.archive }}-portable.zip" "$appimage" PORTABLE.md
- name: Create macOS portable ZIP
if: matrix.platform == 'macos'
shell: bash
run: |
set -euo pipefail
version="$(node -p "require('./package.json').version")"
app="$(find "src-tauri/target/${{ matrix.target }}/release/bundle/macos" -maxdepth 1 -type d -name '*.app' -print -quit)"
test -n "$app"
mkdir -p dist
ditto -c -k --keepParent "$app" "dist/BiliRec-Control-${version}-${{ matrix.archive }}-portable.zip"
- name: Upload portable archive to draft release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
shell: bash
run: gh release upload "${GITHUB_REF_NAME}" dist/*.zip --clobber
publish-release:
name: Publish release
needs:
- create-release
- build-release
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: Checkout
uses: actions/checkout@v7
- name: Rebuild updater manifest and synchronize release notes
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RELEASE_ID: ${{ needs.create-release.outputs.release_id }}
shell: bash
run: |
set -euo pipefail
work_dir="${RUNNER_TEMP}/updater-release-notes"
mkdir -p "${work_dir}"
node scripts/build-updater-manifest.mjs \
--repository "${GITHUB_REPOSITORY}" \
--release-id "${RELEASE_ID}" \
--tag "${GITHUB_REF_NAME}" \
--output "${work_dir}/latest.json"
node scripts/validate-updater-manifest.mjs \
--input "${work_dir}/latest.json" \
--repository "${GITHUB_REPOSITORY}" \
--tag "${GITHUB_REF_NAME}"
gh release upload "${GITHUB_REF_NAME}" "${work_dir}/latest.json" \
--repo "${GITHUB_REPOSITORY}" \
--clobber
- name: Publish the completed release for verification
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RELEASE_ID: ${{ needs.create-release.outputs.release_id }}
run: |
gh api --method PATCH \
"repos/${GITHUB_REPOSITORY}/releases/${RELEASE_ID}" \
-F draft=false \
-f make_latest=false
- name: Verify anonymous updater downloads for tag
shell: bash
run: |
set -euo pipefail
node scripts/verify-public-updater.mjs \
--url "https://github.com/${GITHUB_REPOSITORY}/releases/download/${GITHUB_REF_NAME}/latest.json" \
--repository "${GITHUB_REPOSITORY}" \
--tag "${GITHUB_REF_NAME}" \
--probe
- name: Promote the verified release to latest
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RELEASE_ID: ${{ needs.create-release.outputs.release_id }}
run: |
gh api --method PATCH \
"repos/${GITHUB_REPOSITORY}/releases/${RELEASE_ID}" \
-f make_latest=true
- name: Verify latest updater metadata
shell: bash
run: |
set -euo pipefail
node scripts/verify-public-updater.mjs \
--url "https://github.com/${GITHUB_REPOSITORY}/releases/latest/download/latest.json" \
--repository "${GITHUB_REPOSITORY}" \
--tag "${GITHUB_REF_NAME}"