#!/usr/bin/env python3 """Validate Novela release version state before a release build. Releases must ship with BUILD = 0 so the sidebar shows a clean semantic version (e.g. v0.2.11) instead of a dev build (e.g. v0.2.11.3). """ from __future__ import annotations import re from pathlib import Path ROOT = Path(__file__).resolve().parents[1] VERSION_FILE = ROOT / "containers" / "novela" / "version.py" text = VERSION_FILE.read_text() match = re.search(r"^BUILD = (\d+)\s*$", text, flags=re.MULTILINE) if not match: raise SystemExit(f"BUILD assignment not found in {VERSION_FILE}") build = int(match.group(1)) if build != 0: raise SystemExit( f"Release builds require BUILD = 0 in {VERSION_FILE}; found BUILD = {build}. " f"Reset it before releasing." ) print("[check-release-version] BUILD = 0")