88jobs :
99 release-pr :
1010 name : Release PR
11- runs-on : depot -ubuntu-24.04-16
11+ runs-on : bearcove -ubuntu-24.04
1212 permissions :
1313 contents : write
1414 pull-requests : write
1515 concurrency :
1616 group : release-plz-${{ github.ref }}
1717 cancel-in-progress : false
1818 steps :
19- - uses : actions/checkout@v4
19+ - uses : actions/checkout@v6
2020 with :
2121 fetch-depth : 0
2222
@@ -32,29 +32,69 @@ jobs:
3232
3333 release :
3434 name : Publish
35- runs-on : depot -ubuntu-24.04-16
35+ runs-on : bearcove -ubuntu-24.04
3636 permissions :
3737 contents : write
3838 id-token : write
3939 concurrency :
4040 group : release-${{ github.ref }}
4141 cancel-in-progress : false
4242 steps :
43- - uses : actions/checkout@v4
43+ - uses : actions/checkout@v6
4444 with :
4545 fetch-depth : 0
4646
4747 - name : Install Rust
4848 uses : dtolnay/rust-toolchain@1.92
4949
50- - name : Authenticate to crates.io ( OIDC)
50+ - name : Get crates.io token via OIDC
5151 id : crates-io-auth
52- uses : rust-lang/crates-io-auth-action@v1
52+ shell : bash
53+ env :
54+ REGISTRY_URL : https://crates.io
55+ run : |
56+ set -euo pipefail
57+ if [ -z "${ACTIONS_ID_TOKEN_REQUEST_URL:-}" ]; then
58+ echo "::error::Please ensure the 'id-token' permission is set to 'write' in your workflow."
59+ exit 1
60+ fi
61+
62+ oidc_url="${ACTIONS_ID_TOKEN_REQUEST_URL}&audience=crates.io"
63+ jwt="$(curl -fsSL -H "Authorization: bearer ${ACTIONS_ID_TOKEN_REQUEST_TOKEN}" "${oidc_url}" | jq -r '.value')"
64+ if [ -z "${jwt}" ] || [ "${jwt}" = "null" ]; then
65+ echo "::error::Failed to retrieve GitHub Actions OIDC token"
66+ exit 1
67+ fi
68+
69+ token="$(jq -n --arg jwt "${jwt}" '{jwt: $jwt}' \
70+ | curl -fsSL -X POST "${REGISTRY_URL}/api/v1/trusted_publishing/tokens" \
71+ -H "Content-Type: application/json" \
72+ -H "User-Agent: crates-io-auth-shell/1" \
73+ --data @- \
74+ | jq -r '.token')"
75+ if [ -z "${token}" ] || [ "${token}" = "null" ]; then
76+ echo "::error::Failed to retrieve crates.io token"
77+ exit 1
78+ fi
5379
80+ echo "::add-mask::${token}"
81+ echo "token=${token}" >> "${GITHUB_OUTPUT}"
5482 - name : Run release-plz
5583 uses : release-plz/action@v0.5
5684 with :
5785 command : release
5886 env :
5987 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
6088 CARGO_REGISTRY_TOKEN : ${{ steps.crates-io-auth.outputs.token }}
89+ - name : Revoke crates.io token
90+ if : always() && steps.crates-io-auth.outputs.token != ''
91+ shell : bash
92+ env :
93+ CARGO_REGISTRY_TOKEN : ${{ steps.crates-io-auth.outputs.token }}
94+ REGISTRY_URL : https://crates.io
95+ run : |
96+ set -euo pipefail
97+ curl -fsSL -X DELETE "${REGISTRY_URL}/api/v1/trusted_publishing/tokens" \
98+ -H "Authorization: Bearer ${CARGO_REGISTRY_TOKEN}" \
99+ -H "User-Agent: crates-io-auth-shell/1" \
100+ --output /dev/null
0 commit comments