Skip to content

ci(sdk): publish to NuGet with trusted publishing (OIDC), not the static API key - #131

Merged
nikoraes merged 1 commit into
mainfrom
ci/nuget-trusted-publishing
Dec 2, 2026
Merged

nikoraes merged 1 commit into
mainfrom
ci/nuget-trusted-publishing

Conversation

@nikoraes

@nikoraes nikoraes commented Dec 2, 2026

Copy link
Copy Markdown
Member

Why the SDK has not published since 1.30.0

The trust policy on nuget.org was never invoked. build-release-sdk.yml on main contains no NuGet/login step and no id-token: write permission — a repo-wide code search for id-token and NuGet/login returns 0 hits. Every release therefore pushed with secrets.NUGET_API_KEY:

run: dotnet nuget push "*.nupkg" --api-key ${{secrets.NUGET_API_KEY}} --source https://api.nuget.org/v3/index.json

That key was set 2026-05-29 and now answers 403 The specified API key has expired, so Konnektr.AgeDigitalTwins stops at 1.30.0 while 1.30.1 and 1.31.0 shipped images only. A trust policy with no token request is inert — nothing was misconfigured on nuget.org, the workflow just never asked.

The change

permissions:
  contents: read
  id-token: write
...
- name: NuGet login (OIDC trusted publishing)
  if: github.event_name == 'release'
  id: login
  uses: NuGet/login@v1
  with:
    user: ${{ vars.NUGET_USER }}

- name: Push to NuGet
  run: dotnet nuget push "*.nupkg" --api-key ${{steps.login.outputs.NUGET_API_KEY}} ...

vars.NUGET_USER (set to nikoraes) must be the nuget.org profile of the trust-policy creator, not the owning org Konnektr — the login step rejects the org with "No matching trust policy owned by user '…' was found". The minted key is valid for one hour and single-use, so the login sits immediately before the push; Build/Pack stay unauthenticated.

Verification

This is a release-triggered workflow, so a fix on main does not apply to an existing release: the release event runs the workflow from the tag's tree. After merging, v1.31.0's tag is re-cut onto this commit (safe: 1.31.0 was never published to NuGet, and a workflow file is not inside the .nupkg) so the release run picks up the login step. Expected: NuGet login green → Push to NuGet green → 1.31.0 resolvable on the flat-container index.

If the trust policy names a different workflow file than build-release-sdk.yml, the login step fails 401 and names the mismatch — I will report that rather than guess.

— Hermes

…tic API key

The trust policy on nuget.org was never used: build-release-sdk.yml had no
`id-token: write` permission and no NuGet/login step, so every release pushed with
`secrets.NUGET_API_KEY` — a key created 2026-05-29 that now returns
403 "The specified API key has expired". Konnektr.AgeDigitalTwins has therefore not
been published since 1.30.0 (1.30.1 and 1.31.0 shipped images but no package).

Mint a short-lived key from the GitHub OIDC token instead. `user` comes from the
repo variable NUGET_USER (the profile of the trust-policy creator, not the owning
org, which the login step rejects).

Refs #129

Co-authored-by: Hermes Agent <hermes@nikoraes.local>
@nikoraes
nikoraes merged commit 5186173 into main Dec 2, 2026
5 checks passed
@nikoraes
nikoraes deleted the ci/nuget-trusted-publishing branch December 2, 2026 14:20
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