31 lines
1.0 KiB
Python
Executable File
31 lines
1.0 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
"""Validate Clearview release version state before a release build."""
|
|
from __future__ import annotations
|
|
|
|
import re
|
|
from pathlib import Path
|
|
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
VERSION_FILE = ROOT / "containers" / "clearview" / "src" / "clearview_app" / "version.py"
|
|
CHANGELOG = ROOT / "docs" / "changelog.md"
|
|
|
|
ns: dict[str, object] = {}
|
|
exec(VERSION_FILE.read_text(), ns)
|
|
version = str(ns.get("VERSION", ""))
|
|
build = int(ns.get("BUILD", -1))
|
|
|
|
if build != 0:
|
|
raise SystemExit(f"Release builds require BUILD = 0 in {VERSION_FILE}; found BUILD = {build}")
|
|
|
|
match = re.search(r"^## (v\d+\.\d+\.\d+) — \d{4}-\d{2}-\d{2}\s*$", CHANGELOG.read_text(), flags=re.MULTILINE)
|
|
if not match:
|
|
raise SystemExit(f"No release heading found in {CHANGELOG}; expected '## vX.Y.Z — YYYY-MM-DD'")
|
|
|
|
changelog_version = match.group(1)
|
|
if changelog_version != version:
|
|
raise SystemExit(
|
|
f"Version mismatch: {VERSION_FILE} has {version}, but top changelog release is {changelog_version}"
|
|
)
|
|
|
|
print(f"[check-release-version] {version}")
|