Skip to content

Commit c6e8b46

Browse files
committed
update cargo dist
1 parent de9bf94 commit c6e8b46

File tree

3 files changed

+77
-89
lines changed

3 files changed

+77
-89
lines changed

.github/workflows/release.yml

Lines changed: 57 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
1-
# This file was autogenerated by dist: https://axodotdev.github.io/cargo-dist
2-
#
3-
# Copyright 2022-2024, axodotdev
1+
# Copyright 2022-2023, axodotdev
42
# SPDX-License-Identifier: MIT or Apache-2.0
53
#
64
# CI that:
75
#
86
# * checks for a Git Tag that looks like a release
9-
# * builds artifacts with dist (archives, installers, hashes)
7+
# * builds artifacts with cargo-dist (archives, installers, hashes)
108
# * uploads those artifacts to temporary workflow zip
11-
# * on success, uploads the artifacts to a GitHub Release
9+
# * on success, uploads the artifacts to a Github Release
1210
#
13-
# Note that the GitHub Release will be created with a generated
11+
# Note that the Github Release will be created with a generated
1412
# title/body based on your changelogs.
1513

1614
name: Release
15+
1716
permissions:
18-
"contents": "write"
17+
contents: write
1918

2019
# This task will run whenever you push a git tag that looks like a version
2120
# like "1.0.0", "v0.1.0-prerelease.1", "my-app/0.1.0", "releases/v1.0.0", etc.
@@ -24,30 +23,30 @@ permissions:
2423
# must be a Cargo-style SemVer Version (must have at least major.minor.patch).
2524
#
2625
# 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 dist-able).
26+
# package (erroring out if it doesn't have the given version or isn't cargo-dist-able).
2827
#
2928
# If PACKAGE_NAME isn't specified, then the announcement will be for all
30-
# (dist-able) packages in the workspace with that version (this mode is
29+
# (cargo-dist-able) packages in the workspace with that version (this mode is
3130
# intended for workspaces with only one dist-able package, or with all dist-able
3231
# packages versioned/released in lockstep).
3332
#
3433
# If you push multiple tags at once, separate instances of this workflow will
35-
# spin up, creating an independent announcement for each one. However, GitHub
34+
# spin up, creating an independent announcement for each one. However Github
3635
# will hard limit this to 3 tags per commit, as it will assume more tags is a
3736
# mistake.
3837
#
3938
# If there's a prerelease-style suffix to the version, then the release(s)
4039
# will be marked as a prerelease.
4140
on:
42-
pull_request:
4341
push:
4442
tags:
4543
- '**[0-9]+.[0-9]+.[0-9]+*'
44+
pull_request:
4645

4746
jobs:
48-
# Run 'dist plan' (or host) to determine what tasks we need to do
47+
# Run 'cargo dist plan' (or host) to determine what tasks we need to do
4948
plan:
50-
runs-on: "ubuntu-22.04"
49+
runs-on: ubuntu-latest
5150
outputs:
5251
val: ${{ steps.plan.outputs.manifest }}
5352
tag: ${{ !github.event.pull_request && github.ref_name || '' }}
@@ -58,27 +57,21 @@ jobs:
5857
steps:
5958
- uses: actions/checkout@v4
6059
with:
61-
persist-credentials: false
6260
submodules: recursive
63-
- name: Install dist
61+
- name: Install cargo-dist
6462
# we specify bash to get pipefail; it guards against the `curl` command
6563
# failing. otherwise `sh` won't catch that `curl` returned non-0
6664
shell: bash
67-
run: "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.30.0/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
65+
run: "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.12.0/cargo-dist-installer.sh | sh"
7366
# sure would be cool if github gave us proper conditionals...
7467
# so here's a doubly-nested ternary-via-truthiness to try to provide the best possible
7568
# functionality based on whether this is a pull_request, and whether it's from a fork.
7669
# (PRs run on the *source* but secrets are usually on the *target* -- that's *good*
7770
# but also really annoying to build CI around when it needs secrets to work right.)
7871
- id: plan
7972
run: |
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"
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"
8275
cat plan-dist-manifest.json
8376
echo "manifest=$(jq -c "." plan-dist-manifest.json)" >> "$GITHUB_OUTPUT"
8477
- name: "Upload dist-manifest.json"
@@ -96,39 +89,28 @@ jobs:
9689
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') }}
9790
strategy:
9891
fail-fast: false
99-
# Target platforms/runners are computed by dist in create-release.
92+
# Target platforms/runners are computed by cargo-dist in create-release.
10093
# Each member of the matrix has the following arguments:
10194
#
10295
# - runner: the github runner
103-
# - dist-args: cli flags to pass to dist
104-
# - install-dist: expression to run to install dist on the runner
96+
# - dist-args: cli flags to pass to cargo dist
97+
# - install-dist: expression to run to install cargo-dist on the runner
10598
#
10699
# Typically there will be:
107100
# - 1 "global" task that builds universal installers
108101
# - N "local" tasks that build each platform's binaries and platform-specific installers
109102
matrix: ${{ fromJson(needs.plan.outputs.val).ci.github.artifacts_matrix }}
110103
runs-on: ${{ matrix.runner }}
111-
container: ${{ matrix.container && matrix.container.image || null }}
112104
env:
113105
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
114106
BUILD_MANIFEST_NAME: target/distrib/${{ join(matrix.targets, '-') }}-dist-manifest.json
115107
steps:
116-
- name: enable windows longpaths
117-
run: |
118-
git config --global core.longpaths true
119108
- uses: actions/checkout@v4
120109
with:
121-
persist-credentials: false
122110
submodules: recursive
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 }}
111+
- uses: swatinem/rust-cache@v2
112+
- name: Install cargo-dist
113+
run: ${{ matrix.install_dist }}
132114
# Get the dist-manifest
133115
- name: Fetch local artifacts
134116
uses: actions/download-artifact@v4
@@ -142,8 +124,8 @@ jobs:
142124
- name: Build artifacts
143125
run: |
144126
# Actually do builds and make zips and whatnot
145-
dist build ${{ needs.plan.outputs.tag-flag }} --print=linkage --output-format=json ${{ matrix.dist_args }} > dist-manifest.json
146-
echo "dist ran successfully"
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"
147129
- id: cargo-dist
148130
name: Post-build
149131
# We force bash here just because github makes it really hard to get values up
@@ -153,7 +135,7 @@ jobs:
153135
run: |
154136
# Parse out what we just built and upload it to scratch storage
155137
echo "paths<<EOF" >> "$GITHUB_OUTPUT"
156-
dist print-upload-files-from-manifest --manifest dist-manifest.json >> "$GITHUB_OUTPUT"
138+
jq --raw-output ".artifacts[]?.path | select( . != null )" dist-manifest.json >> "$GITHUB_OUTPUT"
157139
echo "EOF" >> "$GITHUB_OUTPUT"
158140
159141
cp dist-manifest.json "$BUILD_MANIFEST_NAME"
@@ -170,21 +152,17 @@ jobs:
170152
needs:
171153
- plan
172154
- build-local-artifacts
173-
runs-on: "ubuntu-22.04"
155+
runs-on: "ubuntu-20.04"
174156
env:
175157
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
176158
BUILD_MANIFEST_NAME: target/distrib/global-dist-manifest.json
177159
steps:
178160
- uses: actions/checkout@v4
179161
with:
180-
persist-credentials: false
181162
submodules: recursive
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
163+
- name: Install cargo-dist
164+
shell: bash
165+
run: "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.12.0/cargo-dist-installer.sh | sh"
188166
# Get all the local artifacts for the global tasks to use (for e.g. checksums)
189167
- name: Fetch local artifacts
190168
uses: actions/download-artifact@v4
@@ -195,12 +173,12 @@ jobs:
195173
- id: cargo-dist
196174
shell: bash
197175
run: |
198-
dist build ${{ needs.plan.outputs.tag-flag }} --output-format=json "--artifacts=global" > dist-manifest.json
199-
echo "dist ran successfully"
176+
cargo dist build ${{ needs.plan.outputs.tag-flag }} --output-format=json "--artifacts=global" > dist-manifest.json
177+
echo "cargo dist ran successfully"
200178
201179
# Parse out what we just built and upload it to scratch storage
202180
echo "paths<<EOF" >> "$GITHUB_OUTPUT"
203-
jq --raw-output ".upload_files[]" dist-manifest.json >> "$GITHUB_OUTPUT"
181+
jq --raw-output ".artifacts[]?.path | select( . != null )" dist-manifest.json >> "$GITHUB_OUTPUT"
204182
echo "EOF" >> "$GITHUB_OUTPUT"
205183
206184
cp dist-manifest.json "$BUILD_MANIFEST_NAME"
@@ -221,31 +199,27 @@ jobs:
221199
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') }}
222200
env:
223201
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
224-
runs-on: "ubuntu-22.04"
202+
runs-on: "ubuntu-20.04"
225203
outputs:
226204
val: ${{ steps.host.outputs.manifest }}
227205
steps:
228206
- uses: actions/checkout@v4
229207
with:
230-
persist-credentials: false
231208
submodules: recursive
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
209+
- name: Install cargo-dist
210+
run: "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.12.0/cargo-dist-installer.sh | sh"
238211
# Fetch artifacts from scratch-storage
239212
- name: Fetch artifacts
240213
uses: actions/download-artifact@v4
241214
with:
242215
pattern: artifacts-*
243216
path: target/distrib/
244217
merge-multiple: true
218+
# This is a harmless no-op for Github Releases, hosting for that happens in "announce"
245219
- id: host
246220
shell: bash
247221
run: |
248-
dist host ${{ needs.plan.outputs.tag-flag }} --steps=upload --steps=release --output-format=json > dist-manifest.json
222+
cargo dist host ${{ needs.plan.outputs.tag-flag }} --steps=upload --steps=release --output-format=json > dist-manifest.json
249223
echo "artifacts uploaded and released successfully"
250224
cat dist-manifest.json
251225
echo "manifest=$(jq -c "." dist-manifest.json)" >> "$GITHUB_OUTPUT"
@@ -255,29 +229,8 @@ jobs:
255229
# Overwrite the previous copy
256230
name: artifacts-dist-manifest
257231
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/*
280232

233+
# Create a Github Release while uploading all files to it
281234
announce:
282235
needs:
283236
- plan
@@ -286,11 +239,28 @@ jobs:
286239
# still allowing individual publish jobs to skip themselves (for prereleases).
287240
# "host" however must run to completion, no skipping allowed!
288241
if: ${{ always() && needs.host.result == 'success' }}
289-
runs-on: "ubuntu-22.04"
242+
runs-on: "ubuntu-20.04"
290243
env:
291244
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
292245
steps:
293246
- uses: actions/checkout@v4
294247
with:
295-
persist-credentials: false
296248
submodules: recursive
249+
- name: "Download Github Artifacts"
250+
uses: actions/download-artifact@v4
251+
with:
252+
pattern: artifacts-*
253+
path: artifacts
254+
merge-multiple: true
255+
- name: Cleanup
256+
run: |
257+
# Remove the granular manifests
258+
rm -f artifacts/*-dist-manifest.json
259+
- name: Create Github Release
260+
uses: ncipollo/release-action@v1
261+
with:
262+
tag: ${{ needs.plan.outputs.tag }}
263+
name: ${{ fromJson(needs.host.outputs.val).announcement_title }}
264+
body: ${{ fromJson(needs.host.outputs.val).announcement_github_body }}
265+
prerelease: ${{ fromJson(needs.host.outputs.val).announcement_is_prerelease }}
266+
artifacts: "artifacts/*"

Cargo.toml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,21 @@ codegen-units = 1
3535
[profile.release-fast]
3636
inherits = "release"
3737
panic = "abort"
38+
39+
# The profile that 'cargo dist' will build with
40+
[profile.dist]
41+
inherits = "release"
42+
lto = "thin"
43+
44+
# Config for 'cargo dist'
45+
[workspace.metadata.dist]
46+
# The preferred cargo-dist version to use in CI (Cargo.toml SemVer syntax)
47+
cargo-dist-version = "0.12.0"
48+
# CI backends to support
49+
ci = ["github"]
50+
# The installers to generate for each app
51+
installers = []
52+
# Target platforms to build apps for (Rust target-triple syntax)
53+
targets = ["aarch64-apple-darwin", "x86_64-apple-darwin", "x86_64-unknown-linux-gnu", "x86_64-unknown-linux-musl", "x86_64-pc-windows-msvc"]
54+
# Publish jobs to run in CI
55+
pr-run-mode = "plan"

dist-workspace.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ members = ["cargo:."]
44
# Config for 'dist'
55
[dist]
66
# The preferred dist version to use in CI (Cargo.toml SemVer syntax)
7-
cargo-dist-version = "0.30.0"
7+
cargo-dist-version = "0.30.3"
88
# CI backends to support
99
ci = "github"
1010
# The installers to generate for each app
1111
installers = []
1212
# Target platforms to build apps for (Rust target-triple syntax)
13-
targets = ["aarch64-apple-darwin", "x86_64-apple-darwin", "x86_64-unknown-linux-gnu", "x86_64-pc-windows-msvc"]
13+
targets = ["aarch64-apple-darwin", "aarch64-unknown-linux-gnu", "x86_64-apple-darwin", "x86_64-unknown-linux-gnu", "x86_64-unknown-linux-musl", "x86_64-pc-windows-msvc"]
1414
# Which actions to run on pull requests
1515
pr-run-mode = "plan"

0 commit comments

Comments
 (0)