diff --git a/.gitignore b/.gitignore index 5d6cbb7..875c20c 100644 --- a/.gitignore +++ b/.gitignore @@ -11,6 +11,8 @@ # Python # ============================================ __pycache__/ +# Auto-generated version file (created during Docker build) +app/version_frozen.py *.py[cod] *$py.class *.so diff --git a/Dockerfile b/Dockerfile index 9e3c7d8..8ae7b4d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -16,6 +16,8 @@ COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt # Copy application code +# Note: Run 'python -m app.version freeze' before build to include version info +# The version_frozen.py file will be copied automatically if it exists COPY app/ ./app/ # Expose Flask port diff --git a/app/__init__.py b/app/__init__.py index c74d306..790db3e 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -1,5 +1,5 @@ """ mc-webui - Flask application package -""" -__version__ = "0.1.0" +Version is managed dynamically via app/version.py based on Git metadata. +""" diff --git a/app/main.py b/app/main.py index 2acb56b..143193a 100644 --- a/app/main.py +++ b/app/main.py @@ -12,6 +12,7 @@ from flask_socketio import SocketIO, emit from app.config import config, runtime_config from app.routes.views import views_bp from app.routes.api import api_bp +from app.version import VERSION_STRING from app.archiver.manager import schedule_daily_archiving from app.meshcore.cli import fetch_device_name_from_bridge @@ -43,6 +44,11 @@ def create_app(): app.config['DEBUG'] = config.FLASK_DEBUG app.config['SECRET_KEY'] = 'mc-webui-secret-key-change-in-production' + # Inject version into all templates + @app.context_processor + def inject_version(): + return {'version': VERSION_STRING} + # Register blueprints app.register_blueprint(views_bp) app.register_blueprint(api_bp) diff --git a/app/routes/api.py b/app/routes/api.py index 75ae31b..1bbaf1b 100644 --- a/app/routes/api.py +++ b/app/routes/api.py @@ -1910,6 +1910,27 @@ def get_read_status_api(): }), 500 +@api_bp.route('/version', methods=['GET']) +def get_version(): + """ + Get application version. + + Returns: + JSON with version info: + { + "success": true, + "version": "2025.01.18+576c8ca9", + "docker_tag": "2025.01.18-576c8ca9" + } + """ + from app.version import VERSION_STRING, DOCKER_TAG + return jsonify({ + 'success': True, + 'version': VERSION_STRING, + 'docker_tag': DOCKER_TAG + }), 200 + + @api_bp.route('/read_status/mark_read', methods=['POST']) def mark_read_api(): """ diff --git a/app/templates/base.html b/app/templates/base.html index e908c12..4e6f6d3 100644 --- a/app/templates/base.html +++ b/app/templates/base.html @@ -58,6 +58,9 @@
Menu
+
+ {{ version }} +