ci(rust-release): publish to crates.io via Trusted Publishing - #2433
Merged
Merged
Conversation
Replaces the long-lived `secrets.CRATES_TOKEN` with an OIDC exchange: the job mints an id-token, `rust-lang/crates-io-auth-action` trades it for a registry token that crates.io revokes when the run ends. Nothing long-lived is stored. Tags only. `cargo publish --dry-run` never authenticates, so `workflow_dispatch` runs keep working without any Trusted Publishing config. The `crates-io` environment is there to hang required reviewers off the publish, and must match the Environment field on each crate's crates.io entry (blank there accepts any).
|
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Drops the long-lived
secrets.CRATES_TOKENfrom the Rust release. The job now mints an OIDC id-token andrust-lang/crates-io-auth-actionexchanges it for a registry token that crates.io revokes when the run ends.python-release.ymlalready does the equivalent for PyPI (#2425), so this brings the Rust half in line.What changed
permissions: id-token: writeonrust_publishcrates-ioenvironment, so required reviewers can gate a publishrust-lang/crates-io-auth-action@c6f97d4(v1.0.5), SHA-pinned like the rest of our actionssteps.auth.outputs.tokeninstead ofsecrets.CRATES_TOKENThe auth step is gated on
refs/tags/v*:cargo publish --dry-runnever authenticates, soworkflow_dispatchruns keep working with no Trusted Publishing config at all. That means this PR is safe to merge before the crates.io side is configured — only a real tag needs it.Before the next tag: crates.io config is required, per crate
Trusted Publishing is configured on each crate at
crates.io/crates/<crate>/settings/trusted-publishing, with:huggingfacetokenizersrust-release.ymlcrates-io(or blank to accept any)Only
tokenizerscan be configured today. The other five crates this workflow publishes —bitcanon,tk-encode,tk-convert,tk-serialize,tk-train— do not exist on crates.io yet, and crates.io has no pending-publisher state (RFC 3691 lists it as a future enhancement). Each needs one token-based publish before a Trusted Publisher can be attached to it.So the first release of the new crates still needs a token; every release after that does not.