Skip to content

Commit 38caa3a

Browse files
authored
Merge pull request #66 from ynqa/update-cargo-dist
chore: bump up version of cargo-dist 0.11.1 => 0.23.0
2 parents e17dec5 + 0bb54d1 commit 38caa3a

File tree

3 files changed

+79
-55
lines changed

3 files changed

+79
-55
lines changed

.github/workflows/release.yml

+60-38
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
1-
# Copyright 2022-2023, axodotdev
1+
# This file was autogenerated by cargo-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
79
# * builds artifacts with cargo-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.
@@ -31,22 +32,22 @@ permissions:
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:
4748
# Run 'cargo 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 || '' }}
@@ -62,7 +63,12 @@ jobs:
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.23.0/cargo-dist-installer.sh | sh"
67+
- name: Cache cargo-dist
68+
uses: actions/upload-artifact@v4
69+
with:
70+
name: cargo-dist-cache
71+
path: ~/.cargo/bin/cargo-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.
@@ -105,10 +111,12 @@ 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
112120
- name: Install cargo-dist
113121
run: ${{ matrix.install_dist }}
114122
# Get the dist-manifest
@@ -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"
@@ -160,9 +168,12 @@ jobs:
160168
- uses: actions/checkout@v4
161169
with:
162170
submodules: recursive
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.11.1/cargo-dist-installer.sh | sh"
171+
- name: Install cached cargo-dist
172+
uses: actions/download-artifact@v4
173+
with:
174+
name: cargo-dist-cache
175+
path: ~/.cargo/bin/
176+
- run: chmod +x ~/.cargo/bin/cargo-dist
166177
# Get all the local artifacts for the global tasks to use (for e.g. checksums)
167178
- name: Fetch local artifacts
168179
uses: actions/download-artifact@v4
@@ -178,7 +189,7 @@ jobs:
178189
179190
# Parse out what we just built and upload it to scratch storage
180191
echo "paths<<EOF" >> "$GITHUB_OUTPUT"
181-
jq --raw-output ".artifacts[]?.path | select( . != null )" dist-manifest.json >> "$GITHUB_OUTPUT"
192+
jq --raw-output ".upload_files[]" dist-manifest.json >> "$GITHUB_OUTPUT"
182193
echo "EOF" >> "$GITHUB_OUTPUT"
183194
184195
cp dist-manifest.json "$BUILD_MANIFEST_NAME"
@@ -206,16 +217,19 @@ jobs:
206217
- uses: actions/checkout@v4
207218
with:
208219
submodules: recursive
209-
- name: Install cargo-dist
210-
run: "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.11.1/cargo-dist-installer.sh | sh"
220+
- name: Install cached cargo-dist
221+
uses: actions/download-artifact@v4
222+
with:
223+
name: cargo-dist-cache
224+
path: ~/.cargo/bin/
225+
- run: chmod +x ~/.cargo/bin/cargo-dist
211226
# Fetch artifacts from scratch-storage
212227
- name: Fetch artifacts
213228
uses: actions/download-artifact@v4
214229
with:
215230
pattern: artifacts-*
216231
path: target/distrib/
217232
merge-multiple: true
218-
# This is a harmless no-op for Github Releases, hosting for that happens in "announce"
219233
- id: host
220234
shell: bash
221235
run: |
@@ -229,6 +243,28 @@ jobs:
229243
# Overwrite the previous copy
230244
name: artifacts-dist-manifest
231245
path: dist-manifest.json
246+
# Create a GitHub Release while uploading all files to it
247+
- name: "Download GitHub Artifacts"
248+
uses: actions/download-artifact@v4
249+
with:
250+
pattern: artifacts-*
251+
path: artifacts
252+
merge-multiple: true
253+
- name: Cleanup
254+
run: |
255+
# Remove the granular manifests
256+
rm -f artifacts/*-dist-manifest.json
257+
- name: Create GitHub Release
258+
env:
259+
PRERELEASE_FLAG: "${{ fromJson(steps.host.outputs.manifest).announcement_is_prerelease && '--prerelease' || '' }}"
260+
ANNOUNCEMENT_TITLE: "${{ fromJson(steps.host.outputs.manifest).announcement_title }}"
261+
ANNOUNCEMENT_BODY: "${{ fromJson(steps.host.outputs.manifest).announcement_github_body }}"
262+
RELEASE_COMMIT: "${{ github.sha }}"
263+
run: |
264+
# Write and read notes from a file to avoid quoting breaking things
265+
echo "$ANNOUNCEMENT_BODY" > $RUNNER_TEMP/notes.txt
266+
267+
gh release create "${{ needs.plan.outputs.tag }}" --target "$RELEASE_COMMIT" $PRERELEASE_FLAG --title "$ANNOUNCEMENT_TITLE" --notes-file "$RUNNER_TEMP/notes.txt" artifacts/*
232268
233269
publish-homebrew-formula:
234270
needs:
@@ -247,7 +283,7 @@ jobs:
247283
repository: "ynqa/homebrew-tap"
248284
token: ${{ secrets.HOMEBREW_TAP_TOKEN }}
249285
# So we have access to the formula
250-
- name: Fetch local artifacts
286+
- name: Fetch homebrew formulae
251287
uses: actions/download-artifact@v4
252288
with:
253289
pattern: artifacts-*
@@ -265,12 +301,16 @@ jobs:
265301
name=$(echo "$filename" | sed "s/\.rb$//")
266302
version=$(echo "$release" | jq .app_version --raw-output)
267303
304+
export PATH="/home/linuxbrew/.linuxbrew/bin:$PATH"
305+
brew update
306+
# We avoid reformatting user-provided data such as the app description and homepage.
307+
brew style --except-cops FormulaAudit/Homepage,FormulaAudit/Desc,FormulaAuditStrict --fix "Formula/${filename}" || true
308+
268309
git add "Formula/${filename}"
269310
git commit -m "${name} ${version}"
270311
done
271312
git push
272313
273-
# Create a Github Release while uploading all files to it
274314
announce:
275315
needs:
276316
- plan
@@ -287,21 +327,3 @@ jobs:
287327
- uses: actions/checkout@v4
288328
with:
289329
submodules: recursive
290-
- name: "Download Github Artifacts"
291-
uses: actions/download-artifact@v4
292-
with:
293-
pattern: artifacts-*
294-
path: artifacts
295-
merge-multiple: true
296-
- name: Cleanup
297-
run: |
298-
# Remove the granular manifests
299-
rm -f artifacts/*-dist-manifest.json
300-
- name: Create Github Release
301-
uses: ncipollo/release-action@v1
302-
with:
303-
tag: ${{ needs.plan.outputs.tag }}
304-
name: ${{ fromJson(needs.host.outputs.val).announcement_title }}
305-
body: ${{ fromJson(needs.host.outputs.val).announcement_github_body }}
306-
prerelease: ${{ fromJson(needs.host.outputs.val).announcement_is_prerelease }}
307-
artifacts: "artifacts/*"

Cargo.toml

-17
Original file line numberDiff line numberDiff line change
@@ -23,20 +23,3 @@ radix_trie = "0.2.1"
2323
[profile.dist]
2424
inherits = "release"
2525
lto = "thin"
26-
27-
# Config for 'cargo dist'
28-
[workspace.metadata.dist]
29-
# The preferred cargo-dist version to use in CI (Cargo.toml SemVer syntax)
30-
cargo-dist-version = "0.11.1"
31-
# CI backends to support
32-
ci = ["github"]
33-
# The installers to generate for each app
34-
installers = ["homebrew"]
35-
# A GitHub repo to push Homebrew formulas to
36-
tap = "ynqa/homebrew-tap"
37-
# Target platforms to build apps for (Rust target-triple syntax)
38-
targets = ["aarch64-apple-darwin", "x86_64-apple-darwin", "x86_64-unknown-linux-gnu", "x86_64-unknown-linux-musl", "x86_64-pc-windows-msvc"]
39-
# Publish jobs to run in CI
40-
publish-jobs = ["homebrew"]
41-
# Publish jobs to run in CI
42-
pr-run-mode = "plan"

dist-workspace.toml

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
[workspace]
2+
members = ["cargo:."]
3+
4+
# Config for 'cargo dist'
5+
[dist]
6+
# The preferred cargo-dist version to use in CI (Cargo.toml SemVer syntax)
7+
cargo-dist-version = "0.23.0"
8+
# CI backends to support
9+
ci = "github"
10+
# The installers to generate for each app
11+
installers = ["homebrew"]
12+
# A GitHub repo to push Homebrew formulas to
13+
tap = "ynqa/homebrew-tap"
14+
# Target platforms to build apps for (Rust target-triple syntax)
15+
targets = ["aarch64-apple-darwin", "x86_64-apple-darwin", "x86_64-unknown-linux-gnu", "x86_64-unknown-linux-musl", "x86_64-pc-windows-msvc"]
16+
# Publish jobs to run in CI
17+
publish-jobs = ["homebrew"]
18+
# Which actions to run on pull requests
19+
pr-run-mode = "plan"

0 commit comments

Comments
 (0)