Repository navigation
325 lines (314 loc) · 13.2 KB
/
Copy pathrelease.yml
File metadata and controls
325 lines (314 loc) · 13.2 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
# A release (docs/PLAN.md §13.4): pushing an annotated tag `v<version>` on a commit on main
# builds the Windows and macOS releases (Setup.exe, the .pkg, and the Velopack update feed the
# installed app reads) and the Linux AppImage on GitHub's runners, runs every CI gate on that commit, and then waits for
# the owner to approve the `release` environment before anything is published to GitHub
# Releases.
#
# Security, beyond ci.yml's:
# - only the owner can create `v*` tags, and no tag can be moved or deleted (a repository
# ruleset); the `release` environment admits only `v*` tags and needs the owner's approval
# - script/release-check refuses a tag that isn't an annotated `v<semver>` on main whose version
# is the workspace's; like the approval, it guards against a mistaken tag, not a hostile one
# (a tag runs its own commit's copy of this file), which the tag ruleset keeps out
# - the builds start clean (no cache), with Cargo.lock as it is (`--locked`), in jobs whose token
# is read-only
# - the one job that can write (publish) checks out no code and runs nothing from the repository:
# it takes the built files, writes their SHA256SUMS, attests their build provenance (Sigstore,
# `gh attestation verify`) and creates the release; releases are immutable once published
name: Release
on:
push:
tags: ["v*"]
permissions: {}
concurrency:
group: release
cancel-in-progress: false
env:
CARGO_TERM_COLOR: always
CARGO_INCREMENTAL: "0"
jobs:
verify:
name: The tag
runs-on: ubuntu-24.04
timeout-minutes: 10
permissions:
contents: read
outputs:
version: ${{ steps.check.outputs.version }}
prerelease: ${{ steps.check.outputs.prerelease }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
persist-credentials: false
- name: The tag as it is on GitHub (checkout can leave a lightweight copy)
env:
TAG: ${{ github.ref_name }}
run: git fetch --force origin "refs/tags/$TAG:refs/tags/$TAG"
- name: script/release-check
id: check
env:
TAG: ${{ github.ref_name }}
run: |
set -euo pipefail
mkdir -p "$RUNNER_TEMP/notes"
bash script/release-check "$TAG" --notes "$RUNNER_TEMP/notes/notes.md" | tee -a "$GITHUB_OUTPUT"
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: notes
path: ${{ runner.temp }}/notes/notes.md
if-no-files-found: error
retention-days: 7
ci:
name: CI
needs: verify
# A job-level call resolves from this same commit before anything runs, so the runtime
# checkout the self-repository form (`$/`) guards against can't reach it; actionlint doesn't
# read `$/` yet.
uses: ./.github/workflows/ci.yml # zizmor: ignore[self-repository]
permissions:
contents: read
linux:
name: Linux builds
needs: verify
runs-on: ubuntu-24.04
timeout-minutes: 120
permissions:
contents: read
env:
VERSION: ${{ needs.verify.outputs.version }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: The app's system libraries
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends \
libxkbcommon-x11-dev libfontconfig-dev libwayland-dev libx11-xcb-dev squashfs-tools
- name: rustup (act's runner image has none; GitHub's has)
if: ${{ env.ACT == 'true' }}
run: |
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs |
sh -s -- -y --profile minimal --default-toolchain none
echo "$HOME/.cargo/bin" >> "$GITHUB_PATH"
- name: Rust toolchain (rust-toolchain.toml)
run: rustup toolchain install && rustc --version
- uses: actions/setup-dotnet@a98b56852c35b8e3190ac28c8c2271da59106c68 # v6.0.0
with:
dotnet-version: 8.0.x
- name: vpk 1.2.161 (the velopack crate's version)
run: dotnet tool install -g vpk --version 1.2.161
- name: The static Linux dv WSL distros run (script/build-linux)
env:
DV_CHANNEL: release
DV_VERSION: ${{ env.VERSION }}
run: bash script/build-linux --profile dist --out target/package/linux
- name: The Linux app's AppImage (script/package --linux-app)
run: |
set -euo pipefail
bash script/package --linux-app --version "$VERSION" --out target/package/linux-release
mkdir -p target/package/upload
cp target/package/linux-release/dv.AppImage target/package/upload/dv-linux-x86_64.AppImage
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: linux-builds
path: target/package/linux/dv-linux-x86_64
if-no-files-found: error
retention-days: 7
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: release-linux
path: target/package/upload/
if-no-files-found: error
retention-days: 7
windows:
name: Windows release
needs: [verify, linux]
runs-on: windows-2025
timeout-minutes: 120
permissions:
contents: read
env:
VERSION: ${{ needs.verify.outputs.version }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Rust toolchain (rust-toolchain.toml)
shell: bash
run: rustup toolchain install && rustc --version
- uses: actions/setup-dotnet@a98b56852c35b8e3190ac28c8c2271da59106c68 # v6.0.0
with:
dotnet-version: 8.0.x
- name: vpk 1.2.161 (the velopack crate's version)
run: dotnet tool install -g vpk --version 1.2.161
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: linux-builds
path: target/package/linux
- name: The latest release's full package, for the delta and the version check
shell: bash
env:
GH_TOKEN: ${{ github.token }}
run: |
set -euo pipefail
mkdir -p target/package/out
vpk download github --repoUrl "https://github.com/$GITHUB_REPOSITORY" --channel win \
--outputDir target/package/out --token "$GH_TOKEN"
# vpk says nothing went wrong when it finds no release, or when a download fails its
# checksum; make sure the package is there whenever a release is.
latest="$(gh release list --repo "$GITHUB_REPOSITORY" --exclude-drafts \
--exclude-pre-releases --limit 1 --json tagName --jq '.[0].tagName // ""')"
if [[ -n "$latest" ]] && ! compgen -G 'target/package/out/dv-*-full.nupkg' > /dev/null; then
echo "vpk didn't download the full package of the latest release, $latest" >&2
exit 1
fi
ls -l target/package/out
- name: script/package
shell: bash
run: |
set -euo pipefail
bash script/package --version "$VERSION" --feed "https://github.com/$GITHUB_REPOSITORY" \
--linux-dir target/package/linux --out target/package/out
- name: This release's files (vpk's assets.win.json, the feed and RELEASES)
shell: bash
run: |
set -euo pipefail
out=target/package/out
upload=target/package/upload
mkdir -p "$upload"
jq -r '.[].RelativeFileName' "$out/assets.win.json" | tr -d '\r' | while read -r name; do
cp "$out/$name" "$upload/"
done
cp "$out/releases.win.json" "$out/assets.win.json" "$out/RELEASES" "$upload/"
ls -l "$upload"
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: release-windows
path: target/package/upload/
if-no-files-found: error
retention-days: 7
macos:
name: macOS release
needs: verify
runs-on: macos-15
timeout-minutes: 120
permissions:
contents: read
env:
VERSION: ${{ needs.verify.outputs.version }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Rust toolchain (rust-toolchain.toml)
run: rustup toolchain install && rustc --version
- uses: actions/setup-dotnet@a98b56852c35b8e3190ac28c8c2271da59106c68 # v6.0.0
with:
dotnet-version: 8.0.x
- name: vpk 1.2.161 (the velopack crate's version)
run: dotnet tool install -g vpk --version 1.2.161
- name: The latest release's full macOS package, for the delta and the version check
env:
GH_TOKEN: ${{ github.token }}
run: |
set -euo pipefail
mkdir -p target/package/out
"$HOME/.dotnet/tools/vpk" download github --repoUrl "https://github.com/$GITHUB_REPOSITORY" \
--channel osx --outputDir target/package/out --token "$GH_TOKEN"
# As on Windows: vpk says nothing when it finds no release or a download fails, so
# make sure the package is there whenever the latest release has a macOS feed.
latest="$(gh release list --repo "$GITHUB_REPOSITORY" --exclude-drafts \
--exclude-pre-releases --limit 1 --json tagName --jq '.[0].tagName // ""')"
if [[ -n "$latest" ]] && gh release view "$latest" --repo "$GITHUB_REPOSITORY" \
--json assets --jq '.assets[].name' | grep -qx releases.osx.json &&
! compgen -G 'target/package/out/dv-*-osx-full.nupkg' > /dev/null; then
echo "vpk didn't download the full macOS package of the latest release, $latest" >&2
exit 1
fi
ls -l target/package/out
- name: script/package (on macOS, the macOS release)
run: |
set -euo pipefail
bash script/package --version "$VERSION" --feed "https://github.com/$GITHUB_REPOSITORY" \
--out target/package/out
- name: This release's files (vpk's assets.osx.json and the feed)
run: |
set -euo pipefail
out=target/package/out
upload=target/package/upload
mkdir -p "$upload"
jq -r '.[].RelativeFileName' "$out/assets.osx.json" | while read -r name; do
cp "$out/$name" "$upload/"
done
cp "$out/releases.osx.json" "$out/assets.osx.json" "$upload/"
ls -l "$upload"
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: release-macos
path: target/package/upload/
if-no-files-found: error
retention-days: 7
publish:
name: Publish (after the owner approves)
needs: [verify, ci, linux, windows, macos]
runs-on: ubuntu-24.04
timeout-minutes: 30
environment:
name: release
url: ${{ github.server_url }}/${{ github.repository }}/releases/tag/${{ github.ref_name }}
permissions:
contents: write # creates the release and uploads its files
id-token: write # the OIDC token Sigstore signs the provenance with
attestations: write # stores the provenance attestations
env:
VERSION: ${{ needs.verify.outputs.version }}
PRERELEASE: ${{ needs.verify.outputs.prerelease }}
steps:
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: release-windows
path: dist
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: release-linux
path: dist
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: release-macos
path: dist
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: notes
path: notes
- name: SHA256SUMS
run: |
set -euo pipefail
cd dist
sha256sum -- * > "$RUNNER_TEMP/SHA256SUMS"
mv "$RUNNER_TEMP/SHA256SUMS" SHA256SUMS
cat SHA256SUMS
- name: Build provenance
uses: actions/attest-build-provenance@4d101475d8b20a2381f78447822ac1eab6504dd8 # v4.2.2
with:
subject-path: dist/*
- name: The release, a draft until every file is on it
env:
GH_TOKEN: ${{ github.token }}
TAG: ${{ github.ref_name }}
run: |
set -euo pipefail
kind=(--latest)
if [[ "$PRERELEASE" == true ]]; then
kind=(--prerelease --latest=false)
fi
# A re-run after a failure part way finds its own draft and finishes it.
if gh release view "$TAG" --repo "$GITHUB_REPOSITORY" --json isDraft --jq .isDraft \
2> /dev/null | grep -qx true; then
gh release upload "$TAG" --repo "$GITHUB_REPOSITORY" --clobber dist/*
else
gh release create "$TAG" --repo "$GITHUB_REPOSITORY" --verify-tag --draft \
--title "dv $VERSION" --notes-file notes/notes.md "${kind[@]}" dist/*
fi
gh release edit "$TAG" --repo "$GITHUB_REPOSITORY" --draft=false "${kind[@]}"