12 lines
525 B
Python
12 lines
525 B
Python
import os
|
|
from pathlib import Path
|
|
|
|
|
|
def release_version() -> str:
|
|
value = (Path(__file__).parents[2] / "VERSION").read_text(encoding="utf-8").strip()
|
|
if not value or any(part == "" or not part.isdecimal() for part in value.split(".")) or len(value.split(".")) != 3:
|
|
raise RuntimeError("VERSION must contain a semantic version")
|
|
declared = os.getenv("OCR_VERSION")
|
|
if declared is not None and declared != value:
|
|
raise RuntimeError(f"OCR_VERSION must match VERSION ({value})")
|
|
return value
|