publish.yaml: switch to crates.io trusted publishing (OIDC)#128
Conversation
All four crates (hypersync-format, hypersync-schema, hypersync-net-types, hypersync-client) now have this repo + publish.yaml configured as a Trusted Publisher on crates.io. This commit updates the workflow to: - Request `id-token: write` permission so GitHub Actions issues the OIDC token the auth action exchanges for a temporary crates.io API token. `contents: write` is retained because this workflow still creates a git tag and a GitHub release. - Run rust-lang/crates-io-auth-action@v1 instead of relying on the long-lived CARGO_REGISTRY_TOKEN secret. - Drop the unused VERBOSE env var. After this PR merges, the CARGO_REGISTRY_TOKEN repo/org secret can be deleted - trusted publishing supersedes it. No GitHub environment is required by the trusted publisher config; one can be added later by setting it in both the crates.io publisher settings and as `environment:` on this job, if reviewer approval on publishes becomes desired. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
📝 WalkthroughWalkthroughThe workflow's crates publishing job was updated to authenticate with crates.io using ChangesCrates.io Authentication
🎯 1 (Trivial) | ⏱️ ~3 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.github/workflows/publish.yaml:
- Line 68: Replace the mutable tag for the crates auth action with an immutable
commit SHA: find the uses: rust-lang/crates-io-auth-action@v1 entry and change
it to uses: rust-lang/crates-io-auth-action@<full-commit-sha> where
<full-commit-sha> is the exact 40-character commit hash from the action
repository (pick the desired release commit) so the workflow references a
pinned, immutable revision instead of the v1 tag.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: f808f021-fca5-45c4-8b0b-a900e022a492
📒 Files selected for processing (1)
.github/workflows/publish.yaml
|
|
||
| - name: Authenticate with crates.io | ||
| id: auth | ||
| uses: rust-lang/crates-io-auth-action@v1 |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Verify mutable action refs still exist in workflow files.
rg -nP '^\s*uses:\s*[^@\s]+@(v?\d+(\.\d+){0,2}|main|master)$' .github/workflowsRepository: enviodev/hypersync-client-rust
Length of output: 157
Pin the auth action to a full commit SHA.
Line 68 uses a mutable tag (rust-lang/crates-io-auth-action@v1). Pinning to an immutable commit SHA reduces supply-chain risk for the publish path.
Suggested hardening change
- - name: Authenticate with crates.io
- id: auth
- uses: rust-lang/crates-io-auth-action@v1
+ - name: Authenticate with crates.io
+ id: auth
+ uses: rust-lang/crates-io-auth-action@<FULL_COMMIT_SHA>🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In @.github/workflows/publish.yaml at line 68, Replace the mutable tag for the
crates auth action with an immutable commit SHA: find the uses:
rust-lang/crates-io-auth-action@v1 entry and change it to uses:
rust-lang/crates-io-auth-action@<full-commit-sha> where <full-commit-sha> is the
exact 40-character commit hash from the action repository (pick the desired
release commit) so the workflow references a pinned, immutable revision instead
of the v1 tag.
Summary
Switches the crates.io publish workflow from a long-lived
CARGO_REGISTRY_TOKENsecret to OIDC-based trusted publishing.All four crates owned by
JasoonSand published from this repo now have a trusted publisher configured on crates.io pointing atenviodev/hypersync-client-rust+.github/workflows/publish.yaml:hypersync-formathypersync-schemahypersync-net-typeshypersync-clientChanges
id-token: writetopermissions:so GitHub Actions issues the OIDC token.contents: writeis retained because this workflow still creates a git tag and a GitHub release.rust-lang/crates-io-auth-action@v1step (id: auth) before the publish step.CARGO_REGISTRY_TOKENfor the publish step from${{ steps.auth.outputs.token }}instead of${{ secrets.CARGO_REGISTRY_TOKEN }}.VERBOSE: trueenv var.Other parts of the workflow (version check, tag/release creation, the capnproto apt install needed by
hypersync-net-types'sbuild.rs) are preserved unchanged.Follow-up
Once a publish run on this branch (or after merge) succeeds via OIDC, the
CARGO_REGISTRY_TOKENrepo/org secret can be deleted; trusted publishing supersedes it.No GitHub Actions environment is required by the trusted publisher config. One can be added later (set it both in the crates.io publisher settings and as
environment:on this job) if reviewer-approved publishes become desired.Test plan
hypersync-formatafter a version bump) and confirm the OIDC auth step succeeds and the publish completes.CARGO_REGISTRY_TOKENsecret.Co-Authored-By: Claude Opus 4.7 (1M context) noreply@anthropic.com
Summary by CodeRabbit