ci(nuget): switch publishing to NuGet.org Trusted Publishing - #94
Conversation
Replace the long-lived NUGET_API_KEY repository secret with OIDC-based Trusted Publishing, so no durable credential is stored in GitHub. - Grant the workflow `id-token: write` so GitHub can issue an OIDC token. - Add a `NuGet/login@v1` step immediately before the push. The temporary API key nuget.org returns is valid for one hour and single-use, so it is requested after build/test/pack rather than at the top of the job. - Feed the push from `steps.nuget-login.outputs.NUGET_API_KEY` and replace the old "secret not configured" guard with a checklist that points at the likely policy mismatch when the token exchange yields no key. The nuget.org policy is bound to this workflow's file name, so renaming publish-nuget.yml requires updating the policy as well. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Reviewer's GuideThe workflow for publishing NuGet packages has been migrated from using a long-lived NuGet.org API key secret to NuGet.org Trusted Publishing via GitHub OIDC, introducing a NuGet/login step, updating permissions, and adjusting the publish step’s key handling and failure diagnostics. Sequence diagram for NuGet Trusted Publishing workflowsequenceDiagram
participant Workflow
participant NuGet_login
participant NuGet_org
participant Publish_step
Workflow->>Workflow: id-token: write permission
Workflow->>NuGet_login: run NuGet/login@v1 with user secrets.NUGET_USER
NuGet_login->>NuGet_org: exchange OIDC token for short-lived API key
NuGet_org-->>NuGet_login: NUGET_API_KEY
NuGet_login-->>Workflow: outputs.NUGET_API_KEY
Workflow->>Publish_step: env NUGET_API_KEY=steps.nuget-login.outputs.NUGET_API_KEY
Publish_step->>Publish_step: check [ -z "$NUGET_API_KEY" ]
alt NUGET_API_KEY empty
Publish_step->>Publish_step: print Trusted Publishing checklist
Publish_step->>Publish_step: exit 1
else NUGET_API_KEY present
Publish_step->>NuGet_org: publish packages to NuGet.org
end
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
Warning Review limit reached
Next review available in: 98 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 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 configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
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 |
|




What changed
publish-nuget.ymlnow authenticates to NuGet.org via Trusted Publishing (OIDC) instead of a long-lived API key secret.id-token: writeto the workflowpermissionsso GitHub can issue an OIDC token.NuGet/login@v1step that exchanges that token for a short-lived nuget.org API key.steps.nuget-login.outputs.NUGET_API_KEYinstead ofsecrets.NUGET_API_KEY.Why
No durable publishing credential is stored in GitHub anymore, so there is nothing to rotate and nothing to leak. This follows the NuGet Trusted Publishing docs.
Reviewer notes
publish-nuget.ymlwill break publishing until the policy is updated. The policy's Workflow File field must be exactlypublish-nuget.yml, with no.github/workflows/prefix.environment:, so the policy's Environment field must be left empty.Required before the next release
NUGET_USERrepository secret containing the nuget.org profile name (not the e-mail address). This is the valueNuGet/loginsends during the token exchange; the docs recommend a secret over hardcoding.burgan-tech/aether/publish-nuget.yml.NUGET_API_KEYsecret can be deleted. No other reference to it remains in the repo.For private repositories a new policy starts temporarily active for 7 days and goes inactive if no publish happens in that window, so the first release should run within a week of the policy being created.
Testing
Not exercised end-to-end — this workflow only runs on
release-v*branches, so the OIDC exchange is first verified by the next real release run. TheNUGET_USERsecret must be in place before that.🤖 Generated with Claude Code
Summary by Sourcery
Switch NuGet publishing workflow to use NuGet.org Trusted Publishing via OIDC-issued short-lived API keys instead of a stored API key secret.
CI: