Skip to content

ci: publish via NuGet Trusted Publishing (keyless OIDC) - #2

Merged
Pijukatel merged 1 commit into
masterfrom
claude/fervent-allen-bp8pcw
Jul 7, 2026
Merged

ci: publish via NuGet Trusted Publishing (keyless OIDC)#2
Pijukatel merged 1 commit into
masterfrom
claude/fervent-allen-bp8pcw

Conversation

@Pijukatel

@Pijukatel Pijukatel commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator

What

Converts the manual NuGet publish workflow (.github/workflows/dotnet-publish.yml) from a long-lived NUGET_API_KEY secret to NuGet.org Trusted Publishing (keyless OIDC).

Changes

  • Job permissions: added id-token: write (kept contents: write for the tagged release); permissions moved to the publish job scope.
  • Keyless auth: replaced the NUGET_API_KEY secret flow with a NuGet/login@v1 step (user: ${{ secrets.NUGET_USER }}) that exchanges the GitHub OIDC token for a short-lived (1 h) key. The step runs immediately before the push so the key does not expire.
  • Push: dotnet nuget push ... --api-key ${{ steps.login.outputs.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json (kept --skip-duplicate).
  • Guard: the "Require NUGET_API_KEY secret" step is replaced by a "Require NUGET_USER secret" guard whose error message also points at the required nuget.org policy and the docs.
  • Header comment: the outdated rationale ("Trusted Publishing not used because it isn't GA / not supported") is removed and replaced with a description of the OIDC flow and the required nuget.org policy.
  • CHANGELOG: the 0.1.0 publishing line is corrected to describe Trusted Publishing. No version bump — v0.1.0 is unreleased and the public library API is unchanged (CI-only change).

All other behavior is preserved: workflow_dispatch-only trigger, dry_run input, concurrency group, master-branch gate, .NET setup, restore/format/build/unit-test gates, version resolution from csproj, tag-existence check, pack, tag creation, and GitHub release.

Operator prerequisite (before first release)

A Trusted Publishing policy must be registered on nuget.org for this repo/workflow (Workflow File = dotnet-publish.yml) and the NUGET_USER repo secret set to the nuget.org profile name (not an email). Both are enforced at run time (guard + login step), so a misconfigured release fails fast.

Scope

Targeted change to the publish workflow only. The client is already synced to spec v2-2026-07-02T131926Z; no endpoint/test/doc regeneration. No sibling-client changes — Trusted Publishing is nuget.org-specific.

Replace the long-lived NUGET_API_KEY secret with NuGet.org Trusted
Publishing per the official docs. The publish job now requests a GitHub
OIDC token (id-token: write) and NuGet/login@v1 exchanges it for a
short-lived (1 h) API key used by dotnet nuget push. The only secret
needed is NUGET_USER (the nuget.org profile name). The old
"Require NUGET_API_KEY secret" guard is replaced by a NUGET_USER guard,
and the header comment's outdated "not GA / not supported" rationale is
removed. All other behavior (master gate, version resolution, tag check,
pack, dry_run, tag + GitHub release) is preserved. CHANGELOG updated.
@Pijukatel
Pijukatel force-pushed the claude/fervent-allen-bp8pcw branch from d5e23bb to 435042d Compare July 7, 2026 09:36
@Pijukatel
Pijukatel merged commit b09d7d1 into master Jul 7, 2026
1 check passed
@Pijukatel
Pijukatel deleted the claude/fervent-allen-bp8pcw branch July 8, 2026 09:45
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