Repository navigation
444 lines (432 loc) · 20 KB
/
Copy pathrelease.yml
File metadata and controls
444 lines (432 loc) · 20 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
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
name: Release
# Builds the installable packages and, for a version tag, publishes them as a draft
# GitHub release:
# macOS Device-<version>-macos-universal.dmg (Apple silicon + Intel)
# Windows Device-<version>-windows-x64-setup.exe (installer)
# Device-<version>-windows-x64.zip (portable)
# Linux Device-<version>-linux-x86_64.tar.gz
# Device-<version>-linux-aarch64.tar.gz
#
# Releasing (docs/building.md > Versions and releases): a release PR sets `version` in the
# root Cargo.toml to X.Y.Z (SemVer, 0.x while pre-alpha; X.Y.Z-alpha.N, -beta.N or -rc.N for a
# pre-release) and moves CHANGELOG.md's Unreleased entries under `## [X.Y.Z] - date`. Merge it,
# then push the tag vX.Y.Z on that commit. The tag must be on main, match Cargo.toml and have a
# changelog section, or nothing builds. The release is created as a draft whose notes are that
# section followed by GitHub's generated list of pull requests; a pre-release version is
# marked as a pre-release. Review the packages and publish it by hand.
#
# Other runs build the packages without releasing anything (download them from the run's
# artifacts):
# - Actions > Release > Run workflow, from any branch;
# - pull requests that change the packaging (this file, tools/release/, the bundle script).
#
# Signing: the macOS app is signed with a Developer ID and notarised only for release tags,
# in the `macos-sign` job, which runs in the protected `release` environment. Its secrets are
# environment secrets of `release` (not repository secrets): MACOS_CERTIFICATE (base64 .p12 of
# a Developer ID Application certificate), MACOS_CERTIFICATE_PASSWORD, MACOS_SIGN_IDENTITY,
# and for notarisation an App Store Connect API key: APPLE_API_KEY (base64 .p8),
# APPLE_API_KEY_ID and APPLE_API_ISSUER. Without them a tagged release fails, unless the
# repository variable ALLOW_UNSIGNED_MACOS is true (then it is signed ad hoc). Pull requests
# and manual runs, even from a tag, never reach them. The Windows packages are not signed yet.
on:
push:
tags: ['v*.*.*']
pull_request:
paths:
- '.github/workflows/release.yml'
- 'tools/release/**'
- 'tools/macos-bundle.sh'
workflow_dispatch:
permissions:
contents: read
concurrency:
group: release-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
env:
CARGO_TERM_COLOR: always
# A release is a pushed v* tag. A manual run started from a tag is a test build like any other.
IS_RELEASE: ${{ github.event_name == 'push' && github.ref_type == 'tag' }}
jobs:
version:
name: Check version
runs-on: ubuntu-latest
timeout-minutes: 10
outputs:
version: ${{ steps.v.outputs.version }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
fetch-depth: 0 # the tag's ancestry is checked against main
- id: v
name: Version from Cargo.toml (and the tag)
run: |
set -euo pipefail
version=$(sed -n '/^\[workspace.package\]/,/^\[/s/^version = "\(.*\)"/\1/p' Cargo.toml)
[ -n "$version" ] || { echo "::error::no [workspace.package] version in Cargo.toml"; exit 1; }
if [ "$IS_RELEASE" = true ]; then
tag_version="${GITHUB_REF_NAME#v}"
if [ "$tag_version" != "$version" ]; then
echo "::error::tag $GITHUB_REF_NAME does not match the Cargo.toml version $version"
exit 1
fi
if ! [[ "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-(alpha|beta|rc)\.[0-9]+)?$ ]]; then
echo "::error::version $version is not X.Y.Z or X.Y.Z-alpha.N / -beta.N / -rc.N"
exit 1
fi
bash tools/release/changelog-notes.sh "$version" > /dev/null \
|| { echo "::error::CHANGELOG.md has no section for $version"; exit 1; }
git fetch --no-tags origin main:refs/remotes/origin/main
if ! git merge-base --is-ancestor "$GITHUB_SHA" refs/remotes/origin/main; then
echo "::error::tag $GITHUB_REF_NAME is not on main; releases are built from main only"
exit 1
fi
else
# Not a release: mark the packages as a development build of this commit.
version="$version-dev.$(git rev-parse --short HEAD)"
fi
echo "version=$version" >> "$GITHUB_OUTPUT"
echo "Version: $version"
# The two architectures build side by side on their own runners (each is a full release
# build of the app and the engine, about 13 minutes); the macos job joins them with lipo.
macos-build:
name: Build macOS (${{ matrix.arch }})
needs: version
strategy:
matrix:
include:
- arch: aarch64
triple: aarch64-apple-darwin
cmake_arch: arm64
- arch: x86_64
triple: x86_64-apple-darwin
cmake_arch: x86_64
runs-on: macos-15
timeout-minutes: 60
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Rust toolchain (stable, ${{ matrix.triple }})
run: |
rustup toolchain install stable --profile minimal --no-self-update --target ${{ matrix.triple }}
rustup default stable
- name: Install Ninja
run: brew install ninja
- uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: |
~/.cargo/registry/index
~/.cargo/registry/cache
~/.cargo/git/db
key: release-cargo-${{ runner.os }}-${{ hashFiles('Cargo.lock') }}
# The engine's C++ is built by build.rs (CMake). The x86_64 engine is cross-compiled on
# this Apple silicon runner.
- name: Build
env:
MACOSX_DEPLOYMENT_TARGET: '13.0'
CMAKE_OSX_ARCHITECTURES: ${{ matrix.cmake_arch }}
run: cargo build --release --locked -p dstudio-app --target ${{ matrix.triple }}
- name: Collect the app and the plugin scanner
run: |
set -euo pipefail
mkdir -p "build/macos-${{ matrix.arch }}"
cp "target/${{ matrix.triple }}/release/device-studio" "build/macos-${{ matrix.arch }}/"
scanner=$(bash tools/release/find-scanner.sh "target/${{ matrix.triple }}/release")
cp "$scanner" "build/macos-${{ matrix.arch }}/"
lipo -info "build/macos-${{ matrix.arch }}"/*
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: macos-build-${{ matrix.arch }}
path: build/macos-${{ matrix.arch }}
if-no-files-found: error
retention-days: 1
macos:
name: Package macOS (universal)
needs: [version, macos-build]
runs-on: macos-15
timeout-minutes: 30
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: macos-build-aarch64
path: build/macos-aarch64
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: macos-build-x86_64
path: build/macos-x86_64
- name: Bundle the universal app
env:
DSTUDIO_MACOS_ARM_DIR: build/macos-aarch64
DSTUDIO_MACOS_X86_DIR: build/macos-x86_64
run: |
bash tools/release/package-macos.sh build/macos
ditto -c -k --keepParent "build/macos/Device.app" build/macos/Device-app.zip
# The unsigned app goes to the signing job (tags only); every other run makes an
# ad hoc signed .dmg here, with no secrets in reach.
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
if: github.event_name == 'push' && github.ref_type == 'tag'
with:
name: macos-app
path: build/macos/Device-app.zip
if-no-files-found: error
retention-days: 1
- name: Package .dmg (ad hoc signed)
if: env.IS_RELEASE != 'true'
run: bash tools/release/make-dmg.sh "build/macos/Device.app" "${{ needs.version.outputs.version }}" dist
- name: Smoke test (the packaged app starts and renders)
if: env.IS_RELEASE != 'true'
run: bash tools/release/smoke-macos.sh dist/*.dmg
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
if: env.IS_RELEASE != 'true'
with:
name: package-macos
path: dist/*.dmg
if-no-files-found: error
# Signing and notarisation run only here: for a release tag, in the `release` environment,
# whose secrets no other job, pull request or manual run can read. Protect that
# environment (Settings > Environments > release): required reviewer, and deployments
# from tags matching v* only. Then a signing run waits for an approval in the Actions tab.
macos-sign:
name: Sign and notarise macOS
needs: [version, macos]
if: github.event_name == 'push' && github.ref_type == 'tag'
runs-on: macos-15
timeout-minutes: 60
environment: release
env:
HAS_SIGNING_CERTIFICATE: ${{ secrets.MACOS_CERTIFICATE != '' }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: macos-app
path: build/macos
- name: Unpack the app
run: ditto -x -k build/macos/Device-app.zip build/macos
- name: Import the signing certificate and the notary key
id: cert
if: env.HAS_SIGNING_CERTIFICATE == 'true'
env:
MACOS_CERTIFICATE: ${{ secrets.MACOS_CERTIFICATE }}
MACOS_CERTIFICATE_PASSWORD: ${{ secrets.MACOS_CERTIFICATE_PASSWORD }}
APPLE_API_KEY: ${{ secrets.APPLE_API_KEY }}
run: |
set -euo pipefail
keychain="$RUNNER_TEMP/signing.keychain-db"
password="$(openssl rand -hex 16)"
echo "$MACOS_CERTIFICATE" | base64 --decode > "$RUNNER_TEMP/cert.p12"
security create-keychain -p "$password" "$keychain"
security set-keychain-settings -lut 3600 "$keychain"
security unlock-keychain -p "$password" "$keychain"
security import "$RUNNER_TEMP/cert.p12" -k "$keychain" -P "$MACOS_CERTIFICATE_PASSWORD" -T /usr/bin/codesign
security set-key-partition-list -S apple-tool:,apple: -s -k "$password" "$keychain"
# The search list is the new keychain followed by the existing ones (word splitting intended).
# shellcheck disable=SC2046
security list-keychains -d user -s "$keychain" $(security list-keychains -d user | tr -d '"')
rm "$RUNNER_TEMP/cert.p12"
if [ -n "$APPLE_API_KEY" ]; then
echo "$APPLE_API_KEY" | base64 --decode > "$RUNNER_TEMP/notary-key.p8"
echo "APPLE_API_KEY_PATH=$RUNNER_TEMP/notary-key.p8" >> "$GITHUB_ENV"
fi
- name: Sign, notarise and package .dmg
env:
MACOS_SIGN_IDENTITY: ${{ steps.cert.outcome == 'success' && secrets.MACOS_SIGN_IDENTITY || '' }}
APPLE_API_KEY_ID: ${{ secrets.APPLE_API_KEY_ID }}
APPLE_API_ISSUER: ${{ secrets.APPLE_API_ISSUER }}
# A tagged release must be signed and notarised. Set the repository variable
# ALLOW_UNSIGNED_MACOS to true to publish an ad hoc signed .dmg instead.
REQUIRE_SIGNING: ${{ vars.ALLOW_UNSIGNED_MACOS != 'true' && '1' || '' }}
run: bash tools/release/make-dmg.sh "build/macos/Device.app" "${{ needs.version.outputs.version }}" dist
- name: Remove the signing keychain and key
if: always()
run: |
security delete-keychain "$RUNNER_TEMP/signing.keychain-db" 2>/dev/null || true
rm -f "$RUNNER_TEMP/notary-key.p8"
- name: Smoke test (the packaged app starts and renders)
run: bash tools/release/smoke-macos.sh dist/*.dmg
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: package-macos
path: dist/*.dmg
if-no-files-found: error
windows:
name: Package Windows (x64)
needs: version
runs-on: windows-2025
timeout-minutes: 60
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Rust toolchain (stable)
shell: bash
run: |
rustup toolchain install stable --profile minimal --no-self-update
rustup default stable
- name: MSVC developer environment
shell: pwsh
run: |
$vswhere = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe"
$vs = & $vswhere -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath
if (-not $vs) { throw "no Visual Studio with the C++ x64 tools" }
cmd /c "`"$vs\VC\Auxiliary\Build\vcvars64.bat`" >nul && set" | ForEach-Object {
if ($_ -match '^([^=]+)=(.*)$') { "$($Matches[1])=$($Matches[2])" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8 }
}
- name: Install Inno Setup
shell: pwsh
run: |
if (-not (Test-Path "${env:ProgramFiles(x86)}\Inno Setup 6\ISCC.exe")) { choco install innosetup --no-progress -y }
- uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: |
~/.cargo/registry/index
~/.cargo/registry/cache
~/.cargo/git/db
key: release-cargo-${{ runner.os }}-${{ hashFiles('Cargo.lock') }}
- name: Build
run: cargo build --release --locked -p dstudio-app
- name: Package installer and .zip
shell: pwsh
run: pwsh tools/release/package-windows.ps1 -Version "${{ needs.version.outputs.version }}" -OutDir dist
- name: Smoke test (the installer installs, the app starts)
shell: pwsh
env:
WGPU_BACKEND: dx12
SLINT_WGPU_CPU: '1' # WARP: no GPU on the runner
run: |
$setup = Get-ChildItem dist -Filter '*-setup.exe' | Select-Object -First 1
$dir = Join-Path $env:RUNNER_TEMP 'Device'
$p = Start-Process -FilePath $setup.FullName -ArgumentList '/VERYSILENT', '/SUPPRESSMSGBOXES', '/CURRENTUSER', "/DIR=$dir" -Wait -PassThru
if ($p.ExitCode -ne 0) { throw "installer exit code $($p.ExitCode)" }
foreach ($f in 'device-studio.exe', 'dstudio_plugin_scanner.exe', 'vcruntime140.dll') {
if (-not (Test-Path (Join-Path $dir $f))) { throw "$f not installed" }
}
$shot = Join-Path $env:RUNNER_TEMP 'windows.png'
$p = Start-Process -FilePath (Join-Path $dir 'device-studio.exe') -ArgumentList '--state', 'reference-default', '--screenshot', $shot -NoNewWindow -Wait -PassThru
"exit code: 0x{0:X8}" -f $p.ExitCode
if (-not (Test-Path $shot)) { throw "the installed app did not render" }
if ($p.ExitCode -ne 0) { throw "the installed app exited with 0x{0:X8}" -f $p.ExitCode }
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: package-windows
path: |
dist/*.exe
dist/*.zip
if-no-files-found: error
linux:
name: Package Linux (${{ matrix.arch }})
needs: version
strategy:
fail-fast: false
matrix:
include:
- arch: x86_64
runner: ubuntu-24.04
- arch: aarch64
runner: ubuntu-24.04-arm
runs-on: ${{ matrix.runner }}
timeout-minutes: 60
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Rust toolchain (stable)
shell: bash
run: |
rustup toolchain install stable --profile minimal --no-self-update
rustup default stable
- name: Install build packages
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends ninja-build pkg-config \
libpipewire-0.3-dev libasound2-dev \
libxkbcommon-dev libxkbcommon-x11-dev libwayland-dev libx11-dev libx11-xcb-dev \
libxcursor-dev libxrandr-dev libxi-dev libfontconfig1-dev libfreetype-dev libudev-dev
- uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: |
~/.cargo/registry/index
~/.cargo/registry/cache
~/.cargo/git/db
key: release-cargo-${{ runner.os }}-${{ matrix.arch }}-${{ hashFiles('Cargo.lock') }}
- name: Build
run: cargo build --release --locked -p dstudio-app
- name: Package .tar.gz
run: bash tools/release/package-linux.sh "${{ needs.version.outputs.version }}" ${{ matrix.arch }} dist
- name: Smoke test (install from the archive, the app starts and renders)
env:
WGPU_BACKEND: vulkan
SLINT_WGPU_CPU: '1' # lavapipe: no GPU on the runner
run: |
set -euo pipefail
sudo apt-get install -y --no-install-recommends xvfb mesa-vulkan-drivers
mkdir -p "$RUNNER_TEMP/unpack"
tar -C "$RUNNER_TEMP/unpack" -xzf dist/*.tar.gz
install_sh=("$RUNNER_TEMP"/unpack/*/install.sh)
"${install_sh[0]}" "$RUNNER_TEMP/prefix"
test -x "$RUNNER_TEMP/prefix/lib/device-studio/dstudio_plugin_scanner"
xvfb-run -a -s "-screen 0 1600x1000x24" "$RUNNER_TEMP/prefix/bin/device-studio" \
--state reference-default --screenshot "$RUNNER_TEMP/linux.png"
test -s "$RUNNER_TEMP/linux.png"
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: package-linux-${{ matrix.arch }}
path: dist/*.tar.gz
if-no-files-found: error
release:
name: Draft release
needs: [version, macos-sign, windows, linux]
if: github.event_name == 'push' && github.ref_type == 'tag'
runs-on: ubuntu-latest
timeout-minutes: 15
permissions:
contents: write # create the release and upload the packages
id-token: write # sign the build provenance (Sigstore, through GitHub's OIDC token)
attestations: write # store the provenance with the repository
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
sparse-checkout: |
CHANGELOG.md
tools/release
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
path: dist
pattern: package-*
merge-multiple: true
- name: Checksums
working-directory: dist
run: |
sha256sum -- * > "$RUNNER_TEMP/SHA256SUMS.txt"
mv "$RUNNER_TEMP/SHA256SUMS.txt" SHA256SUMS.txt
cat SHA256SUMS.txt
# SLSA build provenance for every package: anyone can check that a download was built
# by this workflow from this tag with `gh attestation verify <file> --repo devicedaw/device`.
- name: Attest build provenance
uses: actions/attest-build-provenance@4d101475d8b20a2381f78447822ac1eab6504dd8 # v4.2.2
with:
subject-path: dist/*
- name: Create the draft release
env:
GH_TOKEN: ${{ github.token }}
VERSION: ${{ needs.version.outputs.version }}
run: |
# The changelog section first; --generate-notes appends GitHub's list of pull requests.
bash tools/release/changelog-notes.sh "$VERSION" > "$RUNNER_TEMP/notes.md"
prerelease=()
case "$VERSION" in *-*) prerelease=(--prerelease) ;; esac
gh release create "$GITHUB_REF_NAME" dist/* \
--repo "$GITHUB_REPOSITORY" \
--draft \
"${prerelease[@]}" \
--title "Device $VERSION" \
--notes-file "$RUNNER_TEMP/notes.md" \
--generate-notes \
--verify-tag