From 263092a71cd5b3d0df10f2b230fa65a8df6776a0 Mon Sep 17 00:00:00 2001 From: shy3130 Date: Tue, 23 Jun 2026 21:52:48 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20bump=5Fversion=20=E5=90=8C=E6=AD=A5=20ap?= =?UTF-8?q?p/=5F=5Finit=5F=5F.py=20=E7=89=88=E6=9C=AC=E5=8F=B7=20(health?= =?UTF-8?q?=20=E6=8E=A5=E5=8F=A3=E5=AF=B9=E9=BD=90)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit bump 脚本之前只更新 pyproject + package.json, 漏改 app/__init__.py, 导致 /health 报的版本号停留在 0.1.31。现在三处版本号源统一更新。 --- backend/app/__init__.py | 2 +- scripts/bump_version.py | 19 +++++++++++++++++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/backend/app/__init__.py b/backend/app/__init__.py index 219bf01..5084745 100644 --- a/backend/app/__init__.py +++ b/backend/app/__init__.py @@ -1,3 +1,3 @@ """TickFlow Stock Panel backend.""" -__version__ = "0.1.31" +__version__ = "0.1.35" diff --git a/scripts/bump_version.py b/scripts/bump_version.py index 5e7530a..cd9d161 100644 --- a/scripts/bump_version.py +++ b/scripts/bump_version.py @@ -17,6 +17,7 @@ from pathlib import Path ROOT = Path(__file__).resolve().parent.parent PKG = ROOT / "frontend" / "package.json" PYPROJECT = ROOT / "backend" / "pyproject.toml" +APP_INIT = ROOT / "backend" / "app" / "__init__.py" # __version__ 写在这里, health 接口读它 def parse_version(v: str) -> tuple[int, int, int]: @@ -54,6 +55,19 @@ def write_pyproject_version(v: str) -> None: PYPROJECT.write_text(text, encoding="utf-8") +def write_app_init_version(v: str) -> None: + """更新 backend/app/__init__.py 的 __version__ (health 接口读这里)。""" + text = APP_INIT.read_text(encoding="utf-8") + text = re.sub( + r'^(__version__\s*=\s*)"[^"]+"', + rf'\1"{v}"', + text, + count=1, + flags=re.MULTILINE, + ) + APP_INIT.write_text(text, encoding="utf-8") + + def main() -> int: # 环境变量跳过 if __import__("os").environ.get("SKIP_VERSION_BUMP") == "1": @@ -62,13 +76,14 @@ def main() -> int: cur = read_pkg_version() new = bump(cur) - # 两个文件版本可能不一致, 统一用 pkg 的为准 + # 三个文件版本可能不一致, 统一用 pkg 的为准 write_pkg_version(new) write_pyproject_version(new) + write_app_init_version(new) # 暂存版本文件改动(并入本次 commit) import subprocess - subprocess.run(["git", "add", str(PKG), str(PYPROJECT)], check=True, cwd=str(ROOT)) + subprocess.run(["git", "add", str(PKG), str(PYPROJECT), str(APP_INIT)], check=True, cwd=str(ROOT)) # 输出新版本号供 hook 读用 print(f"[bump] {cur} -> {new}")