Skip to content

Fix trusted publishing: match environment claim to nuget.org policy - #28

Merged
Sandoun merged 1 commit into
masterfrom
ci/nuget-trusted-publishing-env
Jul 25, 2026
Merged

Fix trusted publishing: match environment claim to nuget.org policy#28
Sandoun merged 1 commit into
masterfrom
ci/nuget-trusted-publishing-env

Conversation

@Sandoun

@Sandoun Sandoun commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Adds environment: production to the publish-package job in publish-pipeline.yml.

Why

The nuget.org trusted publishing policy for this repo was created with Environment: production. Per nuget.org's docs, when a policy specifies an environment, the GitHub Actions OIDC token must carry a matching environment claim, which only happens if the job declares environment: <name>. Without it, the token exchange at nuget.org/api/v2/token fails with a 401 — surfaced as "No matching trust policy owned by user '***' was found" — even when NUGET_USER is otherwise correct.

Also worth checking

The 401 error text specifically says to use "the username of the policy creator, not the policy owner." OpenLogics (the package/org owner) and Sandoun were both tried for NUGET_USER and failed — that secret needs to be the exact nuget.org account username of whoever created the policy, visible at https://www.nuget.org/account (top-right profile), not the org name or a guessed handle. This PR doesn't change that secret's value — worth re-verifying it once this environment fix is in.

Test plan

  • Confirm NUGET_USER secret is set to the exact nuget.org profile username of the policy creator.
  • Trigger publish-pipeline.yml via workflow_dispatch and confirm the NuGet.org push now succeeds.

🤖 Generated with Claude Code

The nuget.org trusted publishing policy was created with Environment
set to "production", which means the OIDC token issued to the job
must carry a matching environment claim. Without an `environment:`
key on the job, GitHub doesn't include that claim, so nuget.org's
token exchange fails with 401 "No matching trust policy owned by
user" even with a correct NUGET_USER value.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@Sandoun
Sandoun merged commit beb86e3 into master Jul 25, 2026
1 check passed
@Sandoun
Sandoun deleted the ci/nuget-trusted-publishing-env branch July 25, 2026 19:26
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