Skip to content

Publish to nuget.org again, via Trusted Publishing - #21

Merged
Timmoth merged 3 commits into
mainfrom
docs/image-is-published
Nov 20, 2026
Merged

Timmoth merged 3 commits into
mainfrom
docs/image-is-published

Conversation

@Timmoth

@Timmoth Timmoth commented Nov 20, 2026 •

Copy link
Copy Markdown
Owner

GitHub Packages requires authentication even for a public package, so every consumer
needed a classic token and a configured feed just to install a testing library. This moves
publishing back to nuget.org, keyless.

How it works

The release job mints a GitHub OIDC token, NuGet/login@v1
exchanges it for an API key valid for one hour, and that key does the push. No API key is
stored anywhere. The exchange step sits immediately before the push, because each OIDC token
buys exactly one key and an early request only risks it expiring behind a slow build.

permissions:
  id-token: write          # mint the OIDC token

- uses: NuGet/login@v1
  id: login
  with:
    user: aptacode         # public; the nuget.org policy is what authorises the push

- run: dotnet nuget push "./artifacts/*.nupkg"
    --api-key ${{ steps.login.outputs.NUGET_API_KEY }}
    --source https://api.nuget.org/v3/index.json
    --skip-duplicate

The repository needs no secrets at all. The container image is unaffected and stays on
ghcr.io/timmoth/fortitude.

⚠️ This will not publish until the nuget.org policy exists

The policy lives on nuget.org, not in this repository. Under your username → Trusted
Publishing
, add a policy with:

Field Value
Repository Owner Timmoth
Repository Fortitude
Workflow File release.yml — the file name alone, no .github/workflows/ path
Environment leave empty — the workflow uses none

It must be owned by aptacode, the account that owns the package on nuget.org, and scoped
to allow publishing new versions of Fortitude. CONTRIBUTING.md carries all of this,
including the note that a policy on a private repo starts temporarily active for 7 days and
turns permanent on the first successful publish.

Docs are back to how they were

  • README badges are NuGet version + downloads again, and the install block is restored to its
    original shape — the Fortitude on NuGet link and # Install via the .NET CLI: comment
    included. The GHCR image badge stays, since the image did not move back.
  • The installation guide loses the token, the nuget.config and the per-tool feed setup for
    VS / VS Code / Rider — all of which existed only to work around GitHub Packages. Installing
    is dotnet add package Fortitude. There is a short note for teams behind a private mirror
    but no walkthrough; say the word if you want that material kept.
  • A note records that 10.1.4 and 10.2.0 live on GitHub Packages rather than nuget.org, so
    nobody goes looking in the wrong place, and the 10.2.0 changelog entry is marked
    superseded so its "authenticate to the feed" instruction does not mislead.

Also

Symbols return to .snupkg, which nuget.org's symbol server accepts — they had been
embedded in the assembly because GHCR has no symbol server. dotnet pack now emits
Fortitude.10.2.0.nupkg and Fortitude.10.2.0.snupkg; verified locally.

State of play

nuget.org currently has up to 10.1.2 (owner aptacode). 10.2.0 went to GitHub
Packages, so the next release here is a new version of an existing package, not a new
package — worth knowing when picking the policy scope.

Carried over from the first commit on this branch

The installation guide had said the GHCR image was not published yet. 10.2.0 is out, and I
verified it: pulled ghcr.io/timmoth/fortitude:v10.2.0 anonymously with no docker login,
ran it, /fortitude/health answered server running as UID 1654, and both linux/amd64 and
linux/arm64 are in the manifest.

Build is clean (0 warnings, warnings-as-errors) and all 506 tests pass.

The guide was written before any release had pushed to GHCR and said so.
10.2.0 is out, the package is public, and an anonymous `docker pull` of
ghcr.io/timmoth/fortitude:v10.2.0 works — verified by pulling it and checking
the health endpoint answers.
GitHub Packages requires authentication even for a public package, so every
consumer needed a classic token and a configured feed just to install a
testing library. That cost outweighed what the move bought.

The release workflow pushes to nuget.org without a stored API key. The job
mints a GitHub OIDC token, NuGet/login exchanges it for a key valid for one
hour, and that key does the push. The exchange step sits immediately before
the push because each token buys exactly one key and the key expires.

This depends on a Trusted Publishing policy configured on nuget.org naming
the repository owner, the repository and release.yml, owned by the account
that owns the package. CONTRIBUTING.md spells the fields out. The only
repository secret is NUGET_USER, the nuget.org profile name.

Symbol packages go back to .snupkg, which nuget.org's symbol server accepts;
they had been embedded in the assembly because GHCR has none.

Installing is plain `dotnet add package Fortitude` again, so the installation
guide loses the token, the nuget.config and the per-tool feed setup that only
existed to work around the GitHub Packages requirement. The image stays on
GHCR, which has no such problem.
@Timmoth Timmoth changed the title Correct the installation guide now 10.2.0 is published Publish to nuget.org again, via Trusted Publishing Nov 20, 2026
The nuget.org profile name is public and authorises nothing on its own - the
Trusted Publishing policy on nuget.org is what permits the push. Holding it
as a repository secret implied otherwise and left a release failing for a
missing value that was never confidential.

The repository now needs no secrets at all.

Also restores the README's install block to the shape it had before the move
off nuget.org, and marks the 10.2.0 changelog entry as superseded so a reader
of those notes is not told to authenticate to a feed that is no longer used.
@Timmoth
Timmoth merged commit 64d6d3f into main Nov 20, 2026
2 checks passed
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