Skip to content

Commit d8521f9

Browse files
TMHSDigitalclaude
andcommitted
ci: release notes and CHANGELOG entries list what actually shipped
302 of 303 CHANGELOG entries read only "See release notes for details", and the release bodies (gh release create --generate-notes) were just a compare link: --generate-notes lists merged PRs, and most commits land as direct pushes. - .github/scripts/release_notes.py groups the conventional-commit subjects since the previous tag into Features / Fixes / Other with commit links, skipping the bot's own bump commits. It writes the release body and replaces the "See release notes ... for details." stub release-doc-sync prepends for the new version (other entries untouched). - release.yml runs it right after release-doc-sync and creates the release with --notes-file instead of --generate-notes. - CHANGELOG.md: backfilled all 306 placeholder entries from their tag ranges (prev tag .. vX); 0 empty ranges. - tests/test_release_notes.py (grouping, links, bump-commit skip, single-entry patch, missing placeholder) runs in validate-harness. Closes #337 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 6d8820b commit d8521f9

5 files changed

Lines changed: 2161 additions & 518 deletions

File tree

‎.github/scripts/release_notes.py‎

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
#!/usr/bin/env python3
2+
"""Write release notes from the commits since the previous tag.
3+
4+
python .github/scripts/release_notes.py --since v0.142.3 --version 0.143.0 \
5+
--notes "$RUNNER_TEMP/notes.md" --changelog CHANGELOG.md
6+
7+
Groups conventional-commit subjects (Features, Fixes, Other) with links to
8+
each commit, skips the release bot's own "chore: bump version" commits, writes
9+
the list to --notes (the GitHub release body) and, with --changelog, replaces
10+
the version's "See release notes ... for details." placeholder that
11+
release-doc-sync writes with the same list plus the link. Without this, every
12+
CHANGELOG entry and release body said nothing about what shipped.
13+
"""
14+
from __future__ import annotations
15+
16+
import argparse
17+
import re
18+
import subprocess
19+
import sys
20+
21+
REPO_URL = "https://github.com/TMHSDigital/Blender-Developer-Tools"
22+
GROUPS = (
23+
("Features", re.compile(r"^(feat|feature)(\(.+?\))?!?:", re.I)),
24+
("Fixes", re.compile(r"^fix(\(.+?\))?!?:", re.I)),
25+
)
26+
SKIP = re.compile(r"^chore: bump version to ", re.I)
27+
28+
29+
def commits(since: str | None) -> list[tuple[str, str]]:
30+
rng = f"{since}..HEAD" if since else "HEAD"
31+
out = subprocess.run(
32+
["git", "log", rng, "--no-merges", "--format=%H%x09%s"],
33+
capture_output=True, text=True, check=True,
34+
).stdout
35+
rows = []
36+
for line in out.splitlines():
37+
sha, _, subject = line.partition("\t")
38+
if subject and not SKIP.match(subject):
39+
rows.append((sha, subject.strip()))
40+
return rows
41+
42+
43+
def render(rows: list[tuple[str, str]]) -> str:
44+
buckets: dict[str, list[str]] = {name: [] for name, _ in GROUPS}
45+
buckets["Other"] = []
46+
for sha, subject in rows:
47+
name = next((n for n, rx in GROUPS if rx.match(subject)), "Other")
48+
buckets[name].append(f"- {subject} ([`{sha[:7]}`]({REPO_URL}/commit/{sha}))")
49+
parts = []
50+
for name, lines in buckets.items():
51+
if lines:
52+
parts.append(f"### {name}\n\n" + "\n".join(lines))
53+
return "\n\n".join(parts) if parts else "No changes recorded."
54+
55+
56+
def patch_changelog(path: str, version: str, body: str) -> bool:
57+
text = open(path, encoding="utf-8").read()
58+
placeholder = re.compile(
59+
r"(## \[" + re.escape(version) + r"\][^\n]*\n\n)See \[release notes\]\(([^)]+)\) for details\.",
60+
)
61+
m = placeholder.search(text)
62+
if not m:
63+
return False
64+
repl = m.group(1) + body + f"\n\n[Release v{version}]({m.group(2)})"
65+
text = text[: m.start()] + repl + text[m.end():]
66+
open(path, "w", encoding="utf-8", newline="\n").write(text)
67+
return True
68+
69+
70+
def main(argv=None) -> int:
71+
ap = argparse.ArgumentParser(description=__doc__.splitlines()[0])
72+
ap.add_argument("--since", default=None, help="previous tag (omit for the first release)")
73+
ap.add_argument("--version", required=True)
74+
ap.add_argument("--notes", required=True, help="file to write the release body to")
75+
ap.add_argument("--changelog", default=None)
76+
a = ap.parse_args(argv)
77+
body = render(commits(a.since))
78+
open(a.notes, "w", encoding="utf-8", newline="\n").write(body + "\n")
79+
print(body)
80+
if a.changelog and not patch_changelog(a.changelog, a.version, body):
81+
print(f"::warning::no 'See release notes' placeholder for {a.version} in {a.changelog}",
82+
file=sys.stderr)
83+
return 0
84+
85+
86+
if __name__ == "__main__":
87+
sys.exit(main())

‎.github/workflows/release.yml‎

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,19 @@ jobs:
144144
previous-version: ${{ steps.current.outputs.version }}
145145
meta-repo-ref: v1.15.1
146146

147+
- name: Write release notes (CHANGELOG entry and release body)
148+
# release-doc-sync prepends a "See release notes ... for details." stub;
149+
# replace it with the feat/fix/other subjects since the previous tag,
150+
# and keep the same list for the GitHub release body.
151+
if: steps.check.outputs.skip == 'false' && steps.bump.outputs.release == 'true'
152+
env:
153+
NEW_VERSION: ${{ steps.new.outputs.version }}
154+
run: |
155+
last_tag=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
156+
python3 .github/scripts/release_notes.py ${last_tag:+--since "$last_tag"} \
157+
--version "$NEW_VERSION" --notes "$RUNNER_TEMP/release-notes.md" \
158+
--changelog CHANGELOG.md
159+
147160
- name: Sync plugin manifest version
148161
if: steps.check.outputs.skip == 'false' && steps.bump.outputs.release == 'true'
149162
env:
@@ -233,7 +246,7 @@ jobs:
233246
run: |
234247
gh release create "v${{ steps.new.outputs.version }}" \
235248
--title "v${{ steps.new.outputs.version }}" \
236-
--generate-notes
249+
--notes-file "$RUNNER_TEMP/release-notes.md"
237250
238251
- name: Dispatch Pages
239252
if: steps.check.outputs.skip == 'false' && steps.bump.outputs.release == 'true' && steps.commit.outputs.stale != 'true'

‎.github/workflows/validate.yml‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,9 @@ jobs:
365365
- name: Release bump detection (bump-kind.sh)
366366
run: python3 tests/test_bump_kind.py -v
367367

368+
- name: Release notes generator
369+
run: python3 tests/test_release_notes.py -v
370+
368371
- name: Hero-drift tool exit-code tests
369372
run: |
370373
pip install numpy==2.2.6 Pillow==11.2.1

0 commit comments

Comments
 (0)