feat: automate version releases

This commit is contained in:
Lan committed 2026-07-11 21:49:04 +08:00
1 parent 818dd47b2a
commit ee8f9082ab
16 files changed
+305 -19

No files matched your search

+20 -1
View File
@@ -1 +1,20 @@
APP_VERSION = "2.4.0"
import os
import re
from pathlib import Path
VERSION_FILE = Path(__file__).resolve().parents[1] / "VERSION"
VERSION_PATTERN = re.compile(
r"^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$"
)
def load_app_version() -> str:
version = os.getenv("APP_VERSION") or VERSION_FILE.read_text(encoding="utf-8")
version = version.strip()
if not VERSION_PATTERN.fullmatch(version):
raise RuntimeError(f"无效的应用版本号: {version!r}")
return version
APP_VERSION = load_app_version()