Add dynamic version from Docker/VERSION file
- Create version.py utility to read version from Docker/VERSION - Replace hardcoded version '1.0.1' with APP_VERSION from version.py - Add version logging on FastAPI startup - Use APP_VERSION in health endpoints and template context
This commit is contained in:
26
src/server/utils/version.py
Normal file
26
src/server/utils/version.py
Normal file
@@ -0,0 +1,26 @@
|
||||
"""Version management utilities for Aniworld application."""
|
||||
|
||||
from pathlib import Path
|
||||
from typing import Optional
|
||||
|
||||
|
||||
def get_version() -> str:
|
||||
"""
|
||||
Get the current application version from Docker/VERSION file.
|
||||
|
||||
Returns:
|
||||
Version string from the VERSION file, or "unknown" if not found.
|
||||
"""
|
||||
version_file = Path(__file__).parent.parent.parent.parent / "Docker" / "VERSION"
|
||||
|
||||
try:
|
||||
if version_file.exists():
|
||||
return version_file.read_text().strip()
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
return "unknown"
|
||||
|
||||
|
||||
# Module-level version constant (loaded once at import)
|
||||
APP_VERSION: str = get_version()
|
||||
Reference in New Issue
Block a user