Skip to content

Commit 5b6c31b

Browse files
authored
chore(release): switch to release-plz (#1333)
1 parent c316e2a commit 5b6c31b

File tree

8 files changed

+106
-161
lines changed

8 files changed

+106
-161
lines changed

.github/workflows/check_semver.yml

Lines changed: 0 additions & 30 deletions
This file was deleted.

.github/workflows/create_release_assets.yml

Lines changed: 27 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,8 @@
11
name: Publish release files for CD native and non-cd-native environments
22

33
on:
4-
release:
5-
types: [ created ]
6-
# When a release failed, and there is something you need to fix in this
7-
# YML file, you can manually re-run the job via this event to re-do the
8-
# release. (Simply re-run the job through GitHub UI won't work as it would use
9-
# the old YML file, which needs a fix.)
10-
workflow_dispatch:
11-
inputs:
12-
# The GitHub Action (softprops/action-gh-release) used in this pipeline
13-
# needs a tag, you specify it through this parameter.
14-
#
15-
# In the case described above, it should be an existing tag. E.g., the
16-
# release of v16.0.4 failed, you should specify "v16.0.4" here.
17-
existing_tag:
18-
description: "The tag of the failed release that you wanna re-run and fix"
19-
required: true
20-
type: string
4+
repository_dispatch:
5+
types: [ release-created ]
216

227
permissions:
238
contents: read
@@ -91,21 +76,11 @@ jobs:
9176
- name: Build in Release profile with all features enabled
9277
run: cargo build --release --all-features
9378

94-
- name: Determine tag name
95-
id: determine_tag_name
96-
shell: bash # Or it won't work on Windows
97-
run: |
98-
if [ -n "${{ github.event.release.tag_name }}" ]; then
99-
echo "tag_name=${{ github.event.release.tag_name }}" >> $GITHUB_OUTPUT
100-
else
101-
echo "tag_name=${{ github.event.inputs.existing_tag }}" >> $GITHUB_OUTPUT
102-
fi
103-
10479
- name: Rename Release (Unix)
10580
run: |
10681
cargo install default-target
10782
mkdir -p assets
108-
FILENAME=topgrade-${{ steps.determine_tag_name.outputs.tag_name }}-$(default-target)
83+
FILENAME=topgrade-${{ github.event.client_payload.tag }}-$(default-target)
10984
mv target/release/topgrade assets
11085
cd assets
11186
tar --format=ustar -czf $FILENAME.tar.gz topgrade
@@ -136,7 +111,7 @@ jobs:
136111
run: |
137112
cargo install default-target
138113
mkdir assets
139-
FILENAME=topgrade-${{steps.determine_tag_name.outputs.tag_name}}-$(default-target)
114+
FILENAME=topgrade-${{ github.event.client_payload.tag }}-$(default-target)
140115
mv target/release/topgrade.exe assets/topgrade.exe
141116
cd assets
142117
powershell Compress-Archive -Path * -Destination ${FILENAME}.zip
@@ -145,12 +120,11 @@ jobs:
145120
if: ${{ matrix.platform == 'windows-latest' }}
146121
shell: bash
147122

148-
149-
- name: Release
150-
uses: softprops/action-gh-release@6da8fa9354ddfdc4aeace5fc48d7f679b5214090 # v2.4.1
151-
with:
152-
tag_name: ${{ steps.determine_tag_name.outputs.tag_name }}
153-
files: assets/*
123+
- name: Upload assets
124+
run:
125+
gh release upload "${{ github.event.client_payload.tag }}" assets/*
126+
env:
127+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
154128

155129
- name: Generate artifact attestations
156130
uses: actions/[email protected]
@@ -250,20 +224,10 @@ jobs:
250224
- name: Build in Release profile with all features enabled
251225
run: cross build --release --all-features --target ${{matrix.target}}
252226

253-
- name: Determine tag name
254-
id: determine_tag_name
255-
shell: bash # Or it won't work on Windows
256-
run: |
257-
if [ -n "${{ github.event.release.tag_name }}" ]; then
258-
echo "tag_name=${{ github.event.release.tag_name }}" >> $GITHUB_OUTPUT
259-
else
260-
echo "tag_name=${{ github.event.inputs.existing_tag }}" >> $GITHUB_OUTPUT
261-
fi
262-
263227
- name: Rename Release
264228
run: |
265229
mkdir -p assets
266-
FILENAME=topgrade-${{steps.determine_tag_name.outputs.tag_name}}-${{matrix.target}}
230+
FILENAME=topgrade-${{ github.event.client_payload.tag }}-${{matrix.target}}
267231
mv target/${{matrix.target}}/release/topgrade assets
268232
cd assets
269233
tar --format=ustar -czf $FILENAME.tar.gz topgrade
@@ -289,13 +253,25 @@ jobs:
289253
shell: bash
290254

291255

292-
- name: Release
293-
uses: softprops/action-gh-release@6da8fa9354ddfdc4aeace5fc48d7f679b5214090 # v2.4.1
294-
with:
295-
tag_name: ${{ steps.determine_tag_name.outputs.tag_name }}
296-
files: assets/*
256+
- name: Upload assets
257+
run:
258+
gh release upload "${{ github.event.client_payload.tag }}" assets/*
259+
env:
260+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
297261

298262
- name: Generate artifact attestations
299263
uses: actions/[email protected]
300264
with:
301265
subject-path: assets/*
266+
267+
triggers:
268+
runs-on: ubuntu-latest
269+
needs: [ native_build, cross_build ]
270+
steps:
271+
- name: Trigger workflows
272+
run: |
273+
gh api repos/${{ github.repository }}/dispatches \
274+
-f "event_type=release-assets-built" \
275+
-F "client_payload[tag]=${{ github.event.client_payload.tag }}"
276+
env:
277+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/release-plz.yml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: Release-plz
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
10+
# Release unpublished packages.
11+
release-plz-release:
12+
name: Release-plz release
13+
runs-on: ubuntu-latest
14+
environment: crates_io
15+
permissions:
16+
contents: write
17+
id-token: write # For trusted publishing
18+
steps:
19+
- &checkout
20+
name: Checkout repository
21+
uses: actions/checkout@v5
22+
with:
23+
fetch-depth: 0
24+
persist-credentials: false
25+
- &install-rust
26+
name: Install Rust toolchain
27+
uses: dtolnay/rust-toolchain@stable
28+
- name: Run release-plz
29+
id: release-plz
30+
uses: release-plz/[email protected]
31+
with:
32+
command: release
33+
env:
34+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
35+
36+
- name: Trigger workflows
37+
if: steps.release-plz.outputs.releases_created == 'true'
38+
run: |
39+
gh api repos/${{ github.repository }}/dispatches \
40+
-f "event_type=release-created" \
41+
-F "client_payload[tag]=${{ fromJSON(steps.release-plz.outputs.releases)[0].tag }}"
42+
env:
43+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
44+
45+
# Create a PR with the new versions and changelog, preparing the next release.
46+
release-plz-pr:
47+
name: Release-plz PR
48+
runs-on: ubuntu-latest
49+
permissions:
50+
contents: write
51+
pull-requests: write
52+
concurrency:
53+
group: release-plz-${{ github.ref }}
54+
cancel-in-progress: false
55+
steps:
56+
- *checkout
57+
- *install-rust
58+
- name: Run release-plz
59+
uses: release-plz/[email protected]
60+
with:
61+
command: release-pr
62+
env:
63+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/release_to_aur.yml

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,8 @@
11
name: Publish to AUR
22

33
on:
4-
# Step "Publish binary AUR package" needs the binaries built by the following
5-
# workflow, so we wait for it to complete.
6-
workflow_run:
7-
workflows: ["Publish release files for CD native and non-cd-native environments"]
8-
types:
9-
- completed
10-
workflow_dispatch:
11-
inputs:
12-
# Example: 16.0.4
13-
version:
14-
description: "The version of this manual release, e.g., 16.0.4"
15-
required: false
16-
type: string
4+
repository_dispatch:
5+
types: [ release-assets-built ]
176

187
permissions:
198
contents: read
@@ -25,12 +14,9 @@ jobs:
2514
- name: Determine version
2615
id: determine_version
2716
run: |
28-
if [ -n "${{ github.event.inputs.version }}" ]; then
29-
echo "version=${{ github.event.inputs.version }}" >> $GITHUB_OUTPUT
30-
else
31-
# GITHUB_REF should be something like "v16.0.4", remove the prefix v here
32-
echo "version=${GITHUB_REF#v}" >> $GITHUB_OUTPUT
33-
fi
17+
# tag should be something like "v16.0.4", remove the prefix v here
18+
tag="${{ github.event.client_payload.tag }}"
19+
echo "version=${tag#v}" >> $GITHUB_OUTPUT
3420
3521
- name: Publish source AUR package
3622
uses: varabyte/update-aur-package@572e31b1972fa289a27b1926c06a489eb89c7fd7

.github/workflows/release_to_homebrew.yml

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,8 @@
11
name: Publish to Homebrew
22

33
on:
4-
# workflow_run:
5-
# workflows: ["Check SemVer compliance"]
6-
# types:
7-
# - completed
8-
workflow_dispatch:
9-
push:
10-
tags:
11-
- "v*"
4+
repository_dispatch:
5+
types: [ release-created ]
126

137
permissions:
148
contents: read
@@ -20,6 +14,7 @@ jobs:
2014
- name: Set up Homebrew
2115
id: set-up-homebrew
2216
uses: Homebrew/actions/setup-homebrew@24a0b15df658487e137fcd20fba32757d41a9411 # master
17+
2318
- name: Cache Homebrew Bundler RubyGems
2419
id: cache
2520
uses: actions/[email protected]
@@ -31,6 +26,7 @@ jobs:
3126
- name: Install Homebrew Bundler RubyGems
3227
if: steps.cache.outputs.cache-hit != 'true'
3328
run: brew install-bundler-gems
29+
3430
- name: Bump formulae
3531
uses: Homebrew/actions/bump-packages@24a0b15df658487e137fcd20fba32757d41a9411 # master
3632
continue-on-error: true

.github/workflows/release_to_pypi.yml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
name: Update PyPi
22

33
on:
4-
release:
5-
types: [published]
6-
workflow_dispatch:
4+
repository_dispatch:
5+
types: [ release-created ]
76

87
permissions:
98
contents: read
109

1110
jobs:
11+
# TODO: make linux/windows/macos/sdist a matrix. See how other workflows do it.
1212
linux:
1313
runs-on: ubuntu-latest
1414
strategy:
@@ -21,7 +21,6 @@ jobs:
2121
with:
2222
target: ${{ matrix.target }}
2323
args: --release --out dist
24-
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
2524
manylinux: auto
2625
- name: Upload wheels
2726
uses: actions/[email protected]
@@ -41,7 +40,6 @@ jobs:
4140
with:
4241
target: ${{ matrix.target }}
4342
args: --release --out dist
44-
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
4543
- name: Upload wheels
4644
uses: actions/[email protected]
4745
with:
@@ -60,7 +58,6 @@ jobs:
6058
with:
6159
target: ${{ matrix.target }}
6260
args: --release --out dist
63-
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
6461
- name: Upload wheels
6562
uses: actions/[email protected]
6663
with:

.github/workflows/release_to_winget.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
name: Publish to WinGet
2+
23
on:
3-
release:
4-
types: [released]
5-
workflow_dispatch:
4+
repository_dispatch:
5+
types: [ release-created ]
66

77
permissions:
88
contents: read

0 commit comments

Comments
 (0)