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 || '' }}
@@ -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.13.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,30 +95,38 @@ 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
107114 steps :
115+ - name : enable windows longpaths
116+ run : |
117+ git config --global core.longpaths true
108118 - uses : actions/checkout@v4
109119 with :
110120 submodules : recursive
111- - uses : swatinem/rust-cache@v2
112- with :
113- key : ${{ join(matrix.targets, '-') }}
114- - name : Install cargo-dist
115- 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 }}
116130 # Get the dist-manifest
117131 - name : Fetch local artifacts
118132 uses : actions/download-artifact@v4
@@ -126,8 +140,8 @@ jobs:
126140 - name : Build artifacts
127141 run : |
128142 # Actually do builds and make zips and whatnot
129- cargo dist build ${{ needs.plan.outputs.tag-flag }} --print=linkage --output-format=json ${{ matrix.dist_args }} > dist-manifest.json
130- 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"
131145 - id : cargo-dist
132146 name : Post-build
133147 # We force bash here just because github makes it really hard to get values up
@@ -137,7 +151,7 @@ jobs:
137151 run : |
138152 # Parse out what we just built and upload it to scratch storage
139153 echo "paths<<EOF" >> "$GITHUB_OUTPUT"
140- jq --raw-output ".upload_files[]" dist-manifest.json >> "$GITHUB_OUTPUT"
154+ dist print-upload-files-from-manifest --manifest dist-manifest.json >> "$GITHUB_OUTPUT"
141155 echo "EOF" >> "$GITHUB_OUTPUT"
142156
143157 cp dist-manifest.json "$BUILD_MANIFEST_NAME"
@@ -162,9 +176,12 @@ jobs:
162176 - uses : actions/checkout@v4
163177 with :
164178 submodules : recursive
165- - name : Install cargo-dist
166- shell : bash
167- run : " curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.13.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
168185 # Get all the local artifacts for the global tasks to use (for e.g. checksums)
169186 - name : Fetch local artifacts
170187 uses : actions/download-artifact@v4
@@ -175,8 +192,8 @@ jobs:
175192 - id : cargo-dist
176193 shell : bash
177194 run : |
178- cargo dist build ${{ needs.plan.outputs.tag-flag }} --output-format=json "--artifacts=global" > dist-manifest.json
179- 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"
180197
181198 # Parse out what we just built and upload it to scratch storage
182199 echo "paths<<EOF" >> "$GITHUB_OUTPUT"
@@ -208,20 +225,23 @@ jobs:
208225 - uses : actions/checkout@v4
209226 with :
210227 submodules : recursive
211- - name : Install cargo-dist
212- run : " curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.13.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
213234 # Fetch artifacts from scratch-storage
214235 - name : Fetch artifacts
215236 uses : actions/download-artifact@v4
216237 with :
217238 pattern : artifacts-*
218239 path : target/distrib/
219240 merge-multiple : true
220- # This is a harmless no-op for GitHub Releases, hosting for that happens in "announce"
221241 - id : host
222242 shell : bash
223243 run : |
224- 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
225245 echo "artifacts uploaded and released successfully"
226246 cat dist-manifest.json
227247 echo "manifest=$(jq -c "." dist-manifest.json)" >> "$GITHUB_OUTPUT"
@@ -231,8 +251,29 @@ jobs:
231251 # Overwrite the previous copy
232252 name : artifacts-dist-manifest
233253 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/*
234276
235- # Create a GitHub Release while uploading all files to it
236277 announce :
237278 needs :
238279 - plan
@@ -248,21 +289,3 @@ jobs:
248289 - uses : actions/checkout@v4
249290 with :
250291 submodules : recursive
251- - name : " Download GitHub Artifacts"
252- uses : actions/download-artifact@v4
253- with :
254- pattern : artifacts-*
255- path : artifacts
256- merge-multiple : true
257- - name : Cleanup
258- run : |
259- # Remove the granular manifests
260- rm -f artifacts/*-dist-manifest.json
261- - name : Create GitHub Release
262- uses : ncipollo/release-action@v1
263- with :
264- tag : ${{ needs.plan.outputs.tag }}
265- name : ${{ fromJson(needs.host.outputs.val).announcement_title }}
266- body : ${{ fromJson(needs.host.outputs.val).announcement_github_body }}
267- prerelease : ${{ fromJson(needs.host.outputs.val).announcement_is_prerelease }}
268- artifacts : " artifacts/*"
0 commit comments