feat: badge versione build in GUI + build.sh con auto-bump

- VERSION (1.0.0) + build.sh: bump patch/minor/major e deploy via docker compose
- Dockerfile: ARG/ENV APP_VERSION + BUILD_TIME (iniettati come build-arg)
- version.build_info(): env in Docker, fallback file VERSION + '(local)' in dev
- GET /api/version; badge #appVersionPill nell'header (tooltip = build time)
- test_version.py: env vs fallback

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
AdrianoandClaude Opus 4.8 committed 2026-06-03 14:40:52 +02:00
1 parent a88a064aa8
commit cf726b479e
8 files changed
+126 -1

No files matched your search

+6
View File
@@ -25,6 +25,7 @@ from .api import (
)
from .clients import G1StatusError
from .config import load_config
from .version import build_info
logging.basicConfig(level=logging.INFO, format="%(asctime)s %(levelname)s %(name)s: %(message)s")
@@ -102,6 +103,11 @@ def health() -> dict:
return {"status": "ok"}
@app.get("/api/version", tags=["meta"])
def version() -> dict:
return build_info()
@app.get("/", include_in_schema=False)
def index() -> HTMLResponse:
idx = WEB_DIR / "index.html"
+35
View File
@@ -0,0 +1,35 @@
"""Versione build dell'app, mostrata nel badge in GUI.
In Docker i valori arrivano da env (`APP_VERSION`, `BUILD_TIME`) iniettati come
build-arg da `build.sh`. In dev locale (`uv run`) gli env non ci sono: si
ripiega sul contenuto del file `VERSION` nella root del repo + suffisso
`(local)`.
"""
from __future__ import annotations
import os
from pathlib import Path
_VERSION_FILE = Path(__file__).resolve().parents[2] / "VERSION"
def _file_version() -> str:
try:
return _VERSION_FILE.read_text(encoding="utf-8").strip() or "0.0.0"
except OSError:
return "0.0.0"
def build_info() -> dict:
"""Ritorna {'version', 'build_time'}.
Preferisce gli env settati al build dell'immagine; in loro assenza ripiega
sul file VERSION marcando la versione come `(local)`.
"""
version = os.environ.get("APP_VERSION")
build_time = os.environ.get("BUILD_TIME")
if not version:
version = f"{_file_version()} (local)"
if not build_time:
build_time = "(local)"
return {"version": version, "build_time": build_time}