Skip to content

Commit b69c6db

Browse files
ci(rust): publish to crates.io via Trusted Publishing (OIDC) (#2346)
Replace the long-lived CARGO_REGISTRY_TOKEN secret with crates.io Trusted Publishing: rust-lang/crates-io-auth-action exchanges the workflow's GitHub OIDC token for a short-lived crates.io token that is automatically revoked when the job ends.
1 parent e27d76f commit b69c6db

1 file changed

Lines changed: 13 additions & 4 deletions

File tree

.github/workflows/rust-release.yml

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,14 @@
1313
# BEFORE the PR is merged, so a failed publish or failed smoke test
1414
# leaves the unmerged PR for cleanup.
1515
#
16-
# Authenticates to crates.io with a long-lived API token issued under the
17-
# Crypto Tools CI bot account, stored in the CARGO_REGISTRY_TOKEN repo
18-
# secret and gated by the `crates-io-publish` GitHub environment.
16+
# Authenticates to crates.io via Trusted Publishing (OIDC): the
17+
# `rust-lang/crates-io-auth-action` step exchanges the workflow's GitHub
18+
# OIDC token for a short-lived crates.io token (automatically revoked
19+
# when the job ends), gated by the `crates-io-publish` GitHub
20+
# environment. No long-lived crates.io API token is stored in the repo.
21+
# crates.io must be configured with a Trusted Publisher for this crate
22+
# pointing at this repo, the `rust-release.yml` workflow, and the
23+
# `crates-io-publish` environment.
1924
name: Rust Release
2025

2126
on:
@@ -79,11 +84,15 @@ jobs:
7984
working-directory: releases/rust/db_esdk
8085
run: cargo publish --dry-run
8186

87+
- name: Authenticate to crates.io (Trusted Publishing / OIDC)
88+
id: auth
89+
uses: rust-lang/crates-io-auth-action@v1
90+
8291
- name: Cargo publish
8392
shell: bash
8493
working-directory: releases/rust/db_esdk
8594
env:
86-
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
95+
CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }}
8796
run: cargo publish
8897

8998
- name: Configure AWS Credentials for test_published.sh

0 commit comments

Comments
 (0)