ADR 0011 · Code and packages
Publish packages from CI with NuGet trusted publishing
Pushing a version tag on main builds, tests and publishes every TickerNet package to NuGet from GitHub Actions. The workflow gets a short-lived NuGet key through trusted publishing, so no API key is stored anywhere.
01
Context
TickerNet's packages weren't on NuGet. ADR 0005 removed TickerQ's publishing workflow, which used upstream secrets. A release process should be repeatable, should publish only tested code from main, and shouldn't depend on a long-lived API key that can leak or expire. The TickerNet. package ID prefix also needs protecting, as the pledge in GOVERNANCE.md promises.
02
Decision
.github/workflows/release.yamlruns when a tagvMAJOR.MINOR.PATCHorvMAJOR.MINOR.PATCH-labelis pushed. It refuses a tag that isn't onmain. It builds the dashboard and every package with the tag's version, runs every test, packs, checks that all 9 packages are there, publishes them to nuget.org, and creates a GitHub release with the packages attached. A tag with a label (for example-preview.2) makes a prerelease.- Publishing uses NuGet trusted publishing: the workflow trades GitHub's OIDC token for a short-lived NuGet API key with
NuGet/login. The policy on nuget.org names this repository,release.yamland thenugetenvironment. The repository variableNUGET_USERnames the nuget.org account that owns the policy. No NuGet key is stored in GitHub. - The job runs in the
nugetGitHub environment, which onlyv*tags can deploy to. - The tag sets the version;
Versioninsrc/Directory.Build.propsis the default for local builds. - Every package carries the TickerNet icon (
assets/tickernet-icon.png) and a README written for nuget.org: absolute links, no images or GitHub-only markup. The core package usessrc/TickerNet/README.mdinstead of the repository README. - The source generator is never packed on its own (
IsPackableis false); it ships inside theTickerNetpackage. - The
TickerNet.ID prefix is reserved on nuget.org for the account that publishes.
03
Alternatives considered
- A NuGet API key in a repository secret. Rejected: a long-lived key can leak through a workflow change and has to be rotated by hand.
- Publishing from a maintainer's machine. Rejected: not repeatable, and it skips the tests and the check that the code is on
main. - Publishing on every push to
main. Rejected: releases should be deliberate, with a chosen version.
04
Consequences
- Before the first release, a maintainer sets up the nuget.org account, the trusted publishing policy, the
NUGET_USERvariable and the prefix reservation (CONTRIBUTING.md, Releasing). Until then a tag fails at the setup check, before anything is published. - Adding or removing a package means updating the package count check in
release.yaml. - Anyone who can push a
v*tag for a commit onmaincan publish, so tag rights are release rights.
05
Where it lives
.github/workflows/release.yamlsrc/Directory.Build.props(icon),src/TickerNet.SourceGenerator/TickerNet.SourceGenerator.csproj(not packable)src/TickerNet/README.md,src/TickerNet.Caching.StackExchangeRedis/README.mdand the other package READMEsassets/tickernet-icon.pngCONTRIBUTING.md, Releasing
06