VNOX-Client/scripts/release/extract_changelog.py
loki5512344 948d10bd37
ci: add gitea workflows and signed release pipeline
CI runs fmt, clippy and tests. Tag releases build Linux and Windows (mingw cross) artifacts, SHA256SUMS and an Ed25519 signed manifest, then publish via the Gitea API. Helper scripts live in scripts/release, docs in docs/release.md.
2026-11-01 15:48:56 +01:00

35 lines
989 B
Python
Executable file

#!/usr/bin/env python3
"""Print the body of the CHANGELOG.md section for a version ("## [X.Y.Z] ...").
Exits non-zero if the section is missing or empty.
Usage: extract_changelog.py VERSION [CHANGELOG.md]
"""
import re
import sys
def main() -> int:
if len(sys.argv) < 2:
sys.exit(__doc__)
version = sys.argv[1].lstrip("v")
path = sys.argv[2] if len(sys.argv) > 2 else "CHANGELOG.md"
with open(path, encoding="utf-8") as f:
lines = f.read().splitlines()
head = re.compile(r"^## \[" + re.escape(version) + r"\]")
out, inside = [], False
for line in lines:
if inside and line.startswith("## "):
break
if inside:
out.append(line)
elif head.match(line):
inside = True
body = "\n".join(out).strip()
if not inside or not body:
sys.exit(f"CHANGELOG.md has no non-empty section for [{version}]")
print(body)
return 0
if __name__ == "__main__":
sys.exit(main())