ci: publish to crates.io via trusted publishing (OIDC)#41
Conversation
…cret Switch the publish-crates job to crates.io Trusted Publishing: - run in `environment: crates` (matches the per-crate Trusted Publisher config) - grant `id-token: write` (mint the OIDC token) + `contents: read` - mint a short-lived token with `rust-lang/crates-io-auth-action` and pass it to each `cargo publish` via CARGO_REGISTRY_TOKEN - remove the `secrets.CARGO_REGISTRY_TOKEN` env and the token-presence check No stored API token is needed anymore. Trusted Publishers must exist on crates.io for both `togl-lib` and `togl` (repo smorin/toggle, workflow release.yml, environment `crates`); togl-lib was bootstrapped with a manual 0.0.0 publish since crates.io TP requires the crate to exist first. Refs P11.
|
Looking for one thing? Review this PR in Change Stack to search files, summaries, diffs, and code without losing your place. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThe PR migrates the release workflow from API-token-based crates.io authentication to OIDC Trusted Publishing. The ChangesOIDC Trusted Publishing Setup
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
Updates the release workflow to publish the Rust crates to crates.io using Trusted Publishing (OIDC) instead of a long-lived CARGO_REGISTRY_TOKEN secret, aligning the CI release pipeline with crates.io’s recommended authentication model.
Changes:
- Switch
publish-cratesto run in thecratesGitHub environment withid-token: writepermissions for OIDC. - Add
rust-lang/crates-io-auth-actionto mint a short-lived crates.io token and pass it tocargo publishviaCARGO_REGISTRY_TOKEN. - Update project documentation to reflect Trusted Publishing setup steps and remove API-token-secret guidance.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| PROJECTS.md | Updates the publishing project plan/manual steps to reflect crates.io Trusted Publishing (OIDC) and required per-crate Trusted Publisher setup. |
| .github/workflows/release.yml | Reworks the publish-crates job to authenticate via OIDC using crates-io-auth-action and removes dependency on a stored crates.io API token secret. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Switches the
publish-cratesjob to crates.io Trusted Publishing (OIDC) — no stored API token.Changes to the job
environment: crates(matches the per-crate Trusted Publisher config)permissions: { id-token: write, contents: read }(mint the OIDC token; the top-levelcontents: writedoesn't grant id-token)rust-lang/crates-io-auth-action@bbd8162 # v1.0.4mints a 30-min token, passed to eachcargo publishviaCARGO_REGISTRY_TOKENsecrets.CARGO_REGISTRY_TOKENenv + the token-presence checkSetup state
cratesGitHub environment exists in the repo.togl-libbootstrapped (manual0.0.0publish — crates.io TP requires the crate to exist before a Trusted Publisher can be configured; no pending-publisher flow like PyPI).togl-libandtoglon crates.io (reposmorin/toggle, workflowrelease.yml, environmentcrates). The workflow publishes both, so both need it.Notes
togl-libthentoglvia OIDC.cratesenvironment, allow tags — this workflow is tag-triggered, and branch rules can block tag deployments.Summary by CodeRabbit