Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 20 additions & 22 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions changelog.d/+cog-release.misc.md
Original file line number Diff line number Diff line change
@@ -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.
34 changes: 13 additions & 21 deletions cog.toml
Original file line number Diff line number Diff line change
@@ -1,25 +1,17 @@
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-*"]

# 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 = [
"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" }]
18 changes: 10 additions & 8 deletions docs/orgmode/contributing.org
Original file line number Diff line number Diff line change
Expand Up @@ -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.
18 changes: 10 additions & 8 deletions llms-full.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
85 changes: 85 additions & 0 deletions tools/release-prepare
Original file line number Diff line number Diff line change
@@ -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