Skip to content

Switch NuGet.org publishing to Trusted Publishing (OIDC) - #835

Merged
Sergio0694 merged 1 commit into
mainfrom
sergio0694-nuget-trusted-publishing
Dec 4, 2026
Merged

Sergio0694 merged 1 commit into
mainfrom
sergio0694-nuget-trusted-publishing

Conversation

@Sergio0694

Copy link
Copy Markdown
Member

Agent assessment

Self-reported assessment, not an independent review.

Assessed revision: 3a1e5869a3bf05334cdece8fedb7834b39cdfe55

Dimension Assessment Rationale
Change confidence 8/10 ↑ Matches the NuGet trusted publishing docs; action pinned to the verified v1 commit SHA; NUGET_API_KEY output name confirmed in action source.
↑ Independent review found no blocking issues; workflow YAML parses.
↓ Not executed end-to-end: needs the NUGET_USER secret and a real release run.
↓ Tag-triggered runs being accepted by the nuget.org policy is unconfirmed from the docs.

Summary

Replaces the deprecated long-lived NUGET_PACKAGE_PUSH_TOKEN API key with NuGet Trusted Publishing in the release job of .github/workflows/build.yml:

  • Job-level permissions: id-token: write (+ contents: read).
  • New NuGet/login step (pinned to the v1 commit SHA) that exchanges the OIDC token for a short-lived API key, using secrets.NUGET_USER.
  • The push step now reads the key from steps.login.outputs.NUGET_API_KEY via env.

Azure DevOps feed pushes and the tooling/ submodule are untouched.

Before merging

  • Policy: confirm the nuget.org trusted publishing policy owner is the account that owns the CommunityToolkit.* packages, Workflow File is build.yml, Environment is nuget-release-gate (or empty), and the package scope allows new packages and new versions (Labs ships new package IDs often, including the winui 0 leg).
  • Secret: add a NUGET_USER secret (nuget.org profile name of the policy creator, not email; consider a shared/bot account) on the repo or the nuget-release-gate environment.
  • Refs: Labs publishes from tag refs (refs/tags/...) and rel/* branches, and each run uses the build.yml from its own ref, so backport this change to any active rel/* branches. Verify on the first run that tag-triggered runs are accepted by the policy (not confirmed from the docs). Note that creating a release with a new tag can fire both push: tags and release: published runs.
  • Cleanup: after one successful OIDC release push, delete the NUGET_PACKAGE_PUSH_TOKEN secret and revoke the PAT on nuget.org.
  • Optional validation: use a temporary branch job pushing an already-published .nupkg with --skip-duplicate.

Replace the NUGET_PACKAGE_PUSH_TOKEN API key secret with a short-lived key obtained via NuGet/login.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@Sergio0694
Sergio0694 marked this pull request as ready for review December 3, 2026 22:12
@michael-hawker

Copy link
Copy Markdown
Member

Seems pretty good, we should make sure the other maintainers know that this needs to be applied elsewhere. Looks like MAUI switched already. 😅

@Sergio0694
Sergio0694 merged commit 4004134 into main Dec 4, 2026
22 checks passed
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.

2 participants