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 Axo Releases and makes an Announcement
1012# * on success, uploads the artifacts to a GitHub Release
1315# title/body based on your changelogs.
1416
1517name : Release
16-
1718permissions :
18- contents : write
19- id-token : write
20- attestations : write
19+ " attestations " : " write"
20+ " contents " : " write"
21+ " id-token " : " write"
2122
2223# This task will run whenever you push a git tag that looks like a version
2324# like "1.0.0", "v0.1.0-prerelease.1", "my-app/0.1.0", "releases/v1.0.0", etc.
@@ -26,10 +27,10 @@ permissions:
2627# must be a Cargo-style SemVer Version (must have at least major.minor.patch).
2728#
2829# If PACKAGE_NAME is specified, then the announcement will be for that
29- # package (erroring out if it doesn't have the given version or isn't cargo- dist-able).
30+ # package (erroring out if it doesn't have the given version or isn't dist-able).
3031#
3132# If PACKAGE_NAME isn't specified, then the announcement will be for all
32- # (cargo- dist-able) packages in the workspace with that version (this mode is
33+ # (dist-able) packages in the workspace with that version (this mode is
3334# intended for workspaces with only one dist-able package, or with all dist-able
3435# packages versioned/released in lockstep).
3536#
4748 - ' **[0-9]+.[0-9]+.[0-9]+*'
4849
4950jobs :
50- # Run 'cargo dist plan' (or host) to determine what tasks we need to do
51+ # Run 'dist plan' (or host) to determine what tasks we need to do
5152 plan :
5253 runs-on : " ubuntu-20.04"
5354 outputs :
@@ -62,20 +63,25 @@ jobs:
6263 - uses : actions/checkout@v4
6364 with :
6465 submodules : recursive
65- - name : Install cargo- dist
66+ - name : Install dist
6667 # we specify bash to get pipefail; it guards against the `curl` command
6768 # failing. otherwise `sh` won't catch that `curl` returned non-0
6869 shell : bash
69- run : " curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.16.0-prerelease.6/cargo-dist-installer.sh | sh"
70+ run : " curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.26.0-prerelease.3/cargo-dist-installer.sh | sh"
71+ - name : Cache dist
72+ uses : actions/upload-artifact@v4
73+ with :
74+ name : cargo-dist-cache
75+ path : ~/.cargo/bin/dist
7076 # sure would be cool if github gave us proper conditionals...
7177 # so here's a doubly-nested ternary-via-truthiness to try to provide the best possible
7278 # functionality based on whether this is a pull_request, and whether it's from a fork.
7379 # (PRs run on the *source* but secrets are usually on the *target* -- that's *good*
7480 # but also really annoying to build CI around when it needs secrets to work right.)
7581 - id : plan
7682 run : |
77- cargo dist ${{ (!github.event.pull_request && format('host --steps=create --tag={0}', github.ref_name)) || (env.AXO_RELEASES_TOKEN && 'host --steps=check') || 'plan' }} --output-format=json > plan-dist-manifest.json
78- echo "cargo dist ran successfully"
83+ dist ${{ (!github.event.pull_request && format('host --steps=create --tag={0}', github.ref_name)) || (env.AXO_RELEASES_TOKEN && 'host --steps=check') || 'plan' }} --output-format=json > plan-dist-manifest.json
84+ echo "dist ran successfully"
7985 cat plan-dist-manifest.json
8086 echo "manifest=$(jq -c "." plan-dist-manifest.json)" >> "$GITHUB_OUTPUT"
8187 - name : " Upload dist-manifest.json"
@@ -93,18 +99,19 @@ jobs:
9399 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') }}
94100 strategy :
95101 fail-fast : false
96- # Target platforms/runners are computed by cargo- dist in create-release.
102+ # Target platforms/runners are computed by dist in create-release.
97103 # Each member of the matrix has the following arguments:
98104 #
99105 # - runner: the github runner
100- # - dist-args: cli flags to pass to cargo dist
101- # - install-dist: expression to run to install cargo- dist on the runner
106+ # - dist-args: cli flags to pass to dist
107+ # - install-dist: expression to run to install dist on the runner
102108 #
103109 # Typically there will be:
104110 # - 1 "global" task that builds universal installers
105111 # - N "local" tasks that build each platform's binaries and platform-specific installers
106112 matrix : ${{ fromJson(needs.plan.outputs.val).ci.github.artifacts_matrix }}
107113 runs-on : ${{ matrix.runner }}
114+ container : ${{ matrix.container && matrix.container.image || null }}
108115 env :
109116 GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
110117 BUILD_MANIFEST_NAME : target/distrib/${{ join(matrix.targets, '-') }}-dist-manifest.json
@@ -115,12 +122,15 @@ jobs:
115122 - uses : actions/checkout@v4
116123 with :
117124 submodules : recursive
118- - uses : swatinem/rust-cache@v2
119- with :
120- key : ${{ join(matrix.targets, '-') }}
121- cache-provider : ${{ matrix.cache_provider }}
122- - name : Install cargo-dist
123- run : ${{ matrix.install_dist }}
125+ - name : Install Rust non-interactively if not already installed
126+ if : ${{ matrix.container }}
127+ run : |
128+ if ! command -v cargo > /dev/null 2>&1; then
129+ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
130+ echo "$HOME/.cargo/bin" >> $GITHUB_PATH
131+ fi
132+ - name : Install dist
133+ run : ${{ matrix.install_dist.run }}
124134 # Get the dist-manifest
125135 - name : Fetch local artifacts
126136 uses : actions/download-artifact@v4
@@ -134,8 +144,8 @@ jobs:
134144 - name : Build artifacts
135145 run : |
136146 # Actually do builds and make zips and whatnot
137- cargo dist build ${{ needs.plan.outputs.tag-flag }} --print=linkage --output-format=json ${{ matrix.dist_args }} > dist-manifest.json
138- 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"
139149 - name : Attest
140150 uses : actions/attest-build-provenance@v1
141151 with :
@@ -149,7 +159,7 @@ jobs:
149159 run : |
150160 # Parse out what we just built and upload it to scratch storage
151161 echo "paths<<EOF" >> "$GITHUB_OUTPUT"
152- jq --raw-output ".upload_files[]" dist-manifest.json >> "$GITHUB_OUTPUT"
162+ dist print-upload-files-from-manifest --manifest dist-manifest.json >> "$GITHUB_OUTPUT"
153163 echo "EOF" >> "$GITHUB_OUTPUT"
154164
155165 cp dist-manifest.json "$BUILD_MANIFEST_NAME"
@@ -174,9 +184,12 @@ jobs:
174184 - uses : actions/checkout@v4
175185 with :
176186 submodules : recursive
177- - name : Install cargo-dist
178- shell : bash
179- run : " curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.16.0-prerelease.6/cargo-dist-installer.sh | sh"
187+ - name : Install cached dist
188+ uses : actions/download-artifact@v4
189+ with :
190+ name : cargo-dist-cache
191+ path : ~/.cargo/bin/
192+ - run : chmod +x ~/.cargo/bin/dist
180193 # Get all the local artifacts for the global tasks to use (for e.g. checksums)
181194 - name : Fetch local artifacts
182195 uses : actions/download-artifact@v4
@@ -187,8 +200,8 @@ jobs:
187200 - id : cargo-dist
188201 shell : bash
189202 run : |
190- cargo dist build ${{ needs.plan.outputs.tag-flag }} --output-format=json "--artifacts=global" > dist-manifest.json
191- echo "cargo dist ran successfully"
203+ dist build ${{ needs.plan.outputs.tag-flag }} --output-format=json "--artifacts=global" > dist-manifest.json
204+ echo "dist ran successfully"
192205
193206 # Parse out what we just built and upload it to scratch storage
194207 echo "paths<<EOF" >> "$GITHUB_OUTPUT"
@@ -230,8 +243,12 @@ jobs:
230243 - uses : actions/checkout@v4
231244 with :
232245 submodules : recursive
233- - name : Install cargo-dist
234- run : " curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.16.0-prerelease.6/cargo-dist-installer.sh | sh"
246+ - name : Install cached dist
247+ uses : actions/download-artifact@v4
248+ with :
249+ name : cargo-dist-cache
250+ path : ~/.cargo/bin/
251+ - run : chmod +x ~/.cargo/bin/dist
235252 # Fetch artifacts from scratch-storage
236253 - name : Fetch artifacts
237254 uses : actions/download-artifact@v4
@@ -244,7 +261,7 @@ jobs:
244261 - id : host
245262 shell : bash
246263 run : |
247- cargo dist host ${{ needs.plan.outputs.tag-flag }} --steps=upload --steps=release --output-format=json > dist-manifest.json
264+ dist host ${{ needs.plan.outputs.tag-flag }} --steps=upload --steps=release --output-format=json > dist-manifest.json
248265 echo "artifacts uploaded and released successfully"
249266 cat dist-manifest.json
250267 echo "manifest=$(jq -c "." dist-manifest.json)" >> "$GITHUB_OUTPUT"
@@ -290,6 +307,11 @@ jobs:
290307 name=$(echo "$filename" | sed "s/\.rb$//")
291308 version=$(echo "$release" | jq .app_version --raw-output)
292309
310+ export PATH="/home/linuxbrew/.linuxbrew/bin:$PATH"
311+ brew update
312+ # We avoid reformatting user-provided data such as the app description and homepage.
313+ brew style --except-cops FormulaAudit/Homepage,FormulaAudit/Desc,FormulaAuditStrict --fix "Formula/${filename}" || true
314+
293315 git add "Formula/${filename}"
294316 git commit -m "${name} ${version}"
295317 done
@@ -334,8 +356,8 @@ jobs:
334356 secrets : inherit
335357 # publish jobs get escalated permissions
336358 permissions :
337- id-token : write
338- packages : write
359+ " id-token " : " write"
360+ " packages " : " write"
339361
340362 # Create an Announcement for all the Axo Releases, updating the "latest" release
341363 # Create a GitHub Release while uploading all files to it
@@ -358,8 +380,12 @@ jobs:
358380 - uses : actions/checkout@v4
359381 with :
360382 submodules : recursive
361- - name : Install cargo-dist
362- run : " curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.16.0-prerelease.6/cargo-dist-installer.sh | sh"
383+ - name : Install cached dist
384+ uses : actions/download-artifact@v4
385+ with :
386+ name : cargo-dist-cache
387+ path : ~/.cargo/bin/
388+ - run : chmod +x ~/.cargo/bin/dist
363389 - name : Fetch Axo Artifacts
364390 uses : actions/download-artifact@v4
365391 with :
@@ -368,7 +394,8 @@ jobs:
368394 merge-multiple : true
369395 - name : Announce Axo Releases
370396 run : |
371- cargo dist host --steps=announce ${{ needs.plan.outputs.tag-flag }}
397+ dist host --steps=announce ${{ needs.plan.outputs.tag-flag }}
398+ # Create a GitHub Release while uploading all files to it
372399 - name : " Download GitHub Artifacts"
373400 uses : actions/download-artifact@v4
374401 with :
@@ -384,9 +411,9 @@ jobs:
384411 PRERELEASE_FLAG : " ${{ fromJson(needs.host.outputs.val).announcement_is_prerelease && '--prerelease' || '' }}"
385412 ANNOUNCEMENT_TITLE : " ${{ fromJson(needs.host.outputs.val).announcement_title }}"
386413 ANNOUNCEMENT_BODY : " ${{ fromJson(needs.host.outputs.val).announcement_github_body }}"
414+ RELEASE_COMMIT : " ${{ github.sha }}"
387415 run : |
388416 # Write and read notes from a file to avoid quoting breaking things
389417 echo "$ANNOUNCEMENT_BODY" > $RUNNER_TEMP/notes.txt
390418
391- gh release create "${{ needs.plan.outputs.tag }}" --title "$ANNOUNCEMENT_TITLE" --notes-file "$RUNNER_TEMP/notes.txt" $PRERELEASE_FLAG
392- gh release upload "${{ needs.plan.outputs.tag }}" artifacts/*
419+ gh release create "${{ needs.plan.outputs.tag }}" --target "$RELEASE_COMMIT" $PRERELEASE_FLAG --title "$ANNOUNCEMENT_TITLE" --notes-file "$RUNNER_TEMP/notes.txt" artifacts/*
0 commit comments