From d0bc9e242165111a3727669c72491890c6466e0d Mon Sep 17 00:00:00 2001 From: Rohit Goswami Date: Sun, 15 Nov 2026 13:05:34 -0600 Subject: [PATCH] build(changelog): towncrier news fragments and a draft check Release notes went into CHANGELOG.md by hand, so any two pull requests that touch it conflict. The other stackhands repositories take one fragment per change in changelog.d/ and build the section at release with towncrier. towncrier.toml follows theirs, with this changelog's heading and section names. A workflow drafts the changelog on each pull request, with the version from Cargo.toml, and checks that a misnamed fragment fails. CONTRIBUTING asks for a fragment and puts towncrier build in the release steps. --- .github/workflows/changelog.yml | 46 +++++++++++++++++++++++++++++++++ CHANGELOG.md | 2 ++ CONTRIBUTING.md | 6 ++++- changelog.d/+towncrier.misc.md | 1 + changelog.d/.gitkeep | 0 towncrier.toml | 37 ++++++++++++++++++++++++++ 6 files changed, 91 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/changelog.yml create mode 100644 changelog.d/+towncrier.misc.md create mode 100644 changelog.d/.gitkeep create mode 100644 towncrier.toml diff --git a/.github/workflows/changelog.yml b/.github/workflows/changelog.yml new file mode 100644 index 00000000..5423a7e4 --- /dev/null +++ b/.github/workflows/changelog.yml @@ -0,0 +1,46 @@ +name: changelog + +on: + push: + branches: [main] + pull_request: + branches: [main] + +permissions: + contents: read + +concurrency: + group: changelog-${{ github.ref }} + cancel-in-progress: true + +jobs: + draft: + name: towncrier build --draft + runs-on: ubuntu-latest + timeout-minutes: 20 + steps: + - uses: actions/checkout@v7 + with: + persist-credentials: false + - uses: astral-sh/setup-uv@v7 + - name: Draft the changelog + run: | + set -euo pipefail + # The draft heading needs a version; Cargo.toml holds the one a release cuts. + version=$(sed -n '0,/^version = /s/^version = "\(.*\)"$/\1/p' Cargo.toml) + test -n "$version" + uvx towncrier@26.9.0 build --draft --version "$version" + - name: A malformed fragment fails the draft + run: | + set -euo pipefail + version=$(sed -n '0,/^version = /s/^version = "\(.*\)"$/\1/p' Cargo.toml) + name=not-a-fragment.md + printf '%s\n' 'This name has no fragment type.' > "changelog.d/$name" + set +e + out=$(uvx towncrier@26.9.0 build --draft --version "$version" 2>&1) + code=$? + set -e + printf '%s\n' "$out" + rm -f "changelog.d/$name" + test "$code" -ne 0 + printf '%s\n' "$out" | grep -F "Invalid news fragment name: $name" diff --git a/CHANGELOG.md b/CHANGELOG.md index 15cd09f7..c222740a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ All notable changes to this project are documented here. + + ## 0.7.4 - 2026-11-13 ### Added diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 4e0c6ad6..0581ff95 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -31,6 +31,9 @@ Build heavy work on a remote builder when local compiles thrash the machine. either a unit test or an integration test under `tests/` - Known maintainer-bump regressions live in `tests/reproduce_real_prs.rs` and must stay green (library **and** CLI auto-bump) +- Every pull request adds a news fragment, `changelog.d/+..md` + with type `feature`, `bugfix`, `doc`, `removal` or `misc`; + `towncrier build --draft --version X.Y.Z` shows how it renders ## Documentation @@ -84,7 +87,8 @@ Keep these in lockstep on every release: 2. `pyproject.toml` `version` and `server.json` (both `version` fields) 3. `CITATION.cff` `version` 4. `docs/source/conf.py` `release` -5. `CHANGELOG.md`: move Unreleased notes into `## X.Y.Z - YYYY-MM-DD` +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`, diff --git a/changelog.d/+towncrier.misc.md b/changelog.d/+towncrier.misc.md new file mode 100644 index 00000000..d7bb3773 --- /dev/null +++ b/changelog.d/+towncrier.misc.md @@ -0,0 +1 @@ +News fragments in `changelog.d/`, assembled into `CHANGELOG.md` by towncrier at release, as in the other stackhands repositories. diff --git a/changelog.d/.gitkeep b/changelog.d/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/towncrier.toml b/towncrier.toml new file mode 100644 index 00000000..bcdeceaf --- /dev/null +++ b/towncrier.toml @@ -0,0 +1,37 @@ +[tool.towncrier] +name = "eb-stack" +directory = "changelog.d" +filename = "CHANGELOG.md" +start_string = "\n" +title_format = "## {version} - {project_date}" +issue_format = "[#{issue}](https://github.com/stackhands/eb-stack/pull/{issue})" +underlines = ["", "", ""] +# Setting ignore, even to nothing, is what makes `towncrier build` fail a +# fragment whose name has no configured type. Unset, that file is skipped +# and the draft still passes. .gitkeep stays ignored either way. +ignore = [] + +[[tool.towncrier.type]] +directory = "feature" +name = "Added" +showcontent = true + +[[tool.towncrier.type]] +directory = "bugfix" +name = "Fixed" +showcontent = true + +[[tool.towncrier.type]] +directory = "doc" +name = "Documentation" +showcontent = true + +[[tool.towncrier.type]] +directory = "removal" +name = "Removed" +showcontent = true + +[[tool.towncrier.type]] +directory = "misc" +name = "Changed" +showcontent = true