Skip to content

Publish to NuGet with Trusted Publishing - #14

Merged
muhammetsafak merged 3 commits into
mainfrom
ci/nuget-trusted-publishing
Nov 4, 2026
Merged

muhammetsafak merged 3 commits into
mainfrom
ci/nuget-trusted-publishing

Conversation

@muhammetsafak

Copy link
Copy Markdown
Member

Replaces the long-lived NUGET_API_KEY secret with NuGet Trusted Publishing: the NuGet/login action exchanges a GitHub OIDC token for a short-lived API key.

  • The NuGet push moves to its own publish job; id-token: write is granted only there and in the new verify-trusted-publishing job. Workflow-level permissions drop to contents: read.
  • .nupkg and .snupkg files reach the publish job as a build artifact.
  • A manual workflow_dispatch run only checks that the Trusted Publishing login works; it never packs, pushes or creates a release.

Replace the long-lived NUGET_API_KEY secret with a short-lived key issued by NuGet/login@v1 over GitHub OIDC. Add a workflow_dispatch dry run (verify-trusted-publishing job) that only exercises the login, so the nuget.org policy can be verified without publishing a version.
Build, test and pack now run with read-only permissions and no OIDC token. The .nupkg files (and the conformance results asset where used) are handed over as artifacts to a separate publish job that needs the build job and alone holds id-token: write and contents: write for NuGet/login, the push and the GitHub release. The dry-run job only gets id-token: write.
All csproj files emit a .snupkg next to the .nupkg, and dotnet nuget push picks up the sibling symbol package. Upload both globs so the publish job pushes the same set the old single job did.
@muhammetsafak
muhammetsafak merged commit aea857e into main Nov 4, 2026
7 checks passed
@muhammetsafak
muhammetsafak deleted the ci/nuget-trusted-publishing branch November 4, 2026 17:57
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