ci(release): attach per-version notes from PREVIOUS_HISTORY.md to releases
Per-version user-facing changelog moved out of the README table into PREVIOUS_HISTORY.md (newest-first sections, Development Plan §11.1). On tag push the workflow now harvests the matching section via scripts/ci/release-notes.py and uses it as the release description, uploading an Incido-<version>-changes.md beside the APKs; a missing section falls back to the plain default description. CONTRIBUTING §5 documents the new release-notes maintenance step.
This commit is contained in:
1 parent
576080c8b5
commit
7b6187f99a
5 files changed
+357
-3
No files matched your search
Executable
+88
@@ -0,0 +1,88 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Extract the release-notes section for one version from PREVIOUS_HISTORY.md.
|
||||
|
||||
Incido publishes its user-facing changelog through the Gitea Releases page:
|
||||
for every tag push, `.gitea/workflows/release.yml` calls this script with
|
||||
the released version. The matching `## v<VERSION> — <DATE>` section of
|
||||
PREVIOUS_HISTORY.md becomes the release description and is also uploaded
|
||||
next to the APKs as `Incido-<VERSION>-changes.md`.
|
||||
|
||||
Usage:
|
||||
release-notes.py <version> [--out FILE] [--history FILE] [--no-footer]
|
||||
|
||||
Exits 0 and prints the Markdown (to --out FILE or stdout) when the section
|
||||
exists; exits 1 (message on stderr) when it doesn't — the workflow then
|
||||
falls back to its generic "Release <tag>" body.
|
||||
"""
|
||||
|
||||
import argparse
|
||||
import re
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
# "## v0.3.8.0 — 2026-09-16" -> group(1) = "0.3.8.0"
|
||||
HEADING = re.compile(r"^##\s+v?([0-9]+(?:\.[0-9]+)*)\b")
|
||||
|
||||
FOOTER = (
|
||||
"\n\n---\n\n"
|
||||
"_Full history: PREVIOUS_HISTORY.md at the repository root. "
|
||||
"In-depth developer notes: Incido Development Plan \u00a710._\n"
|
||||
)
|
||||
|
||||
|
||||
def extract(history_text: str, version: str, footer: bool) -> str | None:
|
||||
wanted = version.lstrip("vV").strip()
|
||||
collected: list[str] = []
|
||||
in_section = False
|
||||
for line in history_text.splitlines():
|
||||
match = HEADING.match(line)
|
||||
if match:
|
||||
in_section = match.group(1) == wanted
|
||||
if in_section:
|
||||
collected.append(line)
|
||||
if not collected:
|
||||
return None
|
||||
body = "\n".join(collected).rstrip()
|
||||
if not body:
|
||||
return None
|
||||
return body + (FOOTER if footer else "")
|
||||
|
||||
|
||||
def main() -> int:
|
||||
parser = argparse.ArgumentParser(description=__doc__.splitlines()[0])
|
||||
parser.add_argument("version", help="Version or tag, e.g. 0.3.8.0 or v0.3.8.0")
|
||||
parser.add_argument("--out", type=Path, default=None,
|
||||
help="Write the notes to this file instead of stdout")
|
||||
parser.add_argument("--history", type=Path, default=None,
|
||||
help="Path to PREVIOUS_HISTORY.md "
|
||||
"(default: repo root, two levels above scripts/ci/)")
|
||||
parser.add_argument("--no-footer", action="store_true",
|
||||
help="Omit the standard cross-reference footer")
|
||||
args = parser.parse_args()
|
||||
|
||||
history_path = args.history or (
|
||||
Path(__file__).resolve().parents[2] / "PREVIOUS_HISTORY.md"
|
||||
)
|
||||
if not history_path.is_file():
|
||||
print(f"release-notes: history file not found: {history_path}",
|
||||
file=sys.stderr)
|
||||
return 1
|
||||
|
||||
notes = extract(history_path.read_text(encoding="utf-8"),
|
||||
args.version, footer=not args.no_footer)
|
||||
if notes is None:
|
||||
print(f"release-notes: no changelog section for {args.version} "
|
||||
f"in {history_path.name}", file=sys.stderr)
|
||||
return 1
|
||||
|
||||
if args.out:
|
||||
args.out.write_text(notes, encoding="utf-8")
|
||||
print(f"Wrote {len(notes)} chars for v{args.version.lstrip('vV')} "
|
||||
f"to {args.out}")
|
||||
else:
|
||||
sys.stdout.write(notes)
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
Reference in new issue
Block a user