Night 24 · Christmas Eve: Sign Off
📺 "It's Christmas Eve, and every guest we have is out in the snow tonight. You've built the studio, the cameras and the calendar on the wall, and there is one job left: to send the whole programme out to people who have never heard of cargo. Coats on. We'll do it properly, and then I shall say good night."
Tonight you'll learn
- A changelog written for players, with git-cliff to check nothing was missed
- Where the version number lives, and what has to follow it
- cargo-dist: archives, installers and a Homebrew formula from a few lines of TOML
- Why a tag, not a merge, makes a release
- A library and a binary in one package, and a workspace with a second crate
- How to rename the project and make it yours
Where we are: the program is finished, documented and checked on three operating systems. Tonight it leaves the building.
The changelog
A release starts with words. CHANGELOG.md says what changed, newest first, under headings such as ## [0.2.0] - 2026-11-14, and it is written for players: "tonight prints a cinema ticket", not "refactor render module".
It is written by hand, but not from memory. The project uses conventional commits (feat:, fix:, docs: and so on), and git-cliff reads them back. Part of cliff.toml:
commit_parsers = [
{ message = "^feat", group = "Features"},
{ message = "^fix", group = "Bug Fixes"},
{ message = "^doc", group = "Documentation"},
# ...
{ message = "^chore\\(release\\): prepare for", skip = true},
{ message = "^chore", group = "Miscellaneous Tasks"},
{ body = ".*security", group = "Security"},
]
Each line is a regular expression tried against a commit message, with the group that commit belongs in. The command from CONTRIBUTING.md prints every commit since the last tag, sorted into those groups:
git cliff --unreleased --tag v0.2.0 --strip all
That list is a checklist and not the changelog, because a commit message is written for the next developer and a changelog entry for someone deciding whether to upgrade. You read the list, make sure the hand-written section has missed nothing, and rename ## [Unreleased] to the version and the date.
One number, three places
Cargo doesn't take the version from a git tag. The version is a line in Cargo.toml:
[package]
name = "terminal-of-tinsel"
version = "0.2.0"
edition = "2024"
rust-version = "1.88"
--version reads it, Cargo.lock records it, and last night's man pages print it. So a release is a commit before it is anything else: change the version, run cargo check so that Cargo.lock follows, run task shelldocs so that the man pages follow, finish the changelog, and commit the lot as chore(release): prepare for v0.2.0. If you forget the man pages, last night's test fails.
What cargo-dist does
Building a release by hand would mean compiling on three operating systems for two kinds of processor, packing six archives, writing install scripts and updating a Homebrew formula. cargo-dist does all of that from dist-workspace.toml:
[dist]
# The preferred dist version to use in CI (Cargo.toml SemVer syntax)
cargo-dist-version = "0.34.0"
# CI backends to support
ci = "github"
# The installers to generate for each app
installers = ["shell", "powershell", "homebrew"]
# Target platforms to build apps for (Rust target-triple syntax)
targets = ["aarch64-apple-darwin", "aarch64-pc-windows-msvc", "aarch64-unknown-linux-gnu", "x86_64-apple-darwin", "x86_64-unknown-linux-gnu", "x86_64-pc-windows-msvc"]
# Extra files for every archive: a man page per command and a completion
# script per shell. They are generated and checked by 'cargo test shell_docs'.
include = ["man/", "completions/"]
# ...
# A custom Homebrew tap to publish the formula to (the same tap as Terminal of Terror)
tap = "hungovercoders/homebrew-tap"
# Publish jobs to run in CI (needs the HOMEBREW_TAP_TOKEN secret)
publish-jobs = ["homebrew"]
A target triple names a processor, a vendor and an operating system. aarch64-apple-darwin is a Mac with Apple silicon and x86_64-pc-windows-msvc is Windows on Intel. Six targets make six archives. The include line is why man/ and completions/ had to be committed. The three installers are a shell script for macOS and Linux, a PowerShell script for Windows, and a formula so that brew install hungovercoders/tap/terminal-of-tinsel works. Publishing the formula means pushing to a different repository, which is what the HOMEBREW_TAP_TOKEN secret is for.
From that file cargo-dist generates .github/workflows/release.yml, all 343 lines of it. Its first line says "autogenerated", so don't edit that file. To change how releases are built, change dist-workspace.toml and let cargo-dist write the workflow again with dist init.
Cargo.toml adds one more piece, a build profile for cargo-dist that starts from the release profile:
[profile.release]
lto = true
codegen-units = 1
strip = true
# The profile that 'dist' will build with
[profile.dist]
inherits = "release"
lto = "thin"
strip removes debugging symbols and lto lets the compiler optimise across crates, which is how a program with a full-screen interface comes out at about two and a half megabytes on Linux.
Why a tag, and not a merge
Here is what starts the release workflow:
on:
pull_request:
push:
tags:
- '**[0-9]+.[0-9]+.[0-9]+*'
There are two triggers. On a pull request only the plan job runs, which works out what a release would build and publishes nothing. The real thing happens when a tag that looks like a version is pushed. Then plan is followed by the builds, a job that creates the GitHub release and uploads the archives, and publish-homebrew-formula.
Releasing on every merge to main would treat two different kinds of event as one. A merge happens whenever a piece of work is ready, perhaps several times a day, and main between releases can hold half of a feature. A release is a decision. Somebody has chosen a version number, read the changelog and judged that this commit is the one players should have. A tag records that decision in git. It is a name for exactly one commit, the name carries the version, and anyone can check out v0.2.0 later and build exactly what was shipped.
A release is also hard to take back. Once the install script and the Homebrew formula point at new archives, people have them. So the trigger is the one deliberate act that can't happen by accident in ordinary work:
git tag v0.2.0
git push origin v0.2.0
Those two lines are quoted from the release steps in CONTRIBUTING.md so that you know what they do. Don't run them on this repository. Its rule, in bold in the same section, is that a v* tag is never pushed without the maintainer's go-ahead. You release your own copy, which is the next section but one.
The library and the website
On Night 6 you met modules: mod creatures; in main.rs. The finished program arranges them differently. src/lib.rs declares every module as public:
pub mod calendar;
pub mod cli;
pub mod complete;
pub mod creatures;
// ...
and src/main.rs reaches them as an outsider would:
use terminal_of_tinsel::{
calendar, cli, creatures, error, explorer, games, guess, host, mash, packs, quiz, render, rng,
stocking, store, tui,
};
A package with both src/lib.rs and src/main.rs is two crates: a library called terminal_of_tinsel (the dash becomes an underscore) and a binary that uses it. The reason is the website, because a binary crate can't be imported by another program and a library can. site/ is a second package in the same repository, joined by two lines in the root Cargo.toml:
[workspace]
members = ["site"]
and it depends on the program by path:
[dependencies]
terminal-of-tinsel = { path = ".." }
The site generator calls Vault::load(), the host's lines and even Cli::command(), so its table of commands is made by asking clap, as the man pages are. A new creature in packs/ appears in the terminal and on the website from the same file. cargo run -p tinsel-site -- --out dist (or task site) writes the pages into dist/, and docs/website.md explains the rules it keeps: everything from the data is escaped, no inline styles or scripts, nothing loaded from another site.
One caution about the website. It is generated and tested, and CI builds it, but it is not deployed. There is no Cloudflare project connected and no domain agreed, and the address in the generator is a placeholder. cargo-dist ignores the site altogether (dist = false in its Cargo.toml), so a release ships the program alone.
Making it yours
The project is released under CC0, so you may take it (the website's fonts keep their own licences). Fork it, or carry on with the folder you began on Night 1. To rename it, search for the old name and decide about each place it appears:
grep -rn "terminal-of-tinsel\|terminal_of_tinsel\|TERMINAL_OF_TINSEL" --include="*.rs" --include="*.toml" --exclude-dir=target .
The ones that matter: name, repository and homepage in Cargo.toml; name = "terminal-of-tinsel" in src/cli.rs; BIN in src/shelldocs.rs and bin in complete_script; the config folder in src/store.rs; the two environment variables, SEED_ENV in src/rng.rs and HOME_ENV in src/store.rs; the use terminal_of_tinsel:: lines; and tap in dist-workspace.toml, which must be a tap you own, or be removed along with "homebrew" from the two lists (run dist init afterwards so the workflow follows). Then run task shelldocs and cargo test --workspace, and let the tests find what you missed.
On your own copy, with cargo-dist installed, dist plan shows what a release would build without publishing anything. When that looks right, the tag is yours to push.
From here, The Rust Programming Language covers properly what these nights met in passing, lifetimes and trait objects above all. docs/go-to-rust.md compares every part of this program with its Go sister, Terminal of Terror, which has a course of its own. And the best next program is one you want to exist.
Try it
- Run
git log --oneline | head -20and see which commits a^feator^fixparser would catch. - Run
cargo run -- --versionand find the same number inCargo.tomland inman/terminal-of-tinsel.1. - Run
cargo test -p tinsel-siteand read the test names insite/tests/site.rs. - Open
.github/workflows/release.ymland find the six jobs. Read it, but don't change it.
🎄 Festive fact
#[command(version)] on the Cli struct has no value because clap fetches one. Cargo sets an environment variable, CARGO_PKG_VERSION, while it compiles your crate, and clap reads it with env!, the same compile-time macro that shelldocs.rs uses for CARGO_MANIFEST_DIR. The number in Cargo.toml is compiled into the binary with no code of yours.
🕯️ Before morning
Add a creature of your own to a built-in pack in your copy, and get cargo test to pass. It can be a guest from your own family's Christmas, as long as the facts are true.
Hint: start with packs new, move the two files into packs/midwinter/, add the id to order in that pack's pack.json, and run cargo test. The data tests will tell you, one failure at a time, what a built-in creature needs that a community one doesn't. CONTRIBUTING.md has the full list.
📺 "And that's the programme. Twenty-four nights ago you had an empty folder; tonight you have a studio, a roster, three games, a calendar and a way to send it all out into the snow. Put the porridge out for the tomte, wear something new for the Yule Cat's sake, and do make something of your own in the new year: I should like to tune in. This has been Auntie Aerial's Night School, on Channel 25, from the top of the tree. Merry Christmas, and good night."