Skip to content

Publish NuGet packages via Trusted Publishing - #97

Merged
ademar merged 1 commit into
masterfrom
nuget-publish
Aug 23, 2026
Merged

Publish NuGet packages via Trusted Publishing#97
ademar merged 1 commit into
masterfrom
nuget-publish

Conversation

@ademar

@ademar ademar commented Aug 23, 2026

Copy link
Copy Markdown
Member

Publishes IronKernel.Tool and IronKernel.Sdk to NuGet.org via Trusted Publishing — no long-lived API key anywhere, superseding the earlier NUGET_API_KEY-secret design at the owner's request.

One workflow is the only pusher (nuget-publish.yml), because a trusted-publishing policy pins a single workflow file. It runs two ways:

  • Automatically via workflow_run when a Release workflow run completes successfully (a tag-triggered run's head branch is the tag) — so every future v* release publishes itself.
  • Manually via workflow_dispatch with a tag input — for releases cut before the policy existed (v0.6.0) or retries.

Mechanics: permissions: id-token: write; NuGet/login@v1 exchanges the GitHub OIDC token for a one-hour API key just before the push; dotnet nuget push --skip-duplicate keeps re-runs idempotent. The user: ademar input is the nuget.org profile name — public on the package pages; the policy, not the name, gates publishing. release.yml is untouched.

One-time setup on nuget.org (owner only)

Sign in → username menu → Trusted Publishing → add a policy:

Field Value
Repository Owner ironkernel-lang
Repository IronKernel
Workflow File nuget-publish.yml (file name only)
Environment leave empty

Public repo, so the policy should be fully active immediately (the 7-day pending window mainly applies to private repos, and the first successful publish locks the policy to the repo IDs either way).

Publishing 0.6.0

After merging and adding the policy:

gh workflow run nuget-publish.yml -f tag=v0.6.0

One workflow, nuget-publish.yml, is the only path to nuget.org --
Trusted Publishing pins a policy to a single workflow file, so both
routes go through it: automatically when a Release run completes
successfully (the tag is the run's head branch), and manually by tag
for releases cut before the policy existed or for retries.

No long-lived API key anywhere: the job exchanges a GitHub OIDC token
for a one-hour key via NuGet/login, and --skip-duplicate keeps re-runs
idempotent. The nuget.org profile name in the workflow is public on
the package pages; the policy is what gates publishing.
@ademar ademar changed the title Publish NuGet packages from CI Publish NuGet packages via Trusted Publishing Aug 23, 2026
@ademar
ademar merged commit 6f238e4 into master Aug 23, 2026
2 checks passed
@ademar
ademar deleted the nuget-publish branch August 23, 2026 15:53
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