Skip to content

Commit 51b9010

Browse files
authored
chore: update dist (cargo-dist) to 0.30.1 (#647)
The previous version of `cargo-dist` we had specified ran on `ubuntu-20.04` GitHub runners, which are no longer available and so the job just remained pending forever. This change updates everything to use the latest version of `dist` (it's been renamed from `cargo-dist`) 0.30.1.
1 parent 44e2281 commit 51b9010

File tree

3 files changed

+106
-76
lines changed

3 files changed

+106
-76
lines changed

.github/workflows/release.yml

Lines changed: 80 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
1+
# This file was autogenerated by dist: https://axodotdev.github.io/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

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,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
#
@@ -44,9 +45,9 @@ on:
4445
- '**[0-9]+.[0-9]+.[0-9]+*'
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-20.04"
50+
runs-on: "ubuntu-22.04"
5051
outputs:
5152
val: ${{ steps.plan.outputs.manifest }}
5253
tag: ${{ !github.event.pull_request && github.ref_name || '' }}
@@ -57,21 +58,27 @@ jobs:
5758
steps:
5859
- uses: actions/checkout@v4
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.15.1/cargo-dist-installer.sh | sh"
67+
run: "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.30.1/cargo-dist-installer.sh | sh"
68+
- name: Cache dist
69+
uses: actions/upload-artifact@v4
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 > plan-dist-manifest.json
74-
echo "cargo dist ran successfully"
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"
7582
cat plan-dist-manifest.json
7683
echo "manifest=$(jq -c "." plan-dist-manifest.json)" >> "$GITHUB_OUTPUT"
7784
- name: "Upload dist-manifest.json"
@@ -89,18 +96,19 @@ 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
@@ -110,12 +118,17 @@ jobs:
110118
git config --global core.longpaths true
111119
- uses: actions/checkout@v4
112120
with:
121+
persist-credentials: false
113122
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 }}
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 }}
119132
# Get the dist-manifest
120133
- name: Fetch local artifacts
121134
uses: actions/download-artifact@v4
@@ -129,8 +142,8 @@ jobs:
129142
- name: Build artifacts
130143
run: |
131144
# 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"
145+
dist build ${{ needs.plan.outputs.tag-flag }} --print=linkage --output-format=json ${{ matrix.dist_args }} > dist-manifest.json
146+
echo "dist ran successfully"
134147
- id: cargo-dist
135148
name: Post-build
136149
# We force bash here just because github makes it really hard to get values up
@@ -140,7 +153,7 @@ jobs:
140153
run: |
141154
# Parse out what we just built and upload it to scratch storage
142155
echo "paths<<EOF" >> "$GITHUB_OUTPUT"
143-
jq --raw-output ".upload_files[]" dist-manifest.json >> "$GITHUB_OUTPUT"
156+
dist print-upload-files-from-manifest --manifest dist-manifest.json >> "$GITHUB_OUTPUT"
144157
echo "EOF" >> "$GITHUB_OUTPUT"
145158
146159
cp dist-manifest.json "$BUILD_MANIFEST_NAME"
@@ -157,17 +170,21 @@ jobs:
157170
needs:
158171
- plan
159172
- build-local-artifacts
160-
runs-on: "ubuntu-20.04"
173+
runs-on: "ubuntu-22.04"
161174
env:
162175
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
163176
BUILD_MANIFEST_NAME: target/distrib/global-dist-manifest.json
164177
steps:
165178
- uses: actions/checkout@v4
166179
with:
180+
persist-credentials: false
167181
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.15.1/cargo-dist-installer.sh | sh"
182+
- name: Install cached dist
183+
uses: actions/download-artifact@v4
184+
with:
185+
name: cargo-dist-cache
186+
path: ~/.cargo/bin/
187+
- run: chmod +x ~/.cargo/bin/dist
171188
# Get all the local artifacts for the global tasks to use (for e.g. checksums)
172189
- name: Fetch local artifacts
173190
uses: actions/download-artifact@v4
@@ -178,8 +195,8 @@ jobs:
178195
- id: cargo-dist
179196
shell: bash
180197
run: |
181-
cargo dist build ${{ needs.plan.outputs.tag-flag }} --output-format=json "--artifacts=global" > dist-manifest.json
182-
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"
183200
184201
# Parse out what we just built and upload it to scratch storage
185202
echo "paths<<EOF" >> "$GITHUB_OUTPUT"
@@ -200,31 +217,35 @@ jobs:
200217
- plan
201218
- build-local-artifacts
202219
- build-global-artifacts
203-
# Only run if we're "publishing", and only if local and global didn't fail (skipped is fine)
204-
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') }}
205222
env:
206223
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
207-
runs-on: "ubuntu-20.04"
224+
runs-on: "ubuntu-22.04"
208225
outputs:
209226
val: ${{ steps.host.outputs.manifest }}
210227
steps:
211228
- uses: actions/checkout@v4
212229
with:
230+
persist-credentials: false
213231
submodules: recursive
214-
- name: Install cargo-dist
215-
run: "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.15.1/cargo-dist-installer.sh | sh"
232+
- name: Install cached dist
233+
uses: actions/download-artifact@v4
234+
with:
235+
name: cargo-dist-cache
236+
path: ~/.cargo/bin/
237+
- run: chmod +x ~/.cargo/bin/dist
216238
# Fetch artifacts from scratch-storage
217239
- name: Fetch artifacts
218240
uses: actions/download-artifact@v4
219241
with:
220242
pattern: artifacts-*
221243
path: target/distrib/
222244
merge-multiple: true
223-
# This is a harmless no-op for GitHub Releases, hosting for that happens in "announce"
224245
- id: host
225246
shell: bash
226247
run: |
227-
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
228249
echo "artifacts uploaded and released successfully"
229250
cat dist-manifest.json
230251
echo "manifest=$(jq -c "." dist-manifest.json)" >> "$GITHUB_OUTPUT"
@@ -234,8 +255,29 @@ jobs:
234255
# Overwrite the previous copy
235256
name: artifacts-dist-manifest
236257
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@v4
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/*
237280
238-
# Create a GitHub Release while uploading all files to it
239281
announce:
240282
needs:
241283
- plan
@@ -244,28 +286,11 @@ jobs:
244286
# still allowing individual publish jobs to skip themselves (for prereleases).
245287
# "host" however must run to completion, no skipping allowed!
246288
if: ${{ always() && needs.host.result == 'success' }}
247-
runs-on: "ubuntu-20.04"
289+
runs-on: "ubuntu-22.04"
248290
env:
249291
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
250292
steps:
251293
- uses: actions/checkout@v4
252294
with:
295+
persist-credentials: false
253296
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/*"

Cargo.toml

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,27 +7,6 @@ members = [
77
]
88
resolver = "2"
99

10-
# Config for 'cargo dist'
11-
[workspace.metadata.dist]
12-
# The preferred cargo-dist version to use in CI (Cargo.toml SemVer syntax)
13-
cargo-dist-version = "0.15.1"
14-
# CI backends to support
15-
ci = "github"
16-
# The installers to generate for each app
17-
installers = ["shell", "powershell", "msi"]
18-
# Target platforms to build apps for (Rust target-triple syntax)
19-
targets = [
20-
"aarch64-apple-darwin",
21-
"x86_64-apple-darwin",
22-
"x86_64-unknown-linux-gnu",
23-
"x86_64-unknown-linux-musl",
24-
"x86_64-pc-windows-msvc",
25-
]
26-
# Publish jobs to run in CI
27-
pr-run-mode = "plan"
28-
# Whether to install an updater program
29-
install-updater = false
30-
3110
# The profile that 'cargo dist' will build with
3211
[profile.dist]
3312
inherits = "release"

dist-workspace.toml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
[workspace]
2+
members = ["cargo:."]
3+
4+
# Config for 'dist'
5+
[dist]
6+
# The preferred dist version to use in CI (Cargo.toml SemVer syntax)
7+
cargo-dist-version = "0.30.1"
8+
# CI backends to support
9+
ci = "github"
10+
# The installers to generate for each app
11+
installers = ["shell", "powershell", "msi"]
12+
# Target platforms to build apps for (Rust target-triple syntax)
13+
targets = [
14+
"aarch64-apple-darwin",
15+
"aarch64-unknown-linux-gnu",
16+
"x86_64-apple-darwin",
17+
"x86_64-unknown-linux-gnu",
18+
"x86_64-unknown-linux-musl",
19+
"x86_64-pc-windows-msvc"
20+
]
21+
# Which actions to run on pull requests
22+
pr-run-mode = "plan"
23+
# Whether to install an updater program
24+
install-updater = false
25+
# Path that installers should place binaries in
26+
install-path = "CARGO_HOME"

0 commit comments

Comments
 (0)