Skip to content

Use NuGet trusted publishing (OIDC) instead of a long-lived API key - #389

Open
zidad wants to merge 1 commit into
masterfrom
chore/nuget-trusted-publishing
Open

Use NuGet trusted publishing (OIDC) instead of a long-lived API key#389
zidad wants to merge 1 commit into
masterfrom
chore/nuget-trusted-publishing

Conversation

@zidad

@zidad zidad commented Aug 5, 2026

Copy link
Copy Markdown
Member

Switches NuGet publishing from the long-lived NUGET_TOKEN secret to trusted publishing (OIDC).

The publish-to-nuget job now exchanges the GitHub Actions OIDC token for a short-lived (1 hour) nuget.org API key via NuGet/login@v1, scoped to the EasyNetQ organization account rather than an individual profile.

Changes

  • id-token: write permission on the publish job so GitHub issues the OIDC token
  • environment: release so the trusted publishing policy can be pinned to it, and so a manual approval gate can be added later
  • NuGet/login@v1 step with user: EasyNetQ (must match the policy's package owner)
  • dotnet nuget push uses steps.nuget-login.outputs.NUGET_API_KEY instead of secrets.NUGET_TOKEN

Required setup before merging

On nuget.org (signed in as an EasyNetQ org member) — username menu -> Trusted Publishing -> add a policy:

Field Value
Package Owner EasyNetQ (the organization, not a personal account)
Repository Owner EasyNetQ
Repository EasyNetQ.Management.Client
Workflow File ci.yml
Environment release

On GitHub — done: the release environment has been created (no protection rules). Optionally add required reviewers or a tag-only deployment branch rule for a manual gate before publish.

Keep NUGET_TOKEN until the first tagged release publishes successfully, then delete the secret.

Notes

  • The policy is bound to the org member who creates it — if that account leaves the EasyNetQ org, the policy goes inactive until they are re-added.
  • The policy applies to all packages owned by the EasyNetQ org, not just those built here.

Exchange the GitHub Actions OIDC token for a short-lived nuget.org API key
via NuGet/login, scoped to the EasyNetQ organization. Removes the need for
the NUGET_TOKEN secret.

The publish job now runs in the 'release' environment so the trusted
publishing policy can be pinned to it.
@kilo-code-bot

kilo-code-bot Bot commented Aug 5, 2026

Copy link
Copy Markdown

Kilo Code Review could not run — your account is out of credits.

Add credits or switch to a free model to enable reviews on this change.

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