1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
name: Release-plz
on:
push:
branches:
permissions:
# Open/update the release PR and create GitHub Releases.
contents: write
pull-requests: write
# `gh workflow run release-binaries.yml` (workflow_dispatch) needs this even
# with GITHUB_TOKEN.
actions: write
# Don't run two release-plz jobs in parallel.
concurrency:
group: release-plz-${{ github.ref }}
cancel-in-progress: false
jobs:
release-plz-release:
name: Release-plz release
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 0
# release-plz pushes the version-bump commit / tag (and the release PR
# branch) via git, so the PAT must be persisted on the checkout — a tag
# pushed with the default GITHUB_TOKEN cannot trigger other workflows.
token: ${{ secrets.RELEASE_PLZ_TOKEN }}
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Run release-plz
id: release-plz
uses: release-plz/action@v0.5
with:
command: release
env:
GITHUB_TOKEN: ${{ secrets.RELEASE_PLZ_TOKEN }}
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
# The GitHub Release is created with the RELEASE_PLZ_TOKEN PAT, so a
# `release: published` trigger would fire — but we dispatch
# release-binaries explicitly (workflow_dispatch) as the deterministic,
# single trigger path rather than having release-binaries also listen on
# `release: published`, which would double-fire. workflow_dispatch works
# with the default GITHUB_TOKEN (given `actions: write`), so this step
# keeps it.
- name: Trigger release-binaries for each new release
if: ${{ steps.release-plz.outputs.releases_created == 'true' }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RELEASES: ${{ steps.release-plz.outputs.releases }}
run: |
# release-plz emits `.releases[].tag`; see
# https://release-plz.dev/docs/github/output for the schema.
echo "$RELEASES" | jq -r '.[].tag' | while read -r tag; do
if [ -z "$tag" ] || [ "$tag" = "null" ]; then
continue
fi
echo "Dispatching release-binaries for $tag"
gh workflow run release-binaries.yml -f tag="$tag"
done
release-plz-pr:
name: Release-plz PR
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 0
# release-plz pushes the version-bump commit / tag (and the release PR
# branch) via git, so the PAT must be persisted on the checkout — a tag
# pushed with the default GITHUB_TOKEN cannot trigger other workflows.
token: ${{ secrets.RELEASE_PLZ_TOKEN }}
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Run release-plz
uses: release-plz/action@v0.5
with:
command: release-pr
env:
GITHUB_TOKEN: ${{ secrets.RELEASE_PLZ_TOKEN }}