Skip to content

Commit e396865

Browse files
authored
Upgrade cargo-dist (#171)
v0.11.1 was using `macos-12` runners, which are deprecated, causing [release issues](https://github.com/oscope-dev/scope/actions/runs/12207539878/job/34059419077). Upgrade to the latest version, which uses `macos-14` runners.
1 parent 1ef9b90 commit e396865

File tree

2 files changed

+88
-60
lines changed

2 files changed

+88
-60
lines changed

.github/workflows/release.yml

+78-55
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://opensource.axo.dev/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-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.11.1/cargo-dist-installer.sh | sh"
66+
run: "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.25.1/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,12 +95,12 @@ 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
@@ -105,11 +111,13 @@ jobs:
105111
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
106112
BUILD_MANIFEST_NAME: target/distrib/${{ join(matrix.targets, '-') }}-dist-manifest.json
107113
steps:
114+
- name: enable windows longpaths
115+
run: |
116+
git config --global core.longpaths true
108117
- uses: actions/checkout@v4
109118
with:
110119
submodules: recursive
111-
- uses: swatinem/rust-cache@v2
112-
- name: Install cargo-dist
120+
- name: Install dist
113121
run: ${{ matrix.install_dist }}
114122
# Get the dist-manifest
115123
- name: Fetch local artifacts
@@ -124,8 +132,8 @@ jobs:
124132
- name: Build artifacts
125133
run: |
126134
# Actually do builds and make zips and whatnot
127-
cargo dist build ${{ needs.plan.outputs.tag-flag }} --print=linkage --output-format=json ${{ matrix.dist_args }} > dist-manifest.json
128-
echo "cargo dist ran successfully"
135+
dist build ${{ needs.plan.outputs.tag-flag }} --print=linkage --output-format=json ${{ matrix.dist_args }} > dist-manifest.json
136+
echo "dist ran successfully"
129137
- id: cargo-dist
130138
name: Post-build
131139
# We force bash here just because github makes it really hard to get values up
@@ -135,7 +143,7 @@ jobs:
135143
run: |
136144
# Parse out what we just built and upload it to scratch storage
137145
echo "paths<<EOF" >> "$GITHUB_OUTPUT"
138-
jq --raw-output ".artifacts[]?.path | select( . != null )" dist-manifest.json >> "$GITHUB_OUTPUT"
146+
jq --raw-output ".upload_files[]" dist-manifest.json >> "$GITHUB_OUTPUT"
139147
echo "EOF" >> "$GITHUB_OUTPUT"
140148
141149
cp dist-manifest.json "$BUILD_MANIFEST_NAME"
@@ -170,9 +178,12 @@ jobs:
170178
- uses: actions/checkout@v4
171179
with:
172180
submodules: recursive
173-
- name: Install cargo-dist
174-
shell: bash
175-
run: "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.11.1/cargo-dist-installer.sh | sh"
181+
- name: Install cached dist
182+
uses: actions/download-artifact@v4
183+
with:
184+
name: cargo-dist-cache
185+
path: ~/.cargo/bin/
186+
- run: chmod +x ~/.cargo/bin/dist
176187
# Get all the local artifacts for the global tasks to use (for e.g. checksums)
177188
- name: Fetch local artifacts
178189
uses: actions/download-artifact@v4
@@ -183,12 +194,12 @@ jobs:
183194
- id: cargo-dist
184195
shell: bash
185196
run: |
186-
cargo dist build ${{ needs.plan.outputs.tag-flag }} --output-format=json "--artifacts=global" > dist-manifest.json
187-
echo "cargo dist ran successfully"
197+
dist build ${{ needs.plan.outputs.tag-flag }} --output-format=json "--artifacts=global" > dist-manifest.json
198+
echo "dist ran successfully"
188199
189200
# Parse out what we just built and upload it to scratch storage
190201
echo "paths<<EOF" >> "$GITHUB_OUTPUT"
191-
jq --raw-output ".artifacts[]?.path | select( . != null )" dist-manifest.json >> "$GITHUB_OUTPUT"
202+
jq --raw-output ".upload_files[]" dist-manifest.json >> "$GITHUB_OUTPUT"
192203
echo "EOF" >> "$GITHUB_OUTPUT"
193204
194205
cp dist-manifest.json "$BUILD_MANIFEST_NAME"
@@ -214,10 +225,11 @@ jobs:
214225
needs:
215226
- plan
216227
- build-local-artifacts
228+
- custom-build-linux-arm
217229
- build-global-artifacts
218230
- custom-build-linux-pkgs
219231
# Only run if we're "publishing", and only if local and global didn't fail (skipped is fine)
220-
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') }}
232+
if: ${{ always() && needs.plan.outputs.publishing == 'true' && (needs.build-global-artifacts.result == 'skipped' || needs.build-global-artifacts.result == 'success') && (needs.custom-build-linux-pkgs.result == 'skipped' || needs.custom-build-linux-pkgs.result == 'success') && (needs.build-local-artifacts.result == 'skipped' || needs.build-local-artifacts.result == 'success') && (needs.custom-build-linux-arm.result == 'skipped' || needs.custom-build-linux-arm.result == 'success') }}
221233
env:
222234
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
223235
runs-on: "ubuntu-20.04"
@@ -227,20 +239,23 @@ jobs:
227239
- uses: actions/checkout@v4
228240
with:
229241
submodules: recursive
230-
- name: Install cargo-dist
231-
run: "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.11.1/cargo-dist-installer.sh | sh"
242+
- name: Install cached dist
243+
uses: actions/download-artifact@v4
244+
with:
245+
name: cargo-dist-cache
246+
path: ~/.cargo/bin/
247+
- run: chmod +x ~/.cargo/bin/dist
232248
# Fetch artifacts from scratch-storage
233249
- name: Fetch artifacts
234250
uses: actions/download-artifact@v4
235251
with:
236252
pattern: artifacts-*
237253
path: target/distrib/
238254
merge-multiple: true
239-
# This is a harmless no-op for Github Releases, hosting for that happens in "announce"
240255
- id: host
241256
shell: bash
242257
run: |
243-
cargo dist host ${{ needs.plan.outputs.tag-flag }} --steps=upload --steps=release --output-format=json > dist-manifest.json
258+
dist host ${{ needs.plan.outputs.tag-flag }} --steps=upload --steps=release --output-format=json > dist-manifest.json
244259
echo "artifacts uploaded and released successfully"
245260
cat dist-manifest.json
246261
echo "manifest=$(jq -c "." dist-manifest.json)" >> "$GITHUB_OUTPUT"
@@ -250,6 +265,28 @@ jobs:
250265
# Overwrite the previous copy
251266
name: artifacts-dist-manifest
252267
path: dist-manifest.json
268+
# Create a GitHub Release while uploading all files to it
269+
- name: "Download GitHub Artifacts"
270+
uses: actions/download-artifact@v4
271+
with:
272+
pattern: artifacts-*
273+
path: artifacts
274+
merge-multiple: true
275+
- name: Cleanup
276+
run: |
277+
# Remove the granular manifests
278+
rm -f artifacts/*-dist-manifest.json
279+
- name: Create GitHub Release
280+
env:
281+
PRERELEASE_FLAG: "${{ fromJson(steps.host.outputs.manifest).announcement_is_prerelease && '--prerelease' || '' }}"
282+
ANNOUNCEMENT_TITLE: "${{ fromJson(steps.host.outputs.manifest).announcement_title }}"
283+
ANNOUNCEMENT_BODY: "${{ fromJson(steps.host.outputs.manifest).announcement_github_body }}"
284+
RELEASE_COMMIT: "${{ github.sha }}"
285+
run: |
286+
# Write and read notes from a file to avoid quoting breaking things
287+
echo "$ANNOUNCEMENT_BODY" > $RUNNER_TEMP/notes.txt
288+
289+
gh release create "${{ needs.plan.outputs.tag }}" --target "$RELEASE_COMMIT" $PRERELEASE_FLAG --title "$ANNOUNCEMENT_TITLE" --notes-file "$RUNNER_TEMP/notes.txt" artifacts/*
253290
254291
publish-homebrew-formula:
255292
needs:
@@ -268,7 +305,7 @@ jobs:
268305
repository: "oscope-dev/homebrew-formulas"
269306
token: ${{ secrets.HOMEBREW_TAP_TOKEN }}
270307
# So we have access to the formula
271-
- name: Fetch local artifacts
308+
- name: Fetch homebrew formulae
272309
uses: actions/download-artifact@v4
273310
with:
274311
pattern: artifacts-*
@@ -286,12 +323,16 @@ jobs:
286323
name=$(echo "$filename" | sed "s/\.rb$//")
287324
version=$(echo "$release" | jq .app_version --raw-output)
288325
326+
export PATH="/home/linuxbrew/.linuxbrew/bin:$PATH"
327+
brew update
328+
# We avoid reformatting user-provided data such as the app description and homepage.
329+
brew style --except-cops FormulaAudit/Homepage,FormulaAudit/Desc,FormulaAuditStrict --fix "Formula/${filename}" || true
330+
289331
git add "Formula/${filename}"
290332
git commit -m "${name} ${version}"
291333
done
292334
git push
293335
294-
# Create a Github Release while uploading all files to it
295336
announce:
296337
needs:
297338
- plan
@@ -308,24 +349,6 @@ jobs:
308349
- uses: actions/checkout@v4
309350
with:
310351
submodules: recursive
311-
- name: "Download Github Artifacts"
312-
uses: actions/download-artifact@v4
313-
with:
314-
pattern: artifacts-*
315-
path: artifacts
316-
merge-multiple: true
317-
- name: Cleanup
318-
run: |
319-
# Remove the granular manifests
320-
rm -f artifacts/*-dist-manifest.json
321-
- name: Create Github Release
322-
uses: ncipollo/release-action@v1
323-
with:
324-
tag: ${{ needs.plan.outputs.tag }}
325-
name: ${{ fromJson(needs.host.outputs.val).announcement_title }}
326-
body: ${{ fromJson(needs.host.outputs.val).announcement_github_body }}
327-
prerelease: ${{ fromJson(needs.host.outputs.val).announcement_is_prerelease }}
328-
artifacts: "artifacts/*"
329352

330353
custom-dotslash:
331354
needs:

Cargo.toml

+10-5
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
members = ["scope"]
33
resolver = "2"
44

5-
# Config for 'cargo dist'
5+
# Config for 'dist'
66
[workspace.metadata.dist]
7-
# The preferred cargo-dist version to use in CI (Cargo.toml SemVer syntax)
8-
cargo-dist-version = "0.11.1"
7+
# The preferred dist version to use in CI (Cargo.toml SemVer syntax)
8+
cargo-dist-version = "0.25.1"
99
# CI backends to support
10-
ci = ["github"]
10+
ci = "github"
1111
# The installers to generate for each app
1212
installers = ["shell", "homebrew"]
1313
# A GitHub repo to push Homebrew formulas to
@@ -18,13 +18,18 @@ targets = ["aarch64-apple-darwin", "x86_64-apple-darwin", "x86_64-unknown-linux-
1818
global-artifacts-jobs = ["./build-linux-pkgs"]
1919
# Publish jobs to run in CI
2020
publish-jobs = ["homebrew"]
21-
# Publish jobs to run in CI
21+
# Which actions to run on pull requests
2222
pr-run-mode = "plan"
2323
# Whether to publish prereleases to package managers
2424
publish-prereleases = true
2525
# Post-announce jobs to run in CI
2626
post-announce-jobs = ["./dotslash"]
27+
# Local artifacts jobs to run in CI
2728
local-artifacts-jobs = ["./build-linux-arm"]
29+
# Path that installers should place binaries in
30+
install-path = "CARGO_HOME"
31+
# Whether to install an updater program
32+
install-updater = false
2833

2934
# The profile that 'cargo dist' will build with
3035
[profile.dist]

0 commit comments

Comments
 (0)