Releasing the template
How a version of the Trellis.Templates package (the dotnet new trellis template) reaches
nuget.org, and its documentation reaches the website. Everything runs in
.github/workflows/release.yml, which deploys the site through
.github/workflows/site.yml; this page is what a maintainer does
around them. Generated projects ship neither workflow.
What the workflow does
Section titled “What the workflow does”prepare ──► test ─────────┐
└─► template ─────┴─► package ──────────────────────► publish (environment: nuget.org)
(matrix) pack, smoke test, attest, download the drafted package,
draft the GitHub release NuGet login, push, publish
│
└─► site: site.yml from the tag,
build, deploy to Pages| Job | Steps | Dry run |
|---|---|---|
prepare |
Resolve the version (from the tag, or on a branch from the version input or <Version> in eng/); fail unless the commit is on main; fail unless CHANGELOG. has a ## [X. section |
runs; "not on main" is a warning |
test |
dotnet build -c Release (warnings are errors) and every test, Aspire E2E included |
runs |
template |
the whole template-ci. matrix: every toggle leg instantiated and built in Release, and the legs flagged test: true tested, the Aspire E2E that boots the generated AppHost included (the browser tests stay opt-in); the default leg again on Windows; a project built from the packed template |
runs |
package |
pack with -p:Version=X., install the . and build an instance of it, attest its build provenance, create a draft GitHub release with the CHANGELOG section as notes and the . attached |
runs; the draft stays |
publish |
in the nuget. environment: download the . from the draft, log in to nuget.org by trusted publishing, push, publish the release |
runs up to the login; push and publish are skipped |
site |
site. with the tag: build the documentation site from the tagged commit (every link checked) and deploy it to GitHub Pages in the github-pages environment; every page's footer names the version |
skipped |
Nothing is public until publish: the package is attested and drafted first, the push happens
next, and the GitHub release is published only after the push succeeded. The site follows the
published release, so it never documents a version nuget.org does not have.
One-time setup
Section titled “One-time setup”-
nuget.org account. Sign in with the account (or organization) that owns, or will own, the
Trellis.Templatespackage id. -
Trusted publisher on nuget.org (no API key is stored anywhere). Under your account's Trusted Publishing page, add a GitHub Actions policy: repository owner
Revazi1st, repositoryTrellis, workflow filerelease.yml, environmentnuget.org. -
NUGET_USERrepository variable — the nuget.org profile name (not the e-mail) that owns the policy: Settings → Secrets and variables → Actions → Variables.NuGet/loginexchanges the workflow's OIDC token for a short-lived API key on behalf of that user. -
nuget.orgenvironment — Settings → Environments → New environment, named exactlynuget.org. Add yourself (or the release owners) as required reviewers, and limit deployments to themainbranch andv*tags (dry runs run onmain, releases on tags). -
A public repository (for attestation). Build-provenance attestations are available to public repositories on every plan; a private repository needs GitHub Enterprise Cloud. On any other private repository the
Attest build provenancestep is skipped with a warning and the release goes out unattested, sogh attestation verifyfinds nothing for that package. -
The
docs-not-neededandadr-rewritelabels. The CIDocs driftjob (scripts/check-docs-drift.sh) skips itself on a pull request carrying the first — the escape hatch for refactors that change no behaviour — and theADR historyjob (scripts/check-adr-history.sh) on one carrying the second, for an accepted ADR that truly needs a rewrite rather than an amendment. Create them once:gh label create docs-not-needed --description "No feature or threat-model doc change needed"andgh label create adr-rewrite --description "An accepted ADR is rewritten, not amended". -
Dependency bumps merge on their own.
.github/workflows/dependabot-auto-merge.ymlenables GitHub's auto-merge on Dependabot's patch and minor pull requests for NuGet packages, images and dev-container features. Four kinds wait for a person: a major, or a group that contains one; a .NET SDK bump (Dependabot calls a feature-band jump a patch, yet it raises the SDK everyone needs); every npm update, which here means the documentation site's (site/: Astro and Starlight are 0.x releases its build leans on, so read the notes and look at the site before merging); and the weekly GitHub Actions group, whose pull request edits workflow files, which the Actions token may never merge.dependabot.ymlholds every new version back for a week (cooldown; version updates only, a security update still arrives at once). Two repository settings make it work, both set once: Settings → General → Allow auto-merge (with Automatically delete head branches), and a ruleset onmainthat requires the CI, Template CI and CodeQL jobs, requires a pull request, gates on CodeQL alerts and forbids force-pushes and deletion (setrequire_extra_approval_for_unattributed_changesexplicitly: the API fills it in astruewhen omitted, and with no reviewers that blocks any commit whose author e-mail is not linked to a GitHub account). The workflow checks for both before it acts and only leaves a notice without them, becausegh pr merge --autoon an unprotected branch would merge at once. Two consequences to know: a merge made by the Actions token starts no push workflow onmain, and each weekly pull request was tested against themainof its own moment, soci.yml(template source only) andtemplate-ci.ymlalso run once a night onmainto test the combined tree. -
GitHub Pages, for the documentation site (https://revazi1st.github.io/Trellis/). Two settings only the repository's owner can make:
- Settings → Pages → Build and deployment → Source: GitHub Actions. This also creates the
github-pagesenvironment. - Settings → Environments →
github-pages→ Deployment branches and tags: keepmainand add a tag rule,v*. A release deploys from its tag, and the environment GitHub creates allows only the default branch, so without the rule the release'ssitejob fails withTag "vX.Y.Z" is not allowed to deploy to github-pages due to environment protection rules.(a preview dispatched on another branch fails the same way:Branch "<name>" is not allowed to deploy to github-pages due to environment protection rules.). A preview started onmainis allowed already, whatever ref it builds.
Then require the
Build and validatejob ofsite.ymlonmain's ruleset beside the CI jobs: it runs on every pull request and builds the site only when the pull request touches what the site renders, passing (as skipped) otherwise. - Settings → Pages → Build and deployment → Source: GitHub Actions. This also creates the
Before a minor release: an agent dry run
Section titled “Before a minor release: an agent dry run”The template's guidance (AGENTS.md, the rules, the skills) is code for agents, and it drifts like
code. Before a minor version, pack the release candidate, generate a fresh project from it into a
private hive (dotnet new install <nupkg> --debug:custom-hive <dir>), and give an agent one fixed
feature spec (keep the same one from release to release, for example a Customer with a unique e-mail
that can be created, renamed and deactivated, which members may list) and nothing but the generated
repository. Judge the result by the gates that already exist: the Release build, the whole test suite
with the architecture tests, scripts/check-docs-drift.sh and the OpenAPI snapshot. Then read the diff
for what no gate sees: the rule in the aggregate rather than the handler, the feature doc written first,
the shapes from the add-feature skill's "not shown" list handled the way it points. Each miss becomes
a fix to a rule, a skill box or a test in the release, never a note to the agent. One run is anecdote,
and results vary between models and attempts: it is a smoke test of the guidance, not a score. The
agent finishes the way a generated project's agent is told to, with /finish-change, so the run puts
that skill's gates and reviewers to the test as well.
The harness decides what the run can show, so set it up for the template's own configuration to govern:
- Trust the generated folder before the launch. A
claude -prun in a folder nobody trusted ignores the project's.claude/settings.jsonallow rules (stderr saysIgnoring N permissions.allow entries … this workspace has not been trusted), so the harness's--allowedToolslist stands in for the template's, and a command the template forgot to allow never shows as a denial. Setprojects["<the generated folder>"].hasTrustDialogAcceptedtotruein~/.claude.jsonfirst, and keep only the harness's own additions on its command line. - Record the hooks. Run with
--output-format stream-json --verbose --include-hook-events: without the last flag the stream carries no PreToolUse, PostToolUse or Stop hook output, and the judge cannot see what a hook decided or reminded. - Judge the tree as generated, and the change as finished. Before the agent starts,
dotnet format <name>.slnx --verify-no-changes --severity warnon the generated tree must pass (a failure there is the template's, whatever the agent does next); after the finishing commit,scripts/check-docs-drift.sh <the generation commit>reads the agent's whole change against the generation, beside the gates above. - On a usage limit, resume the same session (
claude -p --resume <session id>) rather than committing the work in progress onmainand starting over: the new session loses the reviewers' findings, and the judge can no longer tell the operator's commit from the agent's.
Cutting a release
Section titled “Cutting a release”- Pick the version. First read the dependency bumps that merged on their own since the last
tag (
git log vPREV..main --oneline --author=dependabot); they are part of what ships. SemVer: a breaking change to generated output or to a toggle's meaning is a major bump (a minor bump while below 1.0), a new toggle or feature a minor bump, a fix a patch. A pre-release (X.Y.Z-rc.1) is published as a GitHub pre-release. - Write the release notes. In a pull request to
main, move the entries under## [Unreleased]inCHANGELOG.mdinto a new## [X.Y.Z] - YYYY-MM-DDsection (Keep a Changelog), written for template consumers. The section becomes the GitHub release notes verbatim. Merge once CI is green. - Dry run. Actions → Release → Run workflow on
main,dry_runticked,versionX.Y.Z — orgh workflow run release.yml --ref main -f dry_run=true -f version=X.Y.Z. Approve thenuget.orgenvironment when it asks. Then check the run is green, the draft release's notes and attached.nupkg, and the provenance:gh attestation verify Trellis.Templates.X.Y.Z.nupkg --repo Revazi1st/Trellis(download the asset from the draft first). - Tag and push. Tag the
maincommit the dry run used, annotated:git tag -a vX.Y.Z -m "vX.Y.Z" <sha>thengit push origin vX.Y.Z. The push starts the real run; approve thenuget.orgenvironment whenpublishreaches it. The run replaces the dry run's draft with its own. - Verify. The GitHub release is published; the package page
(https://www.nuget.org/packages/Trellis.Templates) shows X.Y.Z once nuget.org has indexed it
(minutes), with a Release Notes link to that GitHub release (
PackageReleaseNotesin the pack project, built from the version); it installs:dotnet new install Trellis.Templates::X.Y.Z --debug:custom-hive "$(mktemp -d)"; and https://revazi1st.github.io/Trellis/ has no preview banner and namesTrellis.Templates X.Y.Zin every page's footer.
The documentation site
Section titled “The documentation site”The site is site/ (see its README): Astro and Starlight rendering docs/ in place. GitHub Pages
holds one copy of it, and three things replace that copy:
- A release: the
sitejob above, from the tag. - A preview:
gh workflow run site.yml -f ref=main(any branch, tag or SHA; the default ismain). It builds that ref and deploys it in place of the released site, with a banner on every page saying it is a preview of that ref and commit and not the released documentation (before the first release: thatTrellis.Templatesis not on nuget.org yet). Put the release back afterwards withgh workflow run site.yml -f ref=vX.Y.Z, which rebuilds it from its tag, no banner. - A fix to the site itself after a release (a page that renders wrong, a broken style): merge it
to
main, thengh workflow run site.yml -f ref=vX.Y.Z -f site_ref=main. The docs still come from the tag andsite/frommain, so the release's documentation stays the release's. A fix todocs/is documentation of the next version and ships with it.
Pull requests that touch docs/, site/, README.md, .template.config/, global.json,
eng/readme/ or a source file a site page quotes run the same build without deploying it: a link or
an #anchor that points nowhere fails it.
When something fails
Section titled “When something fails”- Before
publish: nothing is public. Fix the cause onmain; if the fix changes the tagged commit, delete the tag (git push --delete origin vX.Y.Z,git tag -d vX.Y.Z) and tag the new commit. Re-running replaces a leftover draft for the tag; a published release is never touched. - CHANGELOG gate: the tag points at a commit without the
## [X.Y.Z]section — merge the notes, then re-tag as above. - NuGet login:
NUGET_USERis unset or not the policy owner's profile name, or the policy's repository, workflow file or environment does not match this run exactly. - Push succeeded, publish failed: re-run the
publishjob (the push uses--skip-duplicate) or publish by hand withgh release edit vX.Y.Z --draft=false. - A bad version reached nuget.org: versions cannot be deleted or replaced. Unlist it on nuget.org and release a patch.
- The
sitejob failed withTag "vX.Y.Z" is not allowed to deploy to github-pages: add thev*tag rule (one-time setup, step 8), then re-run the failed job, or rungh workflow run site.yml -f ref=vX.Y.Z. The package and the release are already public; only the site waits. Any other failure of the build is a link or a page to fix: fix it onmainand redeploy with-f site_ref=mainas above.
The documentation of Trellis.Templates 0.2.0 · release notes