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-latest"
5051 outputs :
5152 val : ${{ steps.plan.outputs.manifest }}
5253 tag : ${{ !github.event.pull_request && github.ref_name || '' }}
@@ -58,20 +59,25 @@ jobs:
5859 - uses : actions/checkout@v4
5960 with :
6061 submodules : recursive
61- - name : Install cargo- dist
62+ - name : Install dist
6263 # we specify bash to get pipefail; it guards against the `curl` command
6364 # failing. otherwise `sh` won't catch that `curl` returned non-0
6465 shell : bash
65- run : " curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.14.1/cargo-dist-installer.sh | sh"
66+ run : " curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.28.0/cargo-dist-installer.sh | sh"
67+ - name : Cache dist
68+ uses : actions/upload-artifact@v4
69+ with :
70+ name : cargo-dist-cache
71+ path : ~/.cargo/bin/dist
6672 # sure would be cool if github gave us proper conditionals...
6773 # so here's a doubly-nested ternary-via-truthiness to try to provide the best possible
6874 # functionality based on whether this is a pull_request, and whether it's from a fork.
6975 # (PRs run on the *source* but secrets are usually on the *target* -- that's *good*
7076 # but also really annoying to build CI around when it needs secrets to work right.)
7177 - id : plan
7278 run : |
73- cargo dist ${{ (!github.event.pull_request && format('host --steps=create --tag={0}', github.ref_name)) || 'plan' }} --output-format=json > plan-dist-manifest.json
74- echo "cargo dist ran successfully"
79+ dist ${{ (!github.event.pull_request && format('host --steps=create --tag={0}', github.ref_name)) || 'plan' }} --output-format=json > plan-dist-manifest.json
80+ echo "dist ran successfully"
7581 cat plan-dist-manifest.json
7682 echo "manifest=$(jq -c "." plan-dist-manifest.json)" >> "$GITHUB_OUTPUT"
7783 - name : " Upload dist-manifest.json"
@@ -89,18 +95,19 @@ jobs:
8995 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') }}
9096 strategy :
9197 fail-fast : false
92- # Target platforms/runners are computed by cargo- dist in create-release.
98+ # Target platforms/runners are computed by dist in create-release.
9399 # Each member of the matrix has the following arguments:
94100 #
95101 # - runner: the github runner
96- # - dist-args: cli flags to pass to cargo dist
97- # - install-dist: expression to run to install cargo- dist on the runner
102+ # - dist-args: cli flags to pass to dist
103+ # - install-dist: expression to run to install dist on the runner
98104 #
99105 # Typically there will be:
100106 # - 1 "global" task that builds universal installers
101107 # - N "local" tasks that build each platform's binaries and platform-specific installers
102108 matrix : ${{ fromJson(needs.plan.outputs.val).ci.github.artifacts_matrix }}
103109 runs-on : ${{ matrix.runner }}
110+ container : ${{ matrix.container && matrix.container.image || null }}
104111 env :
105112 GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
106113 BUILD_MANIFEST_NAME : target/distrib/${{ join(matrix.targets, '-') }}-dist-manifest.json
@@ -111,11 +118,15 @@ jobs:
111118 - uses : actions/checkout@v4
112119 with :
113120 submodules : recursive
114- - uses : swatinem/rust-cache@v2
115- with :
116- key : ${{ join(matrix.targets, '-') }}
117- - name : Install cargo-dist
118- run : ${{ matrix.install_dist }}
121+ - name : Install Rust non-interactively if not already installed
122+ if : ${{ matrix.container }}
123+ run : |
124+ if ! command -v cargo > /dev/null 2>&1; then
125+ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
126+ echo "$HOME/.cargo/bin" >> $GITHUB_PATH
127+ fi
128+ - name : Install dist
129+ run : ${{ matrix.install_dist.run }}
119130 # Get the dist-manifest
120131 - name : Fetch local artifacts
121132 uses : actions/download-artifact@v4
@@ -129,8 +140,8 @@ jobs:
129140 - name : Build artifacts
130141 run : |
131142 # Actually do builds and make zips and whatnot
132- cargo dist build ${{ needs.plan.outputs.tag-flag }} --print=linkage --output-format=json ${{ matrix.dist_args }} > dist-manifest.json
133- echo "cargo dist ran successfully"
143+ dist build ${{ needs.plan.outputs.tag-flag }} --print=linkage --output-format=json ${{ matrix.dist_args }} > dist-manifest.json
144+ echo "dist ran successfully"
134145 - id : cargo-dist
135146 name : Post-build
136147 # We force bash here just because github makes it really hard to get values up
@@ -140,7 +151,7 @@ jobs:
140151 run : |
141152 # Parse out what we just built and upload it to scratch storage
142153 echo "paths<<EOF" >> "$GITHUB_OUTPUT"
143- jq --raw-output ".upload_files[]" dist-manifest.json >> "$GITHUB_OUTPUT"
154+ dist print-upload-files-from-manifest --manifest dist-manifest.json >> "$GITHUB_OUTPUT"
144155 echo "EOF" >> "$GITHUB_OUTPUT"
145156
146157 cp dist-manifest.json "$BUILD_MANIFEST_NAME"
@@ -157,17 +168,20 @@ jobs:
157168 needs :
158169 - plan
159170 - build-local-artifacts
160- runs-on : " ubuntu-20.04 "
171+ runs-on : " ubuntu-latest "
161172 env :
162173 GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
163174 BUILD_MANIFEST_NAME : target/distrib/global-dist-manifest.json
164175 steps :
165176 - uses : actions/checkout@v4
166177 with :
167178 submodules : recursive
168- - name : Install cargo-dist
169- shell : bash
170- run : " curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.14.1/cargo-dist-installer.sh | sh"
179+ - name : Install cached dist
180+ uses : actions/download-artifact@v4
181+ with :
182+ name : cargo-dist-cache
183+ path : ~/.cargo/bin/
184+ - run : chmod +x ~/.cargo/bin/dist
171185 # Get all the local artifacts for the global tasks to use (for e.g. checksums)
172186 - name : Fetch local artifacts
173187 uses : actions/download-artifact@v4
@@ -178,8 +192,8 @@ jobs:
178192 - id : cargo-dist
179193 shell : bash
180194 run : |
181- cargo dist build ${{ needs.plan.outputs.tag-flag }} --output-format=json "--artifacts=global" > dist-manifest.json
182- echo "cargo dist ran successfully"
195+ dist build ${{ needs.plan.outputs.tag-flag }} --output-format=json "--artifacts=global" > dist-manifest.json
196+ echo "dist ran successfully"
183197
184198 # Parse out what we just built and upload it to scratch storage
185199 echo "paths<<EOF" >> "$GITHUB_OUTPUT"
@@ -204,27 +218,30 @@ jobs:
204218 if : ${{ always() && needs.plan.outputs.publishing == 'true' && (needs.build-global-artifacts.result == 'skipped' || needs.build-global-artifacts.result == 'success') && (needs.build-local-artifacts.result == 'skipped' || needs.build-local-artifacts.result == 'success') }}
205219 env :
206220 GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
207- runs-on : " ubuntu-20.04 "
221+ runs-on : " ubuntu-latest "
208222 outputs :
209223 val : ${{ steps.host.outputs.manifest }}
210224 steps :
211225 - uses : actions/checkout@v4
212226 with :
213227 submodules : recursive
214- - name : Install cargo-dist
215- run : " curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.14.1/cargo-dist-installer.sh | sh"
228+ - name : Install cached dist
229+ uses : actions/download-artifact@v4
230+ with :
231+ name : cargo-dist-cache
232+ path : ~/.cargo/bin/
233+ - run : chmod +x ~/.cargo/bin/dist
216234 # Fetch artifacts from scratch-storage
217235 - name : Fetch artifacts
218236 uses : actions/download-artifact@v4
219237 with :
220238 pattern : artifacts-*
221239 path : target/distrib/
222240 merge-multiple : true
223- # This is a harmless no-op for GitHub Releases, hosting for that happens in "announce"
224241 - id : host
225242 shell : bash
226243 run : |
227- cargo dist host ${{ needs.plan.outputs.tag-flag }} --steps=upload --steps=release --output-format=json > dist-manifest.json
244+ dist host ${{ needs.plan.outputs.tag-flag }} --steps=upload --steps=release --output-format=json > dist-manifest.json
228245 echo "artifacts uploaded and released successfully"
229246 cat dist-manifest.json
230247 echo "manifest=$(jq -c "." dist-manifest.json)" >> "$GITHUB_OUTPUT"
@@ -234,8 +251,29 @@ jobs:
234251 # Overwrite the previous copy
235252 name : artifacts-dist-manifest
236253 path : dist-manifest.json
254+ # Create a GitHub Release while uploading all files to it
255+ - name : " Download GitHub Artifacts"
256+ uses : actions/download-artifact@v4
257+ with :
258+ pattern : artifacts-*
259+ path : artifacts
260+ merge-multiple : true
261+ - name : Cleanup
262+ run : |
263+ # Remove the granular manifests
264+ rm -f artifacts/*-dist-manifest.json
265+ - name : Create GitHub Release
266+ env :
267+ PRERELEASE_FLAG : " ${{ fromJson(steps.host.outputs.manifest).announcement_is_prerelease && '--prerelease' || '' }}"
268+ ANNOUNCEMENT_TITLE : " ${{ fromJson(steps.host.outputs.manifest).announcement_title }}"
269+ ANNOUNCEMENT_BODY : " ${{ fromJson(steps.host.outputs.manifest).announcement_github_body }}"
270+ RELEASE_COMMIT : " ${{ github.sha }}"
271+ run : |
272+ # Write and read notes from a file to avoid quoting breaking things
273+ echo "$ANNOUNCEMENT_BODY" > $RUNNER_TEMP/notes.txt
274+
275+ gh release create "${{ needs.plan.outputs.tag }}" --target "$RELEASE_COMMIT" $PRERELEASE_FLAG --title "$ANNOUNCEMENT_TITLE" --notes-file "$RUNNER_TEMP/notes.txt" artifacts/*
237276
238- # Create a GitHub Release while uploading all files to it
239277 announce :
240278 needs :
241279 - plan
@@ -244,28 +282,10 @@ jobs:
244282 # still allowing individual publish jobs to skip themselves (for prereleases).
245283 # "host" however must run to completion, no skipping allowed!
246284 if : ${{ always() && needs.host.result == 'success' }}
247- runs-on : " ubuntu-20.04 "
285+ runs-on : " ubuntu-latest "
248286 env :
249287 GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
250288 steps :
251289 - uses : actions/checkout@v4
252290 with :
253291 submodules : recursive
254- - name : " Download GitHub Artifacts"
255- uses : actions/download-artifact@v4
256- with :
257- pattern : artifacts-*
258- path : artifacts
259- merge-multiple : true
260- - name : Cleanup
261- run : |
262- # Remove the granular manifests
263- rm -f artifacts/*-dist-manifest.json
264- - name : Create GitHub Release
265- uses : ncipollo/release-action@v1
266- with :
267- tag : ${{ needs.plan.outputs.tag }}
268- name : ${{ fromJson(needs.host.outputs.val).announcement_title }}
269- body : ${{ fromJson(needs.host.outputs.val).announcement_github_body }}
270- prerelease : ${{ fromJson(needs.host.outputs.val).announcement_is_prerelease }}
271- artifacts : " artifacts/*"
0 commit comments