"""Shared product metadata and independent release versions (Python 3.11+).""" import json from pathlib import Path import re import tomllib ROOT = Path(__file__).resolve().parents[1] def catalog(root=ROOT): return json.loads((root / "plugins/catalog.json").read_text()) def version(plugin, root=ROOT): product = catalog(root)[plugin] return tomllib.loads((root / product["manifest"]).read_text())["package"]["version"] def tag_version(plugin, tag, root=ROOT): match = re.fullmatch(re.escape(plugin) + r"-v(\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?)", tag) if not match or match[1] != version(plugin, root): raise ValueError(f"Expected {plugin}-v{version(plugin, root)}, got {tag!r}") return match[1] def archive_name(plugin, release_version): return f"{plugin}-windows-x86_64-{release_version}.zip"