Skip to content

Commit f37e760

Browse files
volodstaimiclaude
andcommitted
Allow a one-time token for the first crates.io release
crates.io trusted publishing only works for a crate that already exists. The publish job uses a CARGO_REGISTRY_TOKEN secret when present and otherwise the trusted publisher. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 17ceb59 commit f37e760

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

‎.github/workflows/release.yml‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,11 @@ jobs:
6363
permissions:
6464
contents: read
6565
id-token: write
66+
env:
67+
# First release only. crates.io trusted publishing needs a crate that already exists,
68+
# so 0.1.0 uses a CARGO_REGISTRY_TOKEN repository secret. After it is published, add the
69+
# trusted publisher on crates.io, delete the secret and revoke the token.
70+
BOOTSTRAP_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
6671
steps:
6772
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
6873
with:
@@ -71,7 +76,8 @@ jobs:
7176
with:
7277
toolchain: ${{ env.STABLE }}
7378
- uses: rust-lang/crates-io-auth-action@3268eb413133e2960fa4ae0e963ca76380c54cd9 # v1.0.6
79+
if: env.BOOTSTRAP_TOKEN == ''
7480
id: auth
7581
- run: cargo publish --locked
7682
env:
77-
CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }}
83+
CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token || env.BOOTSTRAP_TOKEN }}

0 commit comments

Comments
 (0)