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
name: release-please
on:
push:
branches:
permissions:
contents: write
pull-requests: write
id-token: write # OIDC token exchange for crates.io trusted publishing
concurrency:
group: release-${{ github.ref }}
cancel-in-progress: false # a half-finished publish is worse than a queued one
env:
CARGO_TERM_COLOR: always
jobs:
release-please:
runs-on: ubuntu-latest
steps:
# Mint a short-lived token from the shared org release app. Unlike the
# default GITHUB_TOKEN, PRs and tags created with it DO trigger other
# workflows — so CI (unit tests) runs on the release PR. Credentials are
# provisioned org-wide (visibility=all):
# RELEASE_APP_CLIENT_ID — Actions variable
# RELEASE_APP_PRIVATE_KEY — Actions secret
- name: Mint release app token
id: app-token
uses: actions/create-github-app-token@v1
with:
app-id: ${{ vars.RELEASE_APP_CLIENT_ID }}
private-key: ${{ secrets.RELEASE_APP_PRIVATE_KEY }}
- uses: googleapis/release-please-action@v5
id: release
with:
token: ${{ steps.app-token.outputs.token }}
config-file: release-please-config.json
manifest-file: .release-please-manifest.json
# Everything below runs only when merging the release PR actually cut a
# release. Publishing lives in this same job because events created with
# GITHUB_TOKEN never trigger separate `on: release` workflows.
- uses: actions/checkout@v4
if: ${{ steps.release.outputs.release_created }}
with:
ref: ${{ steps.release.outputs.tag_name }} # build the released tag, not the branch tip
- name: Install Rust toolchain
if: ${{ steps.release.outputs.release_created }}
uses: dtolnay/rust-toolchain@stable
# Trusted publishing: exchange this workflow's OIDC identity for a
# short-lived crates.io token. No long-lived secret is stored.
- uses: rust-lang/crates-io-auth-action@v1
id: auth
if: ${{ steps.release.outputs.release_created }}
- name: Publish to crates.io
if: ${{ steps.release.outputs.release_created }}
run: cargo publish
env:
CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }}