Trame

release: a program's release

#import "trame:release". The steps of a release, the same on a laptop and in a release workflow; a project's own tool (tools/<tool>) gives them its Release_Options and calls them as its commands.

Formula
config :: proc() -> release.Release_Options {
	@(static) files := [?][2]string{{"README.md", "README.md"}, {"LICENSE", "LICENSE"}}
	return {project = project(), dist = "build/dist", files = files[:], check = proc() -> cli.Exit { return run_check(nil) }}
}
release.package_(config(), args)   // <tool> package [version]
release.notes(config(), args)      // <tool> notes <version>
release.ship(config(), args)       // <tool> ship <patch|minor|major|x.y.z> [--dry-run]

Each step returns a cli.Exit, as a command does. check is the project's checks: ship commits only when it returns .Done.

Release_Options.project is the project's toolbox.Project (toolbox.md): its name, repository, changelog, version file and line, and release build; its fields read as the Release_Options's (o.name).

commands(o) -> [3]toolbox.Command gives the three as commands of the project's tool (package, notes, ship), for toolbox.tool_main; the Release_Options is copied, its slices must live as long as the tool (a @(static) table, or main's frame):

Formula
release_commands := release.commands(config())
toolbox.tool_main("classeurtool", {build, test, check, release_commands[0], release_commands[1], release_commands[2]}, toolbox.ROOT_MARK_DEFAULT)
StepWhat it does
package_<dist>/<name>-<version>-linux-x64.tar.gz (stripped, mode 755, owner 0) or <name>-<version>-windows-x64.zip: the program and files, and <archive>.sha256. A version given (a tag, v or not) must be the sources'.
notesThe changelog's section of a version on the standard output: a GitHub release's notes.
shipFrom a clean checkout (any branch, a worktree, a detached HEAD): the fragments checked (a malformed one stops it, and so does nothing to release), then publish (below): the number, the fragments assembled into ## [<version>] - <today> with the version's link, the sources' version set, check run, a commit (the changelog, changelog.d/ and the version file), the annotated tag v<version>, master and the tag pushed at once. --dry-run shows the section it would release.

The changelog is made of fragments (changelog.md): a change adds its file to changelog.d/, beside Release_Options.changelog, and never edits the changelog. ship assembles them: the version's section, its link (<repository>/releases/tag/v<version>), the fragments deleted. A changelog that still has an ## [Unreleased] section written by hand gets its entries in the version too, after the fragments', and loses the section.

A program that updates itself (update.md) gives its product in Release_Options.update: package_ then writes, beside the archive, the program alone (expected_file_name, stripped on Linux as in the archive), what an installed copy downloads, and its manifest and .sig (manifest_name), signed by $UPDATE_SIGNING_KEY (toolbox.md). A release (a version given) without the key is refused; a package without a version is not signed. The release workflow gives the key as a secret and uploads <dist>/*.

The pure parts are there for a project's own steps: semver, semver_newer; the version line's (version_of, version_set) are trame:toolbox's (toolbox.md). The changelog's are in trame:changelog (changelog.md).

A release workflow on a tag v* runs the project's checks, package, then gh release create <tag> <dist>/* --notes-file with notes' output (classeur's and papier's .github/workflows/release.yml).

publish: the number, the commit, the tag and the push

release.publish(Publish) is the end of every release, ship's and the toolkit's own (trame release):

  1. git fetch --tags origin master, then origin/master merged into HEAD when HEAD lacks some of it (a worktree or a detached HEAD works; a branch's own merges stay as they are);
  2. the version: version_next(last, asked), last the highest tag v<x.y.z> (or Publish.floor, the sources' version, when no tag says more); asked is patch, minor, major or an exact x.y.z, which must come after last;
  3. Publish.write(version) writes the release's files and gives the paths to commit and the subject (the checkout is reset when it fails);
  4. a commit, the annotated tag v<version>, then git push --atomic origin HEAD:refs/heads/master refs/tags/v<version>.

When origin moved meanwhile (another session published), the atomic push is refused and nothing went out: the commit and the tag are undone and it starts again at 1 with the next number, Publish.tries times (3). A tag is never published without its commit on master. Publish.no_push stops after the tag.

The toolkit's own release (trame release, CONTRIBUTING.md) gets its demo programs from the Release workflow (.github/workflows/release.yml): one Windows x64 zip per demo, attached once the release is published. ./build/trame demos builds the same zips locally, in build/demos.

Edit this page on GitHub