-
Notifications
You must be signed in to change notification settings - Fork 1
409 lines (353 loc) · 15 KB
/
Copy pathbuild.yml
File metadata and controls
409 lines (353 loc) · 15 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
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
name: Multi-Platform Build
on:
push:
branches: [main, "[0-9]+.[0-9]+"]
tags:
- "v*"
paths-ignore:
- "README.md"
- "CHANGELOG.md"
- ".gitignore"
- "site/**"
- "scripts/check-sitemap.mjs"
- "scripts/check-site-structured-data.mjs"
- "wrangler.jsonc"
- ".github/workflows/site.yml"
pull_request:
branches: [main, "[0-9]+.[0-9]+"]
paths-ignore:
- "README.md"
- "CHANGELOG.md"
- ".gitignore"
- "site/**"
- "scripts/check-sitemap.mjs"
- "scripts/check-site-structured-data.mjs"
- "wrangler.jsonc"
- ".github/workflows/site.yml"
workflow_dispatch:
concurrency:
# A branch push and its pull-request synchronization carry the same head SHA.
# Group them together so only one verification run survives. Release tags and
# explicit packaging runs stay isolated and must finish.
group: ${{ github.workflow }}-${{ startsWith(github.ref, 'refs/tags/') && github.ref || github.event_name == 'workflow_dispatch' && github.run_id || github.event.pull_request.head.sha || github.sha }}
cancel-in-progress: ${{ !startsWith(github.ref, 'refs/tags/') && github.event_name != 'workflow_dispatch' }}
jobs:
# Lint, type-check, audit and build the frontend once, reuse the dist/ output
# across all matrix jobs. This avoids running Vite 5× (once per platform) and
# surfaces TypeScript / lint errors before any Rust compilation starts.
frontend:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803
with:
fetch-depth: 1
- name: Set up Node
uses: actions/setup-node@249970729cb0ef3589644e2896645e5dc5ba9c38
with:
node-version: 22.23.1
cache: npm
- name: Install npm dependencies
run: npm ci --prefer-offline --no-audit --fund=false
- name: Audit npm dependencies
run: npm audit --audit-level=high
- name: Check version alignment
run: npm run version:check
- name: Check asset organization
run: npm run assets:check
- name: Lint
run: npm run lint
- name: Typecheck
run: npm run typecheck
- name: Test
run: npm test
- name: Build frontend
run: npm run build
- name: Check frontend bundle budget
run: npm run bundle:check
- name: Upload dist
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a
with:
name: frontend-dist
path: dist/
if-no-files-found: error
retention-days: 1
# Run every Rust quality gate in one job to avoid another runner startup.
# Clippy and tests use the same profile as non-release builds so the gated
# Linux x86_64 build can reuse compatible dependency artifacts.
rust-compile-checks:
# Match the Linux x86_64 bundle runner so both apt and Rust caches are
# distro-compatible and reusable by the gated build job.
runs-on: ubuntu-22.04
permissions:
contents: read
steps:
- uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803
with:
fetch-depth: 1
- name: Install system dependencies
uses: awalsh128/cache-apt-pkgs-action@553a35bb8ebd9fcabcb1c9451aa4c98e1b4ca8a9
with:
# Keep this identical to the Linux build package set so its gated
# x86_64 job restores the cache populated by these compile checks.
packages: libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf xdg-utils
version: 1.0
- name: Set up Rust
uses: dtolnay/rust-toolchain@6c977a6ca4077a0ceb28ffbe03f59d46e9ac8772
with:
toolchain: 1.97.1
components: clippy,rustfmt
- name: Rustfmt check
run: cargo fmt --check --manifest-path src-tauri/Cargo.toml
- name: Install cargo-audit
uses: taiki-e/install-action@b20dedce73af6905cdc30d6611090c9b67557c8d
with:
tool: cargo-audit@0.22.2
checksum: true
fallback: none
- name: Audit Rust dependencies
run: cargo audit
working-directory: src-tauri
- name: Cache Rust dependencies
uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6
with:
workspaces: src-tauri
# rust-cache does not distinguish Ubuntu releases. Keep the shared
# lint/build cache isolated from artifacts produced on ubuntu-latest.
shared-key: rust-linux-ubuntu-22.04-v1
- name: Clippy
run: cargo clippy --target x86_64-unknown-linux-gnu --profile ci --manifest-path src-tauri/Cargo.toml --tests -- -D warnings
- name: Rust tests
run: cargo test --target x86_64-unknown-linux-gnu --profile ci --manifest-path src-tauri/Cargo.toml
build:
# Gate the expensive cross-platform build matrix on the frontend artifact
# plus the Rust quality jobs so known-bad revisions fail before fan-out.
# Linux x86_64 still reuses the `rust-linux` registry/source cache and
# any compatible artifacts populated by rust-compile-checks.
needs: [frontend, rust-compile-checks]
permissions:
contents: read
id-token: write
attestations: write
artifact-metadata: write
strategy:
fail-fast: false
matrix:
include:
- platform: windows-latest
arch: x86_64
rust-target: x86_64-pc-windows-msvc
tauri-target: x86_64-pc-windows-msvc
bundle: nsis
artifact-name: vidcord-windows-x86_64
- platform: windows-latest
arch: aarch64
rust-target: aarch64-pc-windows-msvc
tauri-target: aarch64-pc-windows-msvc
bundle: nsis
artifact-name: vidcord-windows-aarch64
- platform: ubuntu-22.04
arch: x86_64
rust-target: x86_64-unknown-linux-gnu
tauri-target: x86_64-unknown-linux-gnu
bundle: appimage
artifact-name: vidcord-linux-x86_64
- platform: ubuntu-24.04-arm
arch: aarch64
rust-target: aarch64-unknown-linux-gnu
tauri-target: aarch64-unknown-linux-gnu
bundle: appimage
artifact-name: vidcord-linux-aarch64
- platform: macos-latest
arch: universal
rust-target: aarch64-apple-darwin,x86_64-apple-darwin
tauri-target: universal-apple-darwin
bundle: dmg
artifact-name: vidcord-macos
runs-on: ${{ matrix.platform }}
steps:
- uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803
with:
fetch-depth: 1
- name: Download frontend dist
uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131
with:
name: frontend-dist
path: dist/
- name: Install system dependencies (Linux)
if: startsWith(matrix.platform, 'ubuntu')
uses: awalsh128/cache-apt-pkgs-action@553a35bb8ebd9fcabcb1c9451aa4c98e1b4ca8a9
with:
packages: libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf xdg-utils
version: 1.0
- name: Set up Node
uses: actions/setup-node@249970729cb0ef3589644e2896645e5dc5ba9c38
with:
node-version: 22.23.1
cache: npm
- name: Install locked npm dependencies
run: npm ci --prefer-offline --no-audit --fund=false
- name: Verify locked Tauri build tool
run: npm run build-tools:check
- name: Set up Rust
uses: dtolnay/rust-toolchain@6c977a6ca4077a0ceb28ffbe03f59d46e9ac8772
with:
toolchain: 1.97.1
targets: ${{ matrix.rust-target }}
- name: Cache Rust dependencies (Linux x86_64, shared with rust-compile-checks)
if: matrix.rust-target == 'x86_64-unknown-linux-gnu'
uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6
with:
workspaces: src-tauri
shared-key: rust-linux-ubuntu-22.04-v1
# Windows target artifacts are not interchangeable. Keep target-specific
# keys so each architecture reuses its own prior builds without cache
# contamination or two jobs racing to publish the same entry.
- name: Cache Rust dependencies (Windows)
if: startsWith(matrix.platform, 'windows-latest')
uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6
with:
workspaces: src-tauri
shared-key: rust-windows-${{ matrix.rust-target }}
- name: Cache Rust dependencies
if: matrix.rust-target != 'x86_64-unknown-linux-gnu' && !startsWith(matrix.platform, 'windows-latest')
uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6
with:
workspaces: src-tauri
- name: Verify platform build
if: ${{ !startsWith(github.ref, 'refs/tags/') && github.event_name != 'workflow_dispatch' }}
run: npm run tauri -- build --target ${{ matrix.tauri-target }} --no-bundle --config '{"build":{"beforeBuildCommand":""}}' -- --profile ci
- name: Build installer
if: ${{ startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch' }}
run: npm run tauri -- build --target ${{ matrix.tauri-target }} --bundles ${{ matrix.bundle }} --config '{"build":{"beforeBuildCommand":""}}' -- --profile ${{ startsWith(github.ref, 'refs/tags/') && 'release' || 'ci' }}
- name: Stage artifacts (Unix)
if: ${{ matrix.platform != 'windows-latest' && (startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch') }}
run: |
mkdir -p artifacts
find src-tauri/target \( -name "*.AppImage" -o -name "*.dmg" \) -exec cp {} artifacts/ \;
- name: Stage artifacts (Windows)
if: ${{ matrix.platform == 'windows-latest' && (startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch') }}
shell: pwsh
run: |
New-Item -ItemType Directory -Force -Path artifacts
Get-ChildItem -Path src-tauri\target -Recurse -Filter *.exe |
Where-Object { $_.DirectoryName -like "*bundle\nsis*" } |
ForEach-Object { Copy-Item $_.FullName -Destination artifacts\ }
- name: Attest built installers
if: ${{ startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch' }}
uses: actions/attest@1e69f48acb82d1966a394da916b4c1698aa569d6
with:
subject-path: artifacts/*
- name: Upload artifacts
if: ${{ startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch' }}
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a
with:
name: ${{ matrix.artifact-name }}
path: artifacts/
if-no-files-found: error
# AppImage, DMG and NSIS outputs are already compressed. Avoid a
# second CPU-heavy compression pass and bound transient CI storage.
compression-level: 0
retention-days: 7
sign-release-artifacts:
needs: build
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
permissions:
contents: read
attestations: read
steps:
- uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803
with:
fetch-depth: 1
- name: Download release artifacts
uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131
with:
path: release-artifacts
merge-multiple: true
pattern: vidcord-*
- name: Verify build artifact provenance
env:
GH_TOKEN: ${{ github.token }}
run: |
set -euo pipefail
while IFS= read -r -d '' artifact; do
gh attestation verify "$artifact" \
--repo "$GITHUB_REPOSITORY" \
--signer-workflow "$GITHUB_REPOSITORY/.github/workflows/build.yml" \
--source-ref "$GITHUB_REF"
done < <(
find release-artifacts -type f \( \
-name '*.AppImage' -o -name '*.dmg' -o -name '*.exe' \
\) -print0
)
- name: Sign verified installers
env:
RELEASE_SIGNING_KEY: ${{ secrets.VIDCORD_RELEASE_SIGNING_KEY }}
RELEASE_TAG: ${{ github.ref_name }}
run: |
set -euo pipefail
test -n "$RELEASE_SIGNING_KEY"
umask 077
printf '%s\n' "$RELEASE_SIGNING_KEY" > release-signing-key.pem
trap 'rm -f release-signing-key.pem' EXIT
expected_public_key="$(tr -d '[:space:]' < src-tauri/update-signing-public-key.hex)"
actual_public_key="$(openssl pkey -in release-signing-key.pem -pubout -outform DER | tail -c 32 | od -An -tx1 -v | tr -d ' \n')"
test "$actual_public_key" = "$expected_public_key"
test -n "$(find release-artifacts -type f \( \
-name '*.AppImage' -o -name '*.dmg' -o -name '*.exe' \
\) -print -quit)"
while IFS= read -r -d '' artifact; do
asset_name="$(basename "$artifact")"
digest="$(sha256sum "$artifact" | cut -d ' ' -f1)"
printf 'vidcord-update-signature-v1\n%s\n%s\n%s\n' \
"$RELEASE_TAG" "$asset_name" "$digest" > "$artifact.message"
openssl pkeyutl -sign -rawin -inkey release-signing-key.pem \
-in "$artifact.message" -out "$artifact.sig"
test "$(wc -c < "$artifact.sig")" -eq 64
rm -f "$artifact.message"
done < <(
find release-artifacts -type f \( \
-name '*.AppImage' -o -name '*.dmg' -o -name '*.exe' \
\) -print0
)
- name: Upload signed release artifacts
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a
with:
name: signed-release-artifacts
path: release-artifacts/
if-no-files-found: error
retention-days: 1
publish-release:
needs: sign-release-artifacts
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
permissions:
contents: write
steps:
- uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803
with:
fetch-depth: 1
- name: Download signed release artifacts
uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131
with:
name: signed-release-artifacts
path: release-artifacts
- name: Extract release notes
run: |
TAG="${GITHUB_REF#refs/tags/}"
awk -v tag="## $TAG" 'found && /^## /{exit} $0==tag{found=1;next} found' CHANGELOG.md > release_notes.md
if [ ! -s release_notes.md ]; then
echo "CHANGELOG.md has no non-empty ## $TAG release section" >&2
exit 1
fi
- name: Create release
# v3.0.0, pinned because this job has contents:write.
uses: softprops/action-gh-release@b4309332981a82ec1c5618f44dd2e27cc8bfbfda
with:
files: release-artifacts/**/*
draft: true
body_path: release_notes.md
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}