Use trusted publishing for NuGet release#3261
Open
jfversluis wants to merge 2 commits into
Open
Conversation
Switch the NuGet.org release workflow from the long-lived package push token to NuGet trusted publishing via OIDC login. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Updates the NuGet.org release workflow to use NuGet trusted publishing (OIDC) instead of a long-lived NuGet API key, aligning the repo’s publish path with modern, short-lived credential practices.
Changes:
- Grants
release-nugetjob OIDC-capable permissions and adds a NuGet OIDC login step (NuGet/login@v1). - Switches
dotnet nuget pushto use the short-lived API key output from the login step instead ofsecrets.NUGET_PACKAGE_PUSH_TOKEN.
Show a summary per file
| File | Description |
|---|---|
| .github/workflows/dotnet-build.yml | Moves NuGet.org publishing to trusted publishing via OIDC login and short-lived API key output. |
Review details
- Files reviewed: 1/1 changed files
- Comments generated: 1
- Review effort level: Low
Comment on lines
+385
to
+387
| permissions: | ||
| id-token: write | ||
| contents: read |
Keep the trusted publishing action pinned by commit SHA like the other workflow actions in this repo. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of Change
This moves the NuGet.org release job (
release-nugetin.github/workflows/dotnet-build.yml) to NuGet trusted publishing, matching the approach from CommunityToolkit/Aspire#1452:id-token: writeandcontents: readNuGet/login@v1${{ steps.login.outputs.NUGET_API_KEY }}instead of the long-lived${{ secrets.NUGET_PACKAGE_PUSH_TOKEN }}This repo was not already using trusted publishing for the NuGet.org publish path; the signing job requested an OIDC token, but the
release-nugetjob still pushed with the long-lived NuGet API key.Reviewers should note that this workflow change also requires external configuration before the first trusted-publishing release can succeed:
NUGET_USERsecret to thenuget-release-gateGitHub environment. The value should be the nuget.org profile/owner used for the trusted publishing policy, not an email address.Microsoft.Toolkitanddotnetfoundation, so the policy andNUGET_USERsecret should use whichever of those nuget.org owners is intended to publish these packages.CommunityToolkit, repositoryMaui, workflow filedotnet-build.yml, and environmentnuget-release-gate.Linked Issues
PR Checklist
approved(bug) orChampioned(feature/proposal) - N/A, workflow infrastructure changemainat time of PRAdditional information
No product code changes; this only updates the NuGet.org release publishing workflow.