Publish NuGet packages via Trusted Publishing - #97
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Publishes
IronKernel.ToolandIronKernel.Sdkto NuGet.org via Trusted Publishing — no long-lived API key anywhere, superseding the earlierNUGET_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:workflow_runwhen a Release workflow run completes successfully (a tag-triggered run's head branch is the tag) — so every futurev*release publishes itself.workflow_dispatchwith ataginput — for releases cut before the policy existed (v0.6.0) or retries.Mechanics:
permissions: id-token: write;NuGet/login@v1exchanges the GitHub OIDC token for a one-hour API key just before the push;dotnet nuget push --skip-duplicatekeeps re-runs idempotent. Theuser: ademarinput is the nuget.org profile name — public on the package pages; the policy, not the name, gates publishing.release.ymlis untouched.One-time setup on nuget.org (owner only)
Sign in → username menu → Trusted Publishing → add a policy:
ironkernel-langIronKernelnuget-publish.yml(file name only)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: