Skip to content

ci: authenticate to crates.io over OIDC - #24

Merged
pratyush618 merged 1 commit into
masterfrom
ci/crates-oidc
Aug 4, 2026
Merged

ci: authenticate to crates.io over OIDC#24
pratyush618 merged 1 commit into
masterfrom
ci/crates-oidc

Conversation

@kartikeya-27

Copy link
Copy Markdown
Contributor

Drops the stored CARGO_TOKEN in favour of trusted publishing. Now that both crates exist on crates.io, a trusted publisher can be configured for them — which was the only thing blocking this.

     permissions:
       contents: write  # to push the crates-v* tag
+      id-token: write  # to mint a short-lived crates.io token over OIDC

+      - name: Authenticate to crates.io
+        id: auth
+        uses: rust-lang/crates-io-auth-action@v1
+
       - name: Publish crates
         env:
-          CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_TOKEN }}
+          CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }}

The job now exchanges its own OIDC identity for a credential valid only for that run. Nothing long-lived sits in repository secrets, so there is nothing to leak or rotate. Both registries are on the same model now — publish.yml already used OIDC for PyPI.

The explicit "token is empty" guard is gone with it; the auth step fails on its own if trust is not configured.

Before merging — two crates.io settings

1. dagron-ui needs a trusted publisher. Only dagron-core has one configured. Trust is per crate, not per repository, so dagron-ui will fail to publish without it. Same values on its settings page:

Repository:  ByteVeda/dagron
Workflow:    publish-crates.yml
Environment: crates.io

2. After a green release, enable "Require trusted publishing for all new versions" on both crates. That makes crates.io reject API tokens outright, so a leaked token cannot publish. Worth doing in that order — if it is enabled before this merges, the next release fails, since the workflow on master still sends a token.

Be aware it also closes the manual cargo publish break-glass path: with it on, releases can only go out through this workflow.

CARGO_TOKEN can be deleted from the crates.io environment once a release has gone out over OIDC. Revoking it on crates.io too is worthwhile — it stays valid until then.

Verification

  • actionlint clean
  • No secrets.CARGO_TOKEN reference remains anywhere in the workflow
  • rust-lang/crates-io-auth-action@v1 resolves (rust-lang's moving release branch), exports token, and runs on node24 — no Node 20 deprecation

Replaces the stored CARGO_TOKEN with a trusted-publishing exchange, so
the run mints a credential scoped to itself and nothing long-lived sits
in repository secrets.
@coderabbitai

coderabbitai Bot commented Aug 4, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@kartikeya-27, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 5 minutes

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 50656174-6d7d-4fdb-a269-8bdb6e0f7822

📥 Commits

Reviewing files that changed from the base of the PR and between 1cd7761 and 3de7fa8.

📒 Files selected for processing (2)
  • .github/workflows/publish-crates.yml
  • CONTRIBUTING.md

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@pratyush618
pratyush618 merged commit a1ad934 into master Aug 4, 2026
8 checks passed
@pratyush618
pratyush618 deleted the ci/crates-oidc branch August 4, 2026 06:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants