Skip to content

Commit 26ee87a

Browse files
chore: upgrade cargo-dist 0.8.2 → 0.31.0
Regenerated release workflow with latest cargo-dist. Updates deprecated GHA actions (upload/download-artifact v3→v6/v7) and runner images (ubuntu-20.04→ubuntu-22.04).
1 parent e2fb0d3 commit 26ee87a

2 files changed

Lines changed: 116 additions & 80 deletions

File tree

.github/workflows/release.yml

Lines changed: 115 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
1-
# Copyright 2022-2023, axodotdev
1+
# This file was autogenerated by dist: https://axodotdev.github.io/cargo-dist
2+
#
3+
# 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
9-
# * on success, uploads the artifacts to a Github Release
11+
# * on success, uploads the artifacts to a GitHub Release
1012
#
11-
# Note that the Github Release will be created with a generated
13+
# Note that the GitHub Release will be created with a generated
1214
# title/body based on your changelogs.
1315

1416
name: Release
15-
1617
permissions:
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,30 +24,30 @@ 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
#
3334
# If you push multiple tags at once, separate instances of this workflow will
34-
# spin up, creating an independent announcement for each one. However Github
35+
# spin up, creating an independent announcement for each one. However, GitHub
3536
# will hard limit this to 3 tags per commit, as it will assume more tags is a
3637
# mistake.
3738
#
3839
# If there's a prerelease-style suffix to the version, then the release(s)
3940
# will be marked as a prerelease.
4041
on:
42+
pull_request:
4143
push:
4244
tags:
4345
- '**[0-9]+.[0-9]+.[0-9]+*'
44-
pull_request:
4546

4647
jobs:
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-22.04"
5051
outputs:
5152
val: ${{ steps.plan.outputs.manifest }}
5253
tag: ${{ !github.event.pull_request && github.ref_name || '' }}
@@ -55,30 +56,36 @@ jobs:
5556
env:
5657
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5758
steps:
58-
- uses: actions/checkout@v4
59+
- uses: actions/checkout@v6
5960
with:
61+
persist-credentials: false
6062
submodules: recursive
61-
- name: Install cargo-dist
63+
- name: Install dist
6264
# we specify bash to get pipefail; it guards against the `curl` command
6365
# failing. otherwise `sh` won't catch that `curl` returned non-0
6466
shell: bash
65-
run: "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.8.2/cargo-dist-installer.sh | sh"
67+
run: "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.31.0/cargo-dist-installer.sh | sh"
68+
- name: Cache dist
69+
uses: actions/upload-artifact@v6
70+
with:
71+
name: cargo-dist-cache
72+
path: ~/.cargo/bin/dist
6673
# sure would be cool if github gave us proper conditionals...
6774
# so here's a doubly-nested ternary-via-truthiness to try to provide the best possible
6875
# functionality based on whether this is a pull_request, and whether it's from a fork.
6976
# (PRs run on the *source* but secrets are usually on the *target* -- that's *good*
7077
# but also really annoying to build CI around when it needs secrets to work right.)
7178
- id: plan
7279
run: |
73-
cargo dist ${{ (!github.event.pull_request && format('host --steps=create --tag={0}', github.ref_name)) || 'plan' }} --output-format=json > dist-manifest.json
74-
echo "cargo dist ran successfully"
75-
cat dist-manifest.json
76-
echo "manifest=$(jq -c "." dist-manifest.json)" >> "$GITHUB_OUTPUT"
80+
dist ${{ (!github.event.pull_request && format('host --steps=create --tag={0}', github.ref_name)) || 'plan' }} --output-format=json > plan-dist-manifest.json
81+
echo "dist ran successfully"
82+
cat plan-dist-manifest.json
83+
echo "manifest=$(jq -c "." plan-dist-manifest.json)" >> "$GITHUB_OUTPUT"
7784
- name: "Upload dist-manifest.json"
78-
uses: actions/upload-artifact@v3
85+
uses: actions/upload-artifact@v6
7986
with:
80-
name: artifacts
81-
path: dist-manifest.json
87+
name: artifacts-plan-dist-manifest
88+
path: plan-dist-manifest.json
8289

8390
# Build and packages all the platform-specific things
8491
build-local-artifacts:
@@ -89,42 +96,54 @@ jobs:
8996
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') }}
9097
strategy:
9198
fail-fast: false
92-
# Target platforms/runners are computed by cargo-dist in create-release.
99+
# Target platforms/runners are computed by dist in create-release.
93100
# Each member of the matrix has the following arguments:
94101
#
95102
# - 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
103+
# - dist-args: cli flags to pass to dist
104+
# - install-dist: expression to run to install dist on the runner
98105
#
99106
# Typically there will be:
100107
# - 1 "global" task that builds universal installers
101108
# - N "local" tasks that build each platform's binaries and platform-specific installers
102109
matrix: ${{ fromJson(needs.plan.outputs.val).ci.github.artifacts_matrix }}
103110
runs-on: ${{ matrix.runner }}
111+
container: ${{ matrix.container && matrix.container.image || null }}
104112
env:
105113
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
106114
BUILD_MANIFEST_NAME: target/distrib/${{ join(matrix.targets, '-') }}-dist-manifest.json
107115
steps:
108-
- uses: actions/checkout@v4
116+
- name: enable windows longpaths
117+
run: |
118+
git config --global core.longpaths true
119+
- uses: actions/checkout@v6
109120
with:
121+
persist-credentials: false
110122
submodules: recursive
111-
- uses: swatinem/rust-cache@v2
112-
- name: Install cargo-dist
113-
run: ${{ matrix.install_dist }}
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: Install dist
131+
run: ${{ matrix.install_dist.run }}
114132
# Get the dist-manifest
115133
- name: Fetch local artifacts
116-
uses: actions/download-artifact@v3
134+
uses: actions/download-artifact@v7
117135
with:
118-
name: artifacts
136+
pattern: artifacts-*
119137
path: target/distrib/
138+
merge-multiple: true
120139
- name: Install dependencies
121140
run: |
122141
${{ matrix.packages_install }}
123142
- name: Build artifacts
124143
run: |
125144
# Actually do builds and make zips and whatnot
126-
cargo dist build ${{ needs.plan.outputs.tag-flag }} --print=linkage --output-format=json ${{ matrix.dist_args }} > dist-manifest.json
127-
echo "cargo dist ran successfully"
145+
dist build ${{ needs.plan.outputs.tag-flag }} --print=linkage --output-format=json ${{ matrix.dist_args }} > dist-manifest.json
146+
echo "dist ran successfully"
128147
- id: cargo-dist
129148
name: Post-build
130149
# We force bash here just because github makes it really hard to get values up
@@ -134,14 +153,14 @@ jobs:
134153
run: |
135154
# Parse out what we just built and upload it to scratch storage
136155
echo "paths<<EOF" >> "$GITHUB_OUTPUT"
137-
jq --raw-output ".artifacts[]?.path | select( . != null )" dist-manifest.json >> "$GITHUB_OUTPUT"
156+
dist print-upload-files-from-manifest --manifest dist-manifest.json >> "$GITHUB_OUTPUT"
138157
echo "EOF" >> "$GITHUB_OUTPUT"
139158
140159
cp dist-manifest.json "$BUILD_MANIFEST_NAME"
141160
- name: "Upload artifacts"
142-
uses: actions/upload-artifact@v3
161+
uses: actions/upload-artifact@v6
143162
with:
144-
name: artifacts
163+
name: artifacts-build-local-${{ join(matrix.targets, '_') }}
145164
path: |
146165
${{ steps.cargo-dist.outputs.paths }}
147166
${{ env.BUILD_MANIFEST_NAME }}
@@ -151,38 +170,44 @@ jobs:
151170
needs:
152171
- plan
153172
- build-local-artifacts
154-
runs-on: "ubuntu-20.04"
173+
runs-on: "ubuntu-22.04"
155174
env:
156175
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
157176
BUILD_MANIFEST_NAME: target/distrib/global-dist-manifest.json
158177
steps:
159-
- uses: actions/checkout@v4
178+
- uses: actions/checkout@v6
160179
with:
180+
persist-credentials: false
161181
submodules: recursive
162-
- name: Install cargo-dist
163-
run: "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.8.2/cargo-dist-installer.sh | sh"
182+
- name: Install cached dist
183+
uses: actions/download-artifact@v7
184+
with:
185+
name: cargo-dist-cache
186+
path: ~/.cargo/bin/
187+
- run: chmod +x ~/.cargo/bin/dist
164188
# Get all the local artifacts for the global tasks to use (for e.g. checksums)
165189
- name: Fetch local artifacts
166-
uses: actions/download-artifact@v3
190+
uses: actions/download-artifact@v7
167191
with:
168-
name: artifacts
192+
pattern: artifacts-*
169193
path: target/distrib/
194+
merge-multiple: true
170195
- id: cargo-dist
171196
shell: bash
172197
run: |
173-
cargo dist build ${{ needs.plan.outputs.tag-flag }} --output-format=json "--artifacts=global" > dist-manifest.json
174-
echo "cargo dist ran successfully"
198+
dist build ${{ needs.plan.outputs.tag-flag }} --output-format=json "--artifacts=global" > dist-manifest.json
199+
echo "dist ran successfully"
175200
176201
# Parse out what we just built and upload it to scratch storage
177202
echo "paths<<EOF" >> "$GITHUB_OUTPUT"
178-
jq --raw-output ".artifacts[]?.path | select( . != null )" dist-manifest.json >> "$GITHUB_OUTPUT"
203+
jq --raw-output ".upload_files[]" dist-manifest.json >> "$GITHUB_OUTPUT"
179204
echo "EOF" >> "$GITHUB_OUTPUT"
180205
181206
cp dist-manifest.json "$BUILD_MANIFEST_NAME"
182207
- name: "Upload artifacts"
183-
uses: actions/upload-artifact@v3
208+
uses: actions/upload-artifact@v6
184209
with:
185-
name: artifacts
210+
name: artifacts-build-global
186211
path: |
187212
${{ steps.cargo-dist.outputs.paths }}
188213
${{ env.BUILD_MANIFEST_NAME }}
@@ -192,40 +217,67 @@ jobs:
192217
- plan
193218
- build-local-artifacts
194219
- build-global-artifacts
195-
# Only run if we're "publishing", and only if local and global didn't fail (skipped is fine)
196-
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') }}
220+
# Only run if we're "publishing", and only if plan, local and global didn't fail (skipped is fine)
221+
if: ${{ always() && needs.plan.result == 'success' && 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') }}
197222
env:
198223
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
199-
runs-on: "ubuntu-20.04"
224+
runs-on: "ubuntu-22.04"
200225
outputs:
201226
val: ${{ steps.host.outputs.manifest }}
202227
steps:
203-
- uses: actions/checkout@v4
228+
- uses: actions/checkout@v6
204229
with:
230+
persist-credentials: false
205231
submodules: recursive
206-
- name: Install cargo-dist
207-
run: "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.8.2/cargo-dist-installer.sh | sh"
232+
- name: Install cached dist
233+
uses: actions/download-artifact@v7
234+
with:
235+
name: cargo-dist-cache
236+
path: ~/.cargo/bin/
237+
- run: chmod +x ~/.cargo/bin/dist
208238
# Fetch artifacts from scratch-storage
209239
- name: Fetch artifacts
210-
uses: actions/download-artifact@v3
240+
uses: actions/download-artifact@v7
211241
with:
212-
name: artifacts
242+
pattern: artifacts-*
213243
path: target/distrib/
214-
# This is a harmless no-op for Github Releases, hosting for that happens in "announce"
244+
merge-multiple: true
215245
- id: host
216246
shell: bash
217247
run: |
218-
cargo dist host ${{ needs.plan.outputs.tag-flag }} --steps=upload --steps=release --output-format=json > dist-manifest.json
248+
dist host ${{ needs.plan.outputs.tag-flag }} --steps=upload --steps=release --output-format=json > dist-manifest.json
219249
echo "artifacts uploaded and released successfully"
220250
cat dist-manifest.json
221251
echo "manifest=$(jq -c "." dist-manifest.json)" >> "$GITHUB_OUTPUT"
222252
- name: "Upload dist-manifest.json"
223-
uses: actions/upload-artifact@v3
253+
uses: actions/upload-artifact@v6
224254
with:
225-
name: artifacts
255+
# Overwrite the previous copy
256+
name: artifacts-dist-manifest
226257
path: dist-manifest.json
258+
# Create a GitHub Release while uploading all files to it
259+
- name: "Download GitHub Artifacts"
260+
uses: actions/download-artifact@v7
261+
with:
262+
pattern: artifacts-*
263+
path: artifacts
264+
merge-multiple: true
265+
- name: Cleanup
266+
run: |
267+
# Remove the granular manifests
268+
rm -f artifacts/*-dist-manifest.json
269+
- name: Create GitHub Release
270+
env:
271+
PRERELEASE_FLAG: "${{ fromJson(steps.host.outputs.manifest).announcement_is_prerelease && '--prerelease' || '' }}"
272+
ANNOUNCEMENT_TITLE: "${{ fromJson(steps.host.outputs.manifest).announcement_title }}"
273+
ANNOUNCEMENT_BODY: "${{ fromJson(steps.host.outputs.manifest).announcement_github_body }}"
274+
RELEASE_COMMIT: "${{ github.sha }}"
275+
run: |
276+
# Write and read notes from a file to avoid quoting breaking things
277+
echo "$ANNOUNCEMENT_BODY" > $RUNNER_TEMP/notes.txt
278+
279+
gh release create "${{ needs.plan.outputs.tag }}" --target "$RELEASE_COMMIT" $PRERELEASE_FLAG --title "$ANNOUNCEMENT_TITLE" --notes-file "$RUNNER_TEMP/notes.txt" artifacts/*
227280
228-
# Create a Github Release while uploading all files to it
229281
announce:
230282
needs:
231283
- plan
@@ -234,27 +286,11 @@ jobs:
234286
# still allowing individual publish jobs to skip themselves (for prereleases).
235287
# "host" however must run to completion, no skipping allowed!
236288
if: ${{ always() && needs.host.result == 'success' }}
237-
runs-on: "ubuntu-20.04"
289+
runs-on: "ubuntu-22.04"
238290
env:
239291
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
240292
steps:
241-
- uses: actions/checkout@v4
293+
- uses: actions/checkout@v6
242294
with:
295+
persist-credentials: false
243296
submodules: recursive
244-
- name: "Download Github Artifacts"
245-
uses: actions/download-artifact@v3
246-
with:
247-
name: artifacts
248-
path: artifacts
249-
- name: Cleanup
250-
run: |
251-
# Remove the granular manifests
252-
rm -f artifacts/*-dist-manifest.json
253-
- name: Create Github Release
254-
uses: ncipollo/release-action@v1
255-
with:
256-
tag: ${{ needs.plan.outputs.tag }}
257-
name: ${{ fromJson(needs.host.outputs.val).announcement_title }}
258-
body: ${{ fromJson(needs.host.outputs.val).announcement_github_body }}
259-
prerelease: ${{ fromJson(needs.host.outputs.val).announcement_is_prerelease }}
260-
artifacts: "artifacts/*"

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ lto = "thin"
4040
# Config for 'cargo dist'
4141
[workspace.metadata.dist]
4242
# The preferred cargo-dist version to use in CI (Cargo.toml SemVer syntax)
43-
cargo-dist-version = "0.8.2"
43+
cargo-dist-version = "0.31.0"
4444
# CI backends to support
4545
ci = ["github"]
4646
# Target platforms to build apps for (Rust target-triple syntax)

0 commit comments

Comments
 (0)