Skip to content

Commit fb3dae8

Browse files
committed
chore: switch to astral-sh/cargo-dist
1 parent d853ce3 commit fb3dae8

2 files changed

Lines changed: 47 additions & 33 deletions

File tree

.github/workflows/release.yml

Lines changed: 44 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
# This file was autogenerated by cargo-dist: https://opensource.axo.dev/cargo-dist/
1+
# This file was autogenerated by dist: https://github.com/astral-sh/cargo-dist
22
#
33
# Copyright 2022-2024, axodotdev
4+
# Copyright 2025 Astral Software Inc.
45
# SPDX-License-Identifier: MIT or Apache-2.0
56
#
67
# CI that:
78
#
89
# * checks for a Git Tag that looks like a release
9-
# * builds artifacts with cargo-dist (archives, installers, hashes)
10+
# * builds artifacts with dist (archives, installers, hashes)
1011
# * uploads those artifacts to temporary workflow zip
1112
# * on success, uploads the artifacts to a GitHub Release
1213
#
@@ -24,10 +25,10 @@ permissions:
2425
# must be a Cargo-style SemVer Version (must have at least major.minor.patch).
2526
#
2627
# If PACKAGE_NAME is specified, then the announcement will be for that
27-
# package (erroring out if it doesn't have the given version or isn't cargo-dist-able).
28+
# package (erroring out if it doesn't have the given version or isn't dist-able).
2829
#
2930
# If PACKAGE_NAME isn't specified, then the announcement will be for all
30-
# (cargo-dist-able) packages in the workspace with that version (this mode is
31+
# (dist-able) packages in the workspace with that version (this mode is
3132
# intended for workspaces with only one dist-able package, or with all dist-able
3233
# packages versioned/released in lockstep).
3334
#
@@ -45,9 +46,9 @@ on:
4546
- '**[0-9]+.[0-9]+.[0-9]+*'
4647

4748
jobs:
48-
# Run 'cargo dist plan' (or host) to determine what tasks we need to do
49+
# Run 'dist plan' (or host) to determine what tasks we need to do
4950
plan:
50-
runs-on: "ubuntu-20.04"
51+
runs-on: "ubuntu-22.04"
5152
outputs:
5253
val: ${{ steps.plan.outputs.manifest }}
5354
tag: ${{ !github.event.pull_request && github.ref_name || '' }}
@@ -58,26 +59,27 @@ jobs:
5859
steps:
5960
- uses: actions/checkout@v4
6061
with:
62+
persist-credentials: false
6163
submodules: recursive
62-
- name: Install cargo-dist
64+
- name: Install dist
6365
# we specify bash to get pipefail; it guards against the `curl` command
6466
# failing. otherwise `sh` won't catch that `curl` returned non-0
6567
shell: bash
66-
run: "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.22.1/cargo-dist-installer.sh | sh"
67-
- name: Cache cargo-dist
68+
run: "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/astral-sh/cargo-dist/releases/download/v0.28.4/cargo-dist-installer.sh | sh"
69+
- name: Cache dist
6870
uses: actions/upload-artifact@v4
6971
with:
7072
name: cargo-dist-cache
71-
path: ~/.cargo/bin/cargo-dist
73+
path: ~/.cargo/bin/dist
7274
# sure would be cool if github gave us proper conditionals...
7375
# so here's a doubly-nested ternary-via-truthiness to try to provide the best possible
7476
# functionality based on whether this is a pull_request, and whether it's from a fork.
7577
# (PRs run on the *source* but secrets are usually on the *target* -- that's *good*
7678
# but also really annoying to build CI around when it needs secrets to work right.)
7779
- id: plan
7880
run: |
79-
cargo dist ${{ (!github.event.pull_request && format('host --steps=create --tag={0}', github.ref_name)) || 'plan' }} --output-format=json > plan-dist-manifest.json
80-
echo "cargo dist ran successfully"
81+
dist ${{ (!github.event.pull_request && format('host --steps=create --tag={0}', github.ref_name)) || 'plan' }} --output-format=json > plan-dist-manifest.json
82+
echo "dist ran successfully"
8183
cat plan-dist-manifest.json
8284
echo "manifest=$(jq -c "." plan-dist-manifest.json)" >> "$GITHUB_OUTPUT"
8385
- name: "Upload dist-manifest.json"
@@ -95,18 +97,19 @@ jobs:
9597
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') }}
9698
strategy:
9799
fail-fast: false
98-
# Target platforms/runners are computed by cargo-dist in create-release.
100+
# Target platforms/runners are computed by dist in create-release.
99101
# Each member of the matrix has the following arguments:
100102
#
101103
# - runner: the github runner
102-
# - dist-args: cli flags to pass to cargo dist
103-
# - install-dist: expression to run to install cargo-dist on the runner
104+
# - dist-args: cli flags to pass to dist
105+
# - install-dist: expression to run to install dist on the runner
104106
#
105107
# Typically there will be:
106108
# - 1 "global" task that builds universal installers
107109
# - N "local" tasks that build each platform's binaries and platform-specific installers
108110
matrix: ${{ fromJson(needs.plan.outputs.val).ci.github.artifacts_matrix }}
109111
runs-on: ${{ matrix.runner }}
112+
container: ${{ matrix.container && matrix.container.image || null }}
110113
env:
111114
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
112115
BUILD_MANIFEST_NAME: target/distrib/${{ join(matrix.targets, '-') }}-dist-manifest.json
@@ -116,13 +119,21 @@ jobs:
116119
git config --global core.longpaths true
117120
- uses: actions/checkout@v4
118121
with:
122+
persist-credentials: false
119123
submodules: recursive
124+
- name: Install Rust non-interactively if not already installed
125+
if: ${{ matrix.container }}
126+
run: |
127+
if ! command -v cargo > /dev/null 2>&1; then
128+
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
129+
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
130+
fi
120131
- uses: swatinem/rust-cache@v2
121132
with:
122133
key: ${{ join(matrix.targets, '-') }}
123134
cache-provider: ${{ matrix.cache_provider }}
124-
- name: Install cargo-dist
125-
run: ${{ matrix.install_dist }}
135+
- name: Install dist
136+
run: ${{ matrix.install_dist.run }}
126137
# Get the dist-manifest
127138
- name: Fetch local artifacts
128139
uses: actions/download-artifact@v4
@@ -136,8 +147,8 @@ jobs:
136147
- name: Build artifacts
137148
run: |
138149
# Actually do builds and make zips and whatnot
139-
cargo dist build ${{ needs.plan.outputs.tag-flag }} --print=linkage --output-format=json ${{ matrix.dist_args }} > dist-manifest.json
140-
echo "cargo dist ran successfully"
150+
dist build ${{ needs.plan.outputs.tag-flag }} --print=linkage --output-format=json ${{ matrix.dist_args }} > dist-manifest.json
151+
echo "dist ran successfully"
141152
- id: cargo-dist
142153
name: Post-build
143154
# We force bash here just because github makes it really hard to get values up
@@ -147,7 +158,7 @@ jobs:
147158
run: |
148159
# Parse out what we just built and upload it to scratch storage
149160
echo "paths<<EOF" >> "$GITHUB_OUTPUT"
150-
jq --raw-output ".upload_files[]" dist-manifest.json >> "$GITHUB_OUTPUT"
161+
dist print-upload-files-from-manifest --manifest dist-manifest.json >> "$GITHUB_OUTPUT"
151162
echo "EOF" >> "$GITHUB_OUTPUT"
152163
153164
cp dist-manifest.json "$BUILD_MANIFEST_NAME"
@@ -164,20 +175,21 @@ jobs:
164175
needs:
165176
- plan
166177
- build-local-artifacts
167-
runs-on: "ubuntu-20.04"
178+
runs-on: "ubuntu-22.04"
168179
env:
169180
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
170181
BUILD_MANIFEST_NAME: target/distrib/global-dist-manifest.json
171182
steps:
172183
- uses: actions/checkout@v4
173184
with:
185+
persist-credentials: false
174186
submodules: recursive
175-
- name: Install cached cargo-dist
187+
- name: Install cached dist
176188
uses: actions/download-artifact@v4
177189
with:
178190
name: cargo-dist-cache
179191
path: ~/.cargo/bin/
180-
- run: chmod +x ~/.cargo/bin/cargo-dist
192+
- run: chmod +x ~/.cargo/bin/dist
181193
# Get all the local artifacts for the global tasks to use (for e.g. checksums)
182194
- name: Fetch local artifacts
183195
uses: actions/download-artifact@v4
@@ -188,8 +200,8 @@ jobs:
188200
- id: cargo-dist
189201
shell: bash
190202
run: |
191-
cargo dist build ${{ needs.plan.outputs.tag-flag }} --output-format=json "--artifacts=global" > dist-manifest.json
192-
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"
193205
194206
# Parse out what we just built and upload it to scratch storage
195207
echo "paths<<EOF" >> "$GITHUB_OUTPUT"
@@ -214,19 +226,20 @@ jobs:
214226
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') }}
215227
env:
216228
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
217-
runs-on: "ubuntu-20.04"
229+
runs-on: "ubuntu-22.04"
218230
outputs:
219231
val: ${{ steps.host.outputs.manifest }}
220232
steps:
221233
- uses: actions/checkout@v4
222234
with:
235+
persist-credentials: false
223236
submodules: recursive
224-
- name: Install cached cargo-dist
237+
- name: Install cached dist
225238
uses: actions/download-artifact@v4
226239
with:
227240
name: cargo-dist-cache
228241
path: ~/.cargo/bin/
229-
- run: chmod +x ~/.cargo/bin/cargo-dist
242+
- run: chmod +x ~/.cargo/bin/dist
230243
# Fetch artifacts from scratch-storage
231244
- name: Fetch artifacts
232245
uses: actions/download-artifact@v4
@@ -237,7 +250,7 @@ jobs:
237250
- id: host
238251
shell: bash
239252
run: |
240-
cargo dist host ${{ needs.plan.outputs.tag-flag }} --steps=upload --steps=release --output-format=json > dist-manifest.json
253+
dist host ${{ needs.plan.outputs.tag-flag }} --steps=upload --steps=release --output-format=json > dist-manifest.json
241254
echo "artifacts uploaded and released successfully"
242255
cat dist-manifest.json
243256
echo "manifest=$(jq -c "." dist-manifest.json)" >> "$GITHUB_OUTPUT"
@@ -278,12 +291,13 @@ jobs:
278291
# still allowing individual publish jobs to skip themselves (for prereleases).
279292
# "host" however must run to completion, no skipping allowed!
280293
if: ${{ always() && needs.host.result == 'success' }}
281-
runs-on: "ubuntu-20.04"
294+
runs-on: "ubuntu-22.04"
282295
env:
283296
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
284297
steps:
285298
- uses: actions/checkout@v4
286299
with:
300+
persist-credentials: false
287301
submodules: recursive
288302

289303
custom-bump-action:

Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,12 @@ inherits = "release"
6262
lto = "thin"
6363
strip = true
6464

65-
# Config for 'cargo dist'
65+
# Config for 'dist'
6666
[workspace.metadata.dist]
6767
# Whether to consider the binaries in a package for distribution (defaults true)
6868
dist = true
69-
# The preferred cargo-dist version to use in CI (Cargo.toml SemVer syntax)
70-
cargo-dist-version = "0.22.1"
69+
# The preferred dist version to use in CI (Cargo.toml SemVer syntax)
70+
cargo-dist-version = "0.28.4"
7171
# CI backends to support
7272
ci = "github"
7373
# The installers to generate for each app

0 commit comments

Comments
 (0)