Files

21 lines
563 B
Python

#!/usr/bin/env python3
"""Sync the VERSION file from pyproject.toml after a version bump."""
import re
import sys
from pathlib import Path
root = Path(__file__).resolve().parent.parent
toml_content = (root / "pyproject.toml").read_text()
match = re.search(
r'^\[project\]\s*\n(?:.*\n)*?version\s*=\s*"([^"]+)"',
toml_content,
re.MULTILINE,
)
if match:
version = match.group(1)
(root / "VERSION").write_text(version + "\n")
else:
print("ERROR: Could not find version in pyproject.toml [project] section", file=sys.stderr)
sys.exit(1)