Skip to content

Commit d11ec27

Browse files
authored
Merge pull request #774 from Shnatsel/dist-aarch64
Upgrade to dist v0.26 to build Aarch64 Linux binaries
2 parents c4c3ba9 + 493c568 commit d11ec27

File tree

2 files changed

+79
-60
lines changed

2 files changed

+79
-60
lines changed

.github/workflows/release.yml

+71-55
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
1+
# This file was autogenerated by dist: https://opensource.axo.dev/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-
id-token: write
19-
attestations: write
18+
"attestations": "write"
19+
"contents": "write"
20+
"id-token": "write"
2021

2122
# This task will run whenever you push a git tag that looks like a version
2223
# like "1.0.0", "v0.1.0-prerelease.1", "my-app/0.1.0", "releases/v1.0.0", etc.
@@ -25,10 +26,10 @@ permissions:
2526
# must be a Cargo-style SemVer Version (must have at least major.minor.patch).
2627
#
2728
# If PACKAGE_NAME is specified, then the announcement will be for that
28-
# package (erroring out if it doesn't have the given version or isn't cargo-dist-able).
29+
# package (erroring out if it doesn't have the given version or isn't dist-able).
2930
#
3031
# If PACKAGE_NAME isn't specified, then the announcement will be for all
31-
# (cargo-dist-able) packages in the workspace with that version (this mode is
32+
# (dist-able) packages in the workspace with that version (this mode is
3233
# intended for workspaces with only one dist-able package, or with all dist-able
3334
# packages versioned/released in lockstep).
3435
#
@@ -46,7 +47,7 @@ on:
4647
- '**[0-9]+.[0-9]+.[0-9]+*'
4748

4849
jobs:
49-
# Run 'cargo dist plan' (or host) to determine what tasks we need to do
50+
# Run 'dist plan' (or host) to determine what tasks we need to do
5051
plan:
5152
runs-on: "ubuntu-20.04"
5253
outputs:
@@ -60,20 +61,25 @@ jobs:
6061
- uses: actions/checkout@v4
6162
with:
6263
submodules: recursive
63-
- name: Install cargo-dist
64+
- name: Install dist
6465
# we specify bash to get pipefail; it guards against the `curl` command
6566
# failing. otherwise `sh` won't catch that `curl` returned non-0
6667
shell: bash
67-
run: "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.16.0/cargo-dist-installer.sh | sh"
68+
run: "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.26.1/cargo-dist-installer.sh | sh"
69+
- name: Cache dist
70+
uses: actions/upload-artifact@v4
71+
with:
72+
name: cargo-dist-cache
73+
path: ~/.cargo/bin/dist
6874
# sure would be cool if github gave us proper conditionals...
6975
# so here's a doubly-nested ternary-via-truthiness to try to provide the best possible
7076
# functionality based on whether this is a pull_request, and whether it's from a fork.
7177
# (PRs run on the *source* but secrets are usually on the *target* -- that's *good*
7278
# but also really annoying to build CI around when it needs secrets to work right.)
7379
- id: plan
7480
run: |
75-
cargo dist ${{ (!github.event.pull_request && format('host --steps=create --tag={0}', github.ref_name)) || 'plan' }} --output-format=json > plan-dist-manifest.json
76-
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"
7783
cat plan-dist-manifest.json
7884
echo "manifest=$(jq -c "." plan-dist-manifest.json)" >> "$GITHUB_OUTPUT"
7985
- name: "Upload dist-manifest.json"
@@ -91,18 +97,19 @@ jobs:
9197
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') }}
9298
strategy:
9399
fail-fast: false
94-
# Target platforms/runners are computed by cargo-dist in create-release.
100+
# Target platforms/runners are computed by dist in create-release.
95101
# Each member of the matrix has the following arguments:
96102
#
97103
# - runner: the github runner
98-
# - dist-args: cli flags to pass to cargo dist
99-
# - 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
100106
#
101107
# Typically there will be:
102108
# - 1 "global" task that builds universal installers
103109
# - N "local" tasks that build each platform's binaries and platform-specific installers
104110
matrix: ${{ fromJson(needs.plan.outputs.val).ci.github.artifacts_matrix }}
105111
runs-on: ${{ matrix.runner }}
112+
container: ${{ matrix.container && matrix.container.image || null }}
106113
env:
107114
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
108115
BUILD_MANIFEST_NAME: target/distrib/${{ join(matrix.targets, '-') }}-dist-manifest.json
@@ -113,12 +120,15 @@ jobs:
113120
- uses: actions/checkout@v4
114121
with:
115122
submodules: recursive
116-
- uses: swatinem/rust-cache@v2
117-
with:
118-
key: ${{ join(matrix.targets, '-') }}
119-
cache-provider: ${{ matrix.cache_provider }}
120-
- name: Install cargo-dist
121-
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 }}
122132
# Get the dist-manifest
123133
- name: Fetch local artifacts
124134
uses: actions/download-artifact@v4
@@ -132,8 +142,8 @@ jobs:
132142
- name: Build artifacts
133143
run: |
134144
# Actually do builds and make zips and whatnot
135-
cargo dist build ${{ needs.plan.outputs.tag-flag }} --print=linkage --output-format=json ${{ matrix.dist_args }} > dist-manifest.json
136-
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"
137147
- name: Attest
138148
uses: actions/attest-build-provenance@v1
139149
with:
@@ -147,7 +157,7 @@ jobs:
147157
run: |
148158
# Parse out what we just built and upload it to scratch storage
149159
echo "paths<<EOF" >> "$GITHUB_OUTPUT"
150-
jq --raw-output ".upload_files[]" dist-manifest.json >> "$GITHUB_OUTPUT"
160+
dist print-upload-files-from-manifest --manifest dist-manifest.json >> "$GITHUB_OUTPUT"
151161
echo "EOF" >> "$GITHUB_OUTPUT"
152162
153163
cp dist-manifest.json "$BUILD_MANIFEST_NAME"
@@ -172,9 +182,12 @@ jobs:
172182
- uses: actions/checkout@v4
173183
with:
174184
submodules: recursive
175-
- name: Install cargo-dist
176-
shell: bash
177-
run: "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.16.0/cargo-dist-installer.sh | sh"
185+
- name: Install cached dist
186+
uses: actions/download-artifact@v4
187+
with:
188+
name: cargo-dist-cache
189+
path: ~/.cargo/bin/
190+
- run: chmod +x ~/.cargo/bin/dist
178191
# Get all the local artifacts for the global tasks to use (for e.g. checksums)
179192
- name: Fetch local artifacts
180193
uses: actions/download-artifact@v4
@@ -185,8 +198,8 @@ jobs:
185198
- id: cargo-dist
186199
shell: bash
187200
run: |
188-
cargo dist build ${{ needs.plan.outputs.tag-flag }} --output-format=json "--artifacts=global" > dist-manifest.json
189-
echo "cargo dist ran successfully"
201+
dist build ${{ needs.plan.outputs.tag-flag }} --output-format=json "--artifacts=global" > dist-manifest.json
202+
echo "dist ran successfully"
190203
191204
# Parse out what we just built and upload it to scratch storage
192205
echo "paths<<EOF" >> "$GITHUB_OUTPUT"
@@ -218,20 +231,23 @@ jobs:
218231
- uses: actions/checkout@v4
219232
with:
220233
submodules: recursive
221-
- name: Install cargo-dist
222-
run: "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.16.0/cargo-dist-installer.sh | sh"
234+
- name: Install cached dist
235+
uses: actions/download-artifact@v4
236+
with:
237+
name: cargo-dist-cache
238+
path: ~/.cargo/bin/
239+
- run: chmod +x ~/.cargo/bin/dist
223240
# Fetch artifacts from scratch-storage
224241
- name: Fetch artifacts
225242
uses: actions/download-artifact@v4
226243
with:
227244
pattern: artifacts-*
228245
path: target/distrib/
229246
merge-multiple: true
230-
# This is a harmless no-op for GitHub Releases, hosting for that happens in "announce"
231247
- id: host
232248
shell: bash
233249
run: |
234-
cargo dist host ${{ needs.plan.outputs.tag-flag }} --steps=upload --steps=release --output-format=json > dist-manifest.json
250+
dist host ${{ needs.plan.outputs.tag-flag }} --steps=upload --steps=release --output-format=json > dist-manifest.json
235251
echo "artifacts uploaded and released successfully"
236252
cat dist-manifest.json
237253
echo "manifest=$(jq -c "." dist-manifest.json)" >> "$GITHUB_OUTPUT"
@@ -241,23 +257,7 @@ jobs:
241257
# Overwrite the previous copy
242258
name: artifacts-dist-manifest
243259
path: dist-manifest.json
244-
245-
# Create a GitHub Release while uploading all files to it
246-
announce:
247-
needs:
248-
- plan
249-
- host
250-
# use "always() && ..." to allow us to wait for all publish jobs while
251-
# still allowing individual publish jobs to skip themselves (for prereleases).
252-
# "host" however must run to completion, no skipping allowed!
253-
if: ${{ always() && needs.host.result == 'success' }}
254-
runs-on: "ubuntu-20.04"
255-
env:
256-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
257-
steps:
258-
- uses: actions/checkout@v4
259-
with:
260-
submodules: recursive
260+
# Create a GitHub Release while uploading all files to it
261261
- name: "Download GitHub Artifacts"
262262
uses: actions/download-artifact@v4
263263
with:
@@ -270,12 +270,28 @@ jobs:
270270
rm -f artifacts/*-dist-manifest.json
271271
- name: Create GitHub Release
272272
env:
273-
PRERELEASE_FLAG: "${{ fromJson(needs.host.outputs.val).announcement_is_prerelease && '--prerelease' || '' }}"
274-
ANNOUNCEMENT_TITLE: "${{ fromJson(needs.host.outputs.val).announcement_title }}"
275-
ANNOUNCEMENT_BODY: "${{ fromJson(needs.host.outputs.val).announcement_github_body }}"
273+
PRERELEASE_FLAG: "${{ fromJson(steps.host.outputs.manifest).announcement_is_prerelease && '--prerelease' || '' }}"
274+
ANNOUNCEMENT_TITLE: "${{ fromJson(steps.host.outputs.manifest).announcement_title }}"
275+
ANNOUNCEMENT_BODY: "${{ fromJson(steps.host.outputs.manifest).announcement_github_body }}"
276+
RELEASE_COMMIT: "${{ github.sha }}"
276277
run: |
277278
# Write and read notes from a file to avoid quoting breaking things
278279
echo "$ANNOUNCEMENT_BODY" > $RUNNER_TEMP/notes.txt
279280
280-
gh release create "${{ needs.plan.outputs.tag }}" --title "$ANNOUNCEMENT_TITLE" --notes-file "$RUNNER_TEMP/notes.txt" $PRERELEASE_FLAG
281-
gh release upload "${{ needs.plan.outputs.tag }}" artifacts/*
281+
gh release create "${{ needs.plan.outputs.tag }}" --target "$RELEASE_COMMIT" $PRERELEASE_FLAG --title "$ANNOUNCEMENT_TITLE" --notes-file "$RUNNER_TEMP/notes.txt" artifacts/*
282+
283+
announce:
284+
needs:
285+
- plan
286+
- host
287+
# use "always() && ..." to allow us to wait for all publish jobs while
288+
# still allowing individual publish jobs to skip themselves (for prereleases).
289+
# "host" however must run to completion, no skipping allowed!
290+
if: ${{ always() && needs.host.result == 'success' }}
291+
runs-on: "ubuntu-20.04"
292+
env:
293+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
294+
steps:
295+
- uses: actions/checkout@v4
296+
with:
297+
submodules: recursive

Cargo.toml

+8-5
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,24 @@ license = "Apache-2.0"
1414
repository = "https://github.com/CycloneDX/cyclonedx-rust-cargo"
1515
rust-version = "1.70.0"
1616

17-
# Config for 'cargo dist'
17+
# Config for 'dist'
1818
[workspace.metadata.dist]
19-
# The preferred cargo-dist version to use in CI (Cargo.toml SemVer syntax)
20-
cargo-dist-version = "0.16.0"
19+
# The preferred dist version to use in CI (Cargo.toml SemVer syntax)
20+
cargo-dist-version = "0.26.1"
2121
# CI backends to support
2222
ci = "github"
2323
# The installers to generate for each app
2424
installers = ["shell", "powershell"]
2525
# Target platforms to build apps for (Rust target-triple syntax)
26-
targets = ["aarch64-apple-darwin", "x86_64-apple-darwin", "x86_64-unknown-linux-gnu", "x86_64-unknown-linux-musl", "x86_64-pc-windows-msvc"]
27-
# Publish jobs to run in CI
26+
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"]
27+
# Which actions to run on pull requests
2828
pr-run-mode = "plan"
2929
# Whether to install an updater program
3030
install-updater = false
31+
# Whether to enable GitHub Attestations
3132
github-attestations = true
33+
# Path that installers should place binaries in
34+
install-path = "CARGO_HOME"
3235

3336
# The profile that 'cargo dist' will build with
3437
[profile.dist]

0 commit comments

Comments
 (0)