diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..ca7e045 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,14 @@ +# Changelog + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [Unreleased] + +## [0.1.0] - 2026-11-01 + +### Added + +- Initial public developer preview. diff --git a/scripts/release_notes.py b/scripts/release_notes.py new file mode 100644 index 0000000..19fe982 --- /dev/null +++ b/scripts/release_notes.py @@ -0,0 +1,29 @@ +"""Print one version's section of CHANGELOG.md (the GitHub Release notes for that tag). + + python3 scripts/release_notes.py 0.2.0 + +Exits non-zero when CHANGELOG.md has no section for the version, so a release cannot ship +without one. +""" + +import re +import sys +from pathlib import Path + +CHANGELOG = Path(__file__).resolve().parents[1] / "CHANGELOG.md" + + +def notes(version: str, text: str) -> str | None: + match = re.search( + rf"^## \[{re.escape(version)}\][^\n]*\n(.*?)(?=^## \[|^\[[^\]]+\]: |\Z)", + text, + re.MULTILINE | re.DOTALL, + ) + return match.group(1).strip() if match else None + + +if __name__ == "__main__": + body = notes(sys.argv[1], CHANGELOG.read_text()) + if body is None: + sys.exit(f"CHANGELOG.md has no section for {sys.argv[1]}") + print(body)