From 68c5e5ed73248366a425209e1173368da564155a Mon Sep 17 00:00:00 2001 From: Rohit Goswami Date: Thu, 19 Nov 2026 17:36:15 +0100 Subject: [PATCH 1/3] chore(release): cog bump with a release-prepare hook --- cog.toml | 30 +++++---------- tools/release-prepare | 85 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 94 insertions(+), 21 deletions(-) create mode 100755 tools/release-prepare diff --git a/cog.toml b/cog.toml index 4704de09..3389aa78 100644 --- a/cog.toml +++ b/cog.toml @@ -1,25 +1,13 @@ -from_latest_tag = false -ignore_merge_commits = true -disable_changelog = false +# `cog bump --minor` (or --patch, --major, --version X.Y.Z) on a release branch: +# the hook below prepares the tree, cog commits it as `chore(version): X.Y.Z` +# and creates the tag vX.Y.Z on that commit. CONTRIBUTING.md has the steps around it. tag_prefix = "v" +ignore_merge_commits = true +# CHANGELOG.md is built by towncrier from changelog.d/, in the hook. +disable_changelog = true +# A release is cut from a branch that becomes a pull request to main. +branch_whitelist = ["chore/release-*"] pre_bump_hooks = [ - "sed -i '0,/^version = /s/^version = \".*\"/version = \"{{version}}\"/' Cargo.toml", - "sed -i '0,/^version = /s/^version = \".*\"/version = \"{{version}}\"/' pixi.toml", - "sed -i '0,/^version = /s/^version = \".*\"/version = \"{{version}}\"/' pyproject.toml", - "cargo generate-lockfile", + "tools/release-prepare {{version}}", ] - -[commit_types] -feat = { changelog_title = "Added" } -fix = { changelog_title = "Fixed" } -docs = { changelog_title = "Documentation" } -chore = { changelog_title = "Maintenance" } -refactor = { changelog_title = "Changed" } -test = { changelog_title = "Tests" } -style = { changelog_title = "Style" } -perf = { changelog_title = "Performance" } - -[changelog] -path = "CHANGELOG.md" -authors = [{ username = "HaoZeke", signature = "Rohit Goswami" }] diff --git a/tools/release-prepare b/tools/release-prepare new file mode 100755 index 00000000..68d223d9 --- /dev/null +++ b/tools/release-prepare @@ -0,0 +1,85 @@ +#!/usr/bin/env bash +# Prepare the tree for a release: the pre-bump hook of cog.toml. +# +# usage: tools/release-prepare NEW_VERSION +# +# `cog bump` runs this with the version it is about to tag, then commits what +# changed and creates the tag. For NEW_VERSION and the version Cargo.toml +# still names (OLD) it sets: +# - CHANGELOG.md: `towncrier build` writes the fragments of changelog.d/ +# under a heading for NEW_VERSION and removes them; +# - the version declarations tests/public_metadata.rs and the publish +# workflow compare: Cargo.toml, the eb_stack entry of Cargo.lock, +# pixi.toml, pyproject.toml, server.json, CITATION.cff and +# docs/source/conf.py. Nothing is compiled, and no dependency moves; +# - the pages that state the current release (the list `current_release` +# below): every OLD that stands alone as a version becomes NEW; +# - llms.txt and llms-full.txt, written again from the Org manual. +# +# Not done here: a sentence that should keep naming the old release. None of +# the listed pages has one; when one gains it, take the page out of the list +# and edit it in a commit before the bump. +# +# Needs: towncrier (or uvx), python3. A refused run can leave edited files +# behind; `git checkout -- .` puts the tree back. +set -euo pipefail + +new=${1:?usage: tools/release-prepare NEW_VERSION} +cd "$(dirname "${BASH_SOURCE[0]}")/.." + +die() { echo "release-prepare: $*" >&2; exit 2; } + +# set_in FILE SED_EXPRESSION...: edit FILE, and refuse a FILE the expressions +# leave unchanged, so a version string that moved fails the bump instead of +# being skipped. +set_in() { + local file=$1 before + shift + before=$(sha256sum < "${file}") + sed -i -E "$@" "${file}" + [ "${before}" != "$(sha256sum < "${file}")" ] || die "${file} does not name ${old} where expected" +} + +[[ ${new} =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] || die "'${new}' is not X.Y.Z" +old=$(awk '/^\[package\]/{p=1; next} /^\[/{p=0} p && /^version[[:space:]]*=/{gsub(/^[^"]*"|".*$/, ""); print; exit}' Cargo.toml) +[ -n "${old}" ] || die "Cargo.toml names no [package] version" +[ "${old}" != "${new}" ] || die "Cargo.toml already names ${new}" +old_re=${old//./\\.} + +if command -v towncrier > /dev/null 2>&1; then + towncrier build --version "${new}" --yes +else + uvx towncrier build --version "${new}" --yes +fi + +first_version="0,/^version = /s/^(version = )\"${old_re}\"\$/\1\"${new}\"/" +set_in Cargo.toml "${first_version}" +set_in pixi.toml "${first_version}" +set_in pyproject.toml "${first_version}" +set_in Cargo.lock "/^name = \"eb_stack\"\$/{n;s/^(version = )\"${old_re}\"\$/\1\"${new}\"/}" +set_in server.json "s/^( *\"version\": )\"${old_re}\"/\1\"${new}\"/" +set_in CITATION.cff "s/^(version: )${old_re}\$/\1${new}/" +set_in docs/source/conf.py "s/^(release = )\"${old_re}\"\$/\1\"${new}\"/" + +# Pages whose every mention of OLD means "the current release". +current_release=( + README.md + CONTRIBUTING.md + docs/orgmode/changelog.org + docs/orgmode/contributing.org + docs/orgmode/get-started.org + docs/orgmode/index.org + docs/orgmode/install.org + docs/orgmode/explanation/sbom-blast-radius.org +) +for page in "${current_release[@]}"; do + # OLD alone: not the tail of 10.8.0 and not the head of 0.8.01 or 0.8.0.1. + # Applied twice, since two mentions can share the character between them. + alone="s/(^|[^0-9.])${old_re}(\$|[^0-9]|\.[^0-9]|\.\$)/\1${new}\2/g" + set_in "${page}" -e "${alone}" -e "${alone}" +done + +python3 scripts/gen-llms-txt.py + +echo "release-prepare: ${old} -> ${new}" +git status --short | awk '{print $1}' | sort | uniq -c From 137b2edbbf841d71404a1c4b01b534f4a203630f Mon Sep 17 00:00:00 2001 From: Rohit Goswami Date: Thu, 19 Nov 2026 17:36:37 +0100 Subject: [PATCH 2/3] docs(release): the steps around cog bump --- CONTRIBUTING.md | 42 +++++++++++++++----------------- changelog.d/+cog-release.misc.md | 1 + docs/orgmode/contributing.org | 18 ++++++++------ llms-full.txt | 18 ++++++++------ 4 files changed, 41 insertions(+), 38 deletions(-) create mode 100644 changelog.d/+cog-release.misc.md diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 8e5c3336..496aa5b9 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -81,30 +81,28 @@ layer. The public files contain reusable package intent and target topology. ## Releasing Version source of truth: `version` in root `Cargo.toml` (currently **0.8.0**). -Keep these in lockstep on every release: - -1. `Cargo.toml` / `pixi.toml` `version` -2. `pyproject.toml` `version` and `server.json` (both `version` fields) -3. `CITATION.cff` `version` -4. `docs/source/conf.py` `release` -5. `CHANGELOG.md`: `towncrier build --version X.Y.Z` turns the fragments in - `changelog.d/` into `## X.Y.Z - YYYY-MM-DD` -6. `CITATION.cff`: add `date-released` when the version is published -7. The version a recorded command prints: `README.md`, this file, - `docs/orgmode/index.org` (the install section), `docs/orgmode/install.org`, - `docs/orgmode/get-started.org`, `docs/orgmode/contributing.org`, - `docs/orgmode/changelog.org`, and - `docs/orgmode/explanation/sbom-blast-radius.org`, whose `eb-stack --version` - block `tests/sbom_page_drift.rs` compares with a fresh run; then - `python scripts/gen-llms-txt.py` for `llms-full.txt` - -`tests/public_metadata.rs` rejects a `date-released` line, so that field -stays absent until the test is updated for a published citation. - -Then: + +`cog bump` cuts a release. `cog.toml` runs `tools/release-prepare` before the +bump commit, which builds `CHANGELOG.md` from `changelog.d/` with towncrier, +sets the version in every file that declares or states it, and writes +`llms.txt` and `llms-full.txt` again; the script's header lists the files. +It refuses when one of them no longer names the old version. + +1. Branch from `main`: `git switch -c chore/release-X.Y.Z origin/main`. +2. `cog bump --minor` (or `--patch`, `--major`, `--version X.Y.Z`). It runs + the hook, commits `chore(version): X.Y.Z` and creates the tag on that + commit. `cog bump --minor --dry-run` prints the version only. +3. Push the branch, open the pull request, and merge it with a merge commit + once its checks pass, so the tagged commit is on `main`. + +`CITATION.cff` gets no `date-released`: `tests/public_metadata.rs` rejects +that line, so the field stays absent until the test is updated for a +published citation. + +Then sign the tag cog made and push it: ```bash -git tag -a v0.8.0 -m "eb-stack 0.8.0" +git tag -s -f v0.8.0 -m "eb-stack 0.8.0" 'v0.8.0^{}' git push origin v0.8.0 # .github/workflows/release.yml (cargo-dist) builds the installers # and publishes the GitHub Release. diff --git a/changelog.d/+cog-release.misc.md b/changelog.d/+cog-release.misc.md new file mode 100644 index 00000000..f036dde7 --- /dev/null +++ b/changelog.d/+cog-release.misc.md @@ -0,0 +1 @@ +A release is cut with `cog bump`: `cog.toml` runs `tools/release-prepare`, which builds the changelog, sets the version in every file that declares or states it, and regenerates `llms.txt` and `llms-full.txt`. It refuses when a listed file no longer names the old version. diff --git a/docs/orgmode/contributing.org b/docs/orgmode/contributing.org index 2e2af6c6..24187a41 100644 --- a/docs/orgmode/contributing.org +++ b/docs/orgmode/contributing.org @@ -78,18 +78,20 @@ layer. Public files contain reusable package intent and target topology. * Releasing Version source of truth is ~version~ in root ~Cargo.toml~ (currently *0.8.0*). -Keep these aligned: -1. ~Cargo.toml~ / ~pixi.toml~ ~version~ -2. ~pyproject.toml~ ~version~ and ~server.json~ (both ~version~ fields) -3. ~CITATION.cff~ ~version~ -4. ~docs/source/conf.py~ ~release~ -5. ~CHANGELOG.md~ version heading and release date -6. ~CITATION.cff~ ~date-released~ when the version is published +~cog bump~ cuts a release, on a branch named ~chore/release-X.Y.Z~. ~cog.toml~ +runs ~tools/release-prepare~ before the bump commit: towncrier builds +~CHANGELOG.md~ from ~changelog.d/~, the version is set in every file that +declares or states it (~Cargo.toml~, ~Cargo.lock~, ~pixi.toml~, +~pyproject.toml~, ~server.json~, ~CITATION.cff~, ~docs/source/conf.py~ and the +pages the script lists), and ~llms.txt~ and ~llms-full.txt~ are written again. +The script refuses when one of those files no longer names the old version. +~CONTRIBUTING.md~ has the steps. ~tests/public_metadata.rs~ rejects a ~date-released~ line, so that field stays absent until the test is updated for a published citation. -Tag ~vX.Y.Z~ and push the tag. ~.github/workflows/release.yml~ (cargo-dist) +Merge the release branch with a merge commit, then sign the tag cog made, +~vX.Y.Z~, and push it. ~.github/workflows/release.yml~ (cargo-dist) builds the installers and publishes the GitHub Release. It does not publish to crates.io. diff --git a/llms-full.txt b/llms-full.txt index 883fabd6..5b996495 100644 --- a/llms-full.txt +++ b/llms-full.txt @@ -13920,19 +13920,21 @@ layer. Public files contain reusable package intent and target topology. # Releasing Version source of truth is `version` in root `Cargo.toml` (currently **0.8.0**). -Keep these aligned: -1. `Cargo.toml` / `pixi.toml` `version` -2. `pyproject.toml` `version` and `server.json` (both `version` fields) -3. `CITATION.cff` `version` -4. `docs/source/conf.py` `release` -5. `CHANGELOG.md` version heading and release date -6. `CITATION.cff` `date-released` when the version is published +`cog bump` cuts a release, on a branch named `chore/release-X.Y.Z`. `cog.toml` +runs `tools/release-prepare` before the bump commit: towncrier builds +`CHANGELOG.md` from `changelog.d/`, the version is set in every file that +declares or states it (`Cargo.toml`, `Cargo.lock`, `pixi.toml`, +`pyproject.toml`, `server.json`, `CITATION.cff`, `docs/source/conf.py` and the +pages the script lists), and `llms.txt` and `llms-full.txt` are written again. +The script refuses when one of those files no longer names the old version. +`CONTRIBUTING.md` has the steps. `tests/public_metadata.rs` rejects a `date-released` line, so that field stays absent until the test is updated for a published citation. -Tag `vX.Y.Z` and push the tag. `.github/workflows/release.yml` (cargo-dist) +Merge the release branch with a merge commit, then sign the tag cog made, +`vX.Y.Z`, and push it. `.github/workflows/release.yml` (cargo-dist) builds the installers and publishes the GitHub Release. It does not publish to crates.io. From c82359e5ca196ac4a574fdef5862ffed18ede731 Mon Sep 17 00:00:00 2001 From: Rohit Goswami Date: Thu, 19 Nov 2026 17:41:25 +0100 Subject: [PATCH 3/3] docs(cog): name the files the release hook sets tests/public_metadata.rs requires cog.toml to name pyproject.toml, which the inline sed hooks did. The hook script sets it now, so the file list is stated where the test and a reader look for it. --- cog.toml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cog.toml b/cog.toml index 3389aa78..3bd10f18 100644 --- a/cog.toml +++ b/cog.toml @@ -8,6 +8,10 @@ disable_changelog = true # A release is cut from a branch that becomes a pull request to main. branch_whitelist = ["chore/release-*"] +# The hook sets the version in Cargo.toml, Cargo.lock, pixi.toml, +# pyproject.toml, server.json, CITATION.cff and docs/source/conf.py, and in the +# pages that state the current release; it refuses when one of them no longer +# names the old version. pre_bump_hooks = [ "tools/release-prepare {{version}}", ]