1+ # This file was autogenerated by dist: https://opensource.axo.dev/cargo-dist/
2+ #
13# Copyright 2022-2024, axodotdev
24# SPDX-License-Identifier: MIT or Apache-2.0
35#
46# CI that:
57#
68# * checks for a Git Tag that looks like a release
7- # * builds artifacts with cargo- dist (archives, installers, hashes)
9+ # * builds artifacts with dist (archives, installers, hashes)
810# * uploads those artifacts to temporary workflow zip
911# * on success, uploads the artifacts to a GitHub Release
1012#
1113# Note that the GitHub Release will be created with a generated
1214# title/body based on your changelogs.
1315
1416name : Release
15-
1617permissions :
17- contents : write
18+ " contents " : " write"
1819
1920# This task will run whenever you push a git tag that looks like a version
2021# like "1.0.0", "v0.1.0-prerelease.1", "my-app/0.1.0", "releases/v1.0.0", etc.
@@ -23,10 +24,10 @@ permissions:
2324# must be a Cargo-style SemVer Version (must have at least major.minor.patch).
2425#
2526# If PACKAGE_NAME is specified, then the announcement will be for that
26- # package (erroring out if it doesn't have the given version or isn't cargo- dist-able).
27+ # package (erroring out if it doesn't have the given version or isn't dist-able).
2728#
2829# If PACKAGE_NAME isn't specified, then the announcement will be for all
29- # (cargo- dist-able) packages in the workspace with that version (this mode is
30+ # (dist-able) packages in the workspace with that version (this mode is
3031# intended for workspaces with only one dist-able package, or with all dist-able
3132# packages versioned/released in lockstep).
3233#
@@ -38,15 +39,15 @@ permissions:
3839# If there's a prerelease-style suffix to the version, then the release(s)
3940# will be marked as a prerelease.
4041on :
42+ pull_request :
4143 push :
4244 tags :
4345 - ' **[0-9]+.[0-9]+.[0-9]+*'
44- pull_request :
4546
4647jobs :
47- # Run 'cargo dist plan' (or host) to determine what tasks we need to do
48+ # Run 'dist plan' (or host) to determine what tasks we need to do
4849 plan :
49- runs-on : ubuntu-latest
50+ runs-on : " ubuntu-20.04 "
5051 outputs :
5152 val : ${{ steps.plan.outputs.manifest }}
5253 tag : ${{ !github.event.pull_request && github.ref_name || '' }}
@@ -60,20 +61,25 @@ jobs:
6061 submodules : recursive
6162 - name : Install Rust
6263 run : rustup update "1.82.0" --no-self-update && rustup default "1.82.0"
63- - name : Install cargo- dist
64+ - name : Install dist
6465 # we specify bash to get pipefail; it guards against the `curl` command
6566 # failing. otherwise `sh` won't catch that `curl` returned non-0
6667 shell : bash
67- run : " curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.14.1/cargo-dist-installer.sh | sh"
68+ run : " curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.28.0/cargo-dist-installer.sh | sh"
69+ - name : Cache dist
70+ uses : actions/upload-artifact@v4
71+ with :
72+ name : cargo-dist-cache
73+ path : ~/.cargo/bin/dist
6874 # sure would be cool if github gave us proper conditionals...
6975 # so here's a doubly-nested ternary-via-truthiness to try to provide the best possible
7076 # functionality based on whether this is a pull_request, and whether it's from a fork.
7177 # (PRs run on the *source* but secrets are usually on the *target* -- that's *good*
7278 # but also really annoying to build CI around when it needs secrets to work right.)
7379 - id : plan
7480 run : |
75- cargo dist ${{ (!github.event.pull_request && format('host --steps=create --tag={0}', github.ref_name)) || 'plan' }} --output-format=json > plan-dist-manifest.json
76- echo "cargo dist ran successfully"
81+ dist ${{ (!github.event.pull_request && format('host --steps=create --tag={0}', github.ref_name)) || 'plan' }} --output-format=json > plan-dist-manifest.json
82+ echo "dist ran successfully"
7783 cat plan-dist-manifest.json
7884 echo "manifest=$(jq -c "." plan-dist-manifest.json)" >> "$GITHUB_OUTPUT"
7985 - name : " Upload dist-manifest.json"
@@ -91,18 +97,19 @@ jobs:
9197 if : ${{ fromJson(needs.plan.outputs.val).ci.github.artifacts_matrix.include != null && (needs.plan.outputs.publishing == 'true' || fromJson(needs.plan.outputs.val).ci.github.pr_run_mode == 'upload') }}
9298 strategy :
9399 fail-fast : false
94- # Target platforms/runners are computed by cargo- dist in create-release.
100+ # Target platforms/runners are computed by dist in create-release.
95101 # Each member of the matrix has the following arguments:
96102 #
97103 # - runner: the github runner
98- # - dist-args: cli flags to pass to cargo dist
99- # - install-dist: expression to run to install cargo- dist on the runner
104+ # - dist-args: cli flags to pass to dist
105+ # - install-dist: expression to run to install dist on the runner
100106 #
101107 # Typically there will be:
102108 # - 1 "global" task that builds universal installers
103109 # - N "local" tasks that build each platform's binaries and platform-specific installers
104110 matrix : ${{ fromJson(needs.plan.outputs.val).ci.github.artifacts_matrix }}
105111 runs-on : ${{ matrix.runner }}
112+ container : ${{ matrix.container && matrix.container.image || null }}
106113 env :
107114 GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
108115 BUILD_MANIFEST_NAME : target/distrib/${{ join(matrix.targets, '-') }}-dist-manifest.json
@@ -113,13 +120,17 @@ jobs:
113120 - uses : actions/checkout@v4
114121 with :
115122 submodules : recursive
116- - name : Install Rust
123+ - name : Install Rust non-interactively if not already installed
124+ if : ${{ matrix.container }}
125+ run : |
126+ if ! command -v cargo > /dev/null 2>&1; then
127+ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
128+ echo "$HOME/.cargo/bin" >> $GITHUB_PATH
129+ fi
130+ - name : Use rustup to set correct Rust version
117131 run : rustup update "1.82.0" --no-self-update && rustup default "1.82.0"
118- - uses : swatinem/rust-cache@v2
119- with :
120- key : ${{ join(matrix.targets, '-') }}
121- - name : Install cargo-dist
122- run : ${{ matrix.install_dist }}
132+ - name : Install dist
133+ run : ${{ matrix.install_dist.run }}
123134 # Get the dist-manifest
124135 - name : Fetch local artifacts
125136 uses : actions/download-artifact@v4
@@ -133,8 +144,8 @@ jobs:
133144 - name : Build artifacts
134145 run : |
135146 # Actually do builds and make zips and whatnot
136- cargo dist build ${{ needs.plan.outputs.tag-flag }} --print=linkage --output-format=json ${{ matrix.dist_args }} > dist-manifest.json
137- echo "cargo dist ran successfully"
147+ dist build ${{ needs.plan.outputs.tag-flag }} --print=linkage --output-format=json ${{ matrix.dist_args }} > dist-manifest.json
148+ echo "dist ran successfully"
138149 - id : cargo-dist
139150 name : Post-build
140151 # We force bash here just because github makes it really hard to get values up
@@ -144,7 +155,7 @@ jobs:
144155 run : |
145156 # Parse out what we just built and upload it to scratch storage
146157 echo "paths<<EOF" >> "$GITHUB_OUTPUT"
147- jq --raw-output ".upload_files[]" dist-manifest.json >> "$GITHUB_OUTPUT"
158+ dist print-upload-files-from-manifest --manifest dist-manifest.json >> "$GITHUB_OUTPUT"
148159 echo "EOF" >> "$GITHUB_OUTPUT"
149160
150161 cp dist-manifest.json "$BUILD_MANIFEST_NAME"
@@ -171,9 +182,12 @@ jobs:
171182 submodules : recursive
172183 - name : Install Rust
173184 run : rustup update "1.82.0" --no-self-update && rustup default "1.82.0"
174- - name : Install cargo-dist
175- shell : bash
176- run : " curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.14.1/cargo-dist-installer.sh | sh"
185+ - name : Install cached dist
186+ uses : actions/download-artifact@v4
187+ with :
188+ name : cargo-dist-cache
189+ path : ~/.cargo/bin/
190+ - run : chmod +x ~/.cargo/bin/dist
177191 # Get all the local artifacts for the global tasks to use (for e.g. checksums)
178192 - name : Fetch local artifacts
179193 uses : actions/download-artifact@v4
@@ -184,8 +198,8 @@ jobs:
184198 - id : cargo-dist
185199 shell : bash
186200 run : |
187- cargo dist build ${{ needs.plan.outputs.tag-flag }} --output-format=json "--artifacts=global" > dist-manifest.json
188- echo "cargo dist ran successfully"
201+ dist build ${{ needs.plan.outputs.tag-flag }} --output-format=json "--artifacts=global" > dist-manifest.json
202+ echo "dist ran successfully"
189203
190204 # Parse out what we just built and upload it to scratch storage
191205 echo "paths<<EOF" >> "$GITHUB_OUTPUT"
@@ -219,20 +233,23 @@ jobs:
219233 submodules : recursive
220234 - name : Install Rust
221235 run : rustup update "1.82.0" --no-self-update && rustup default "1.82.0"
222- - name : Install cargo-dist
223- run : " curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.14.1/cargo-dist-installer.sh | sh"
236+ - name : Install cached dist
237+ uses : actions/download-artifact@v4
238+ with :
239+ name : cargo-dist-cache
240+ path : ~/.cargo/bin/
241+ - run : chmod +x ~/.cargo/bin/dist
224242 # Fetch artifacts from scratch-storage
225243 - name : Fetch artifacts
226244 uses : actions/download-artifact@v4
227245 with :
228246 pattern : artifacts-*
229247 path : target/distrib/
230248 merge-multiple : true
231- # This is a harmless no-op for GitHub Releases, hosting for that happens in "announce"
232249 - id : host
233250 shell : bash
234251 run : |
235- cargo dist host ${{ needs.plan.outputs.tag-flag }} --steps=upload --steps=release --output-format=json > dist-manifest.json
252+ dist host ${{ needs.plan.outputs.tag-flag }} --steps=upload --steps=release --output-format=json > dist-manifest.json
236253 echo "artifacts uploaded and released successfully"
237254 cat dist-manifest.json
238255 echo "manifest=$(jq -c "." dist-manifest.json)" >> "$GITHUB_OUTPUT"
@@ -242,6 +259,28 @@ jobs:
242259 # Overwrite the previous copy
243260 name : artifacts-dist-manifest
244261 path : dist-manifest.json
262+ # Create a GitHub Release while uploading all files to it
263+ - name : " Download GitHub Artifacts"
264+ uses : actions/download-artifact@v4
265+ with :
266+ pattern : artifacts-*
267+ path : artifacts
268+ merge-multiple : true
269+ - name : Cleanup
270+ run : |
271+ # Remove the granular manifests
272+ rm -f artifacts/*-dist-manifest.json
273+ - name : Create GitHub Release
274+ env :
275+ PRERELEASE_FLAG : " ${{ fromJson(steps.host.outputs.manifest).announcement_is_prerelease && '--prerelease' || '' }}"
276+ ANNOUNCEMENT_TITLE : " ${{ fromJson(steps.host.outputs.manifest).announcement_title }}"
277+ ANNOUNCEMENT_BODY : " ${{ fromJson(steps.host.outputs.manifest).announcement_github_body }}"
278+ RELEASE_COMMIT : " ${{ github.sha }}"
279+ run : |
280+ # Write and read notes from a file to avoid quoting breaking things
281+ echo "$ANNOUNCEMENT_BODY" > $RUNNER_TEMP/notes.txt
282+
283+ gh release create "${{ needs.plan.outputs.tag }}" --target "$RELEASE_COMMIT" $PRERELEASE_FLAG --title "$ANNOUNCEMENT_TITLE" --notes-file "$RUNNER_TEMP/notes.txt" artifacts/*
245284
246285 publish-homebrew-formula :
247286 needs :
@@ -278,12 +317,16 @@ jobs:
278317 name=$(echo "$filename" | sed "s/\.rb$//")
279318 version=$(echo "$release" | jq .app_version --raw-output)
280319
320+ export PATH="/home/linuxbrew/.linuxbrew/bin:$PATH"
321+ brew update
322+ # We avoid reformatting user-provided data such as the app description and homepage.
323+ brew style --except-cops FormulaAudit/Homepage,FormulaAudit/Desc,FormulaAuditStrict --fix "Formula/${filename}" || true
324+
281325 git add "Formula/${filename}"
282326 git commit -m "${name} ${version}"
283327 done
284328 git push
285329
286- # Create a GitHub Release while uploading all files to it
287330 announce :
288331 needs :
289332 - plan
@@ -300,21 +343,3 @@ jobs:
300343 - uses : actions/checkout@v4
301344 with :
302345 submodules : recursive
303- - name : " Download GitHub Artifacts"
304- uses : actions/download-artifact@v4
305- with :
306- pattern : artifacts-*
307- path : artifacts
308- merge-multiple : true
309- - name : Cleanup
310- run : |
311- # Remove the granular manifests
312- rm -f artifacts/*-dist-manifest.json
313- - name : Create GitHub Release
314- uses : ncipollo/release-action@v1
315- with :
316- tag : ${{ needs.plan.outputs.tag }}
317- name : ${{ fromJson(needs.host.outputs.val).announcement_title }}
318- body : ${{ fromJson(needs.host.outputs.val).announcement_github_body }}
319- prerelease : ${{ fromJson(needs.host.outputs.val).announcement_is_prerelease }}
320- artifacts : " artifacts/*"
0 commit comments