diff --git a/VERSION b/VERSION new file mode 100644 index 0000000..c4e41f9 --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +4.0.3 diff --git a/app/routers/board.py b/app/routers/board.py index 3a3de30..eefdbef 100644 --- a/app/routers/board.py +++ b/app/routers/board.py @@ -10,6 +10,7 @@ from fastapi.responses import HTMLResponse, JSONResponse from app.db import get_conn from app.services.gitea_client import gitea from app.auth.session import SessionManager +from app.routers.dashboard import _get_app_version logger = logging.getLogger(__name__) router = APIRouter(tags=["board"], prefix="/board") @@ -397,7 +398,7 @@ def _sidebar_data(request: Request, owner: str = "", repo: str = "") -> dict: "gitea_linked": gitea_linked, "github_linked": github_linked, "has_active_workspace": has_active_workspace, - "app_version": "4.0.3", + "app_version": _get_app_version(), "local_workspaces": _local_workspaces_for_user(user)} diff --git a/app/routers/dashboard.py b/app/routers/dashboard.py index 4cc4072..48e45ec 100644 --- a/app/routers/dashboard.py +++ b/app/routers/dashboard.py @@ -13,6 +13,32 @@ from app.db import get_conn logger = logging.getLogger(__name__) router = APIRouter(tags=["dashboard"]) +_VERSION = None + + +def _get_app_version() -> str: + """Read version from VERSION file with caching.""" + global _VERSION + if _VERSION is not None: + return _VERSION + try: + import os + version_path = os.path.join(os.path.dirname(__file__), "..", "..", "VERSION") + if os.path.exists(version_path): + with open(version_path) as f: + _VERSION = f.read().strip() + else: + # Docker fallback + version_path = "/app/VERSION" + if os.path.exists(version_path): + with open(version_path) as f: + _VERSION = f.read().strip() + else: + _VERSION = "0.0.0" + except Exception: + _VERSION = "0.0.0" + return _VERSION + def _get_user_or_redirect(request: Request): """Return decoded user or a RedirectResponse to login page. @@ -188,7 +214,7 @@ def _sidebar_data(request: Request, repos: list[dict], include_workspace: bool = "gitea_linked": gitea_linked, "github_linked": github_linked, "has_active_workspace": has_active_workspace, - "app_version": "4.0.3", + "app_version": _get_app_version(), } sidebar["local_workspaces"] = _local_workspaces_for_user(user)