Skip to content

ci(release): switch crates.io publish to Trusted Publishing (OIDC)#12

Open
dkijania wants to merge 1 commit into
masterfrom
ci/release-trusted-publishing
Open

ci(release): switch crates.io publish to Trusted Publishing (OIDC)#12
dkijania wants to merge 1 commit into
masterfrom
ci/release-trusted-publishing

Conversation

@dkijania
Copy link
Copy Markdown
Member

Summary

Removes the long-lived CARGO_REGISTRY_TOKEN dependency on the publish job. Authentication flows through GitHub Actions OIDC: rust-lang/crates-io-auth-action exchanges the short-lived OIDC token for a single-use crates.io API token, scoped to this workflow + ref.

Existing structure preserved: testpublish-dry-runpublish (gated by the crates-io GitHub Environment). Only the publish step changes.

What this PR changes

  • id-token: write permission scoped to the publish job (the other jobs don't need OIDC).
  • New auth step before cargo publish using rust-lang/crates-io-auth-action@v1.
  • Its output token threaded into CARGO_REGISTRY_TOKEN for the publish step.
  • No change to triggers, environment gating, or the test/dry-run jobs.

Prereqs before merging

Both are one-time actions. They don't block the merge itself — but the next release after this lands will fail at the auth step unless these are in place.

  • Configure trusted publisher. On https://crates.io/crates/mina-sdk → Settings → Trusted Publishers → Add GitHub Actions:
    • org: `MinaProtocol`
    • repo: `mina-sdk-rust`
    • workflow: `release.yml`
    • environment: `crates-io` (matches the existing job's `environment:` declaration)
  • Add team co-owner so the crate is owned by the org, not a single user:
    ```
    cargo owner --add github:o1-labs:eng mina-sdk
    ```
    Currently the crate is sole-owned by `dkijania` — adding the team gives the rest of o1-labs/eng publish rights.

Why

  • Bus factor. Today the crate has a single owner and a single token. Team ownership + OIDC means publishes survive maintainer turnover.
  • Secret reduction. No `CARGO_REGISTRY_TOKEN` rotation. The auth action mints a token scoped to one publish, then it expires.
  • Symmetric. Same change just landed for the sibling `mina-archive-sdk` crate (o1-labs/mina-archive-sdk-rust#1).

After OIDC publishing has succeeded once, the existing `CARGO_REGISTRY_TOKEN` repo secret can be revoked (or kept as a dormant fallback — this workflow no longer reads it).

🤖 Generated with Claude Code

Removes the long-lived CARGO_REGISTRY_TOKEN dependency on the `publish`
job. Authentication flows through GitHub Actions OIDC:
rust-lang/crates-io-auth-action exchanges the short-lived id-token for
a single-use crates.io API token, scoped to this workflow + ref.

Keeps the existing job structure intact:
  test → publish-dry-run → publish (gated by `crates-io` environment).

Adds:
  - `id-token: write` permission on the `publish` job (other jobs don't
    need OIDC, so scope it tight).
  - rust-lang/crates-io-auth-action@v1 step before cargo publish.
  - Threads the action's output token into CARGO_REGISTRY_TOKEN.

Prereqs before this workflow can succeed on the next release:
  1. Configure trusted publisher on https://crates.io/crates/mina-sdk
     → Settings → Trusted Publishers → Add GitHub Actions:
         org=MinaProtocol, repo=mina-sdk-rust, workflow=release.yml,
         environment=crates-io.
  2. (Recommended) Add a GitHub team as crate co-owner so ownership
     tracks org membership instead of a single user:
         cargo owner --add github:o1-labs:eng mina-sdk

The existing CARGO_REGISTRY_TOKEN repo secret is no longer read; it
can be revoked once OIDC publishing has succeeded once, or kept as a
dormant emergency fallback (unused).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.

1 participant