From 199d8453ebc4a36d9388107529051f0705b39582 Mon Sep 17 00:00:00 2001 From: CaliBrain Date: Sat, 30 Aug 2025 03:10:15 -0400 Subject: [PATCH] Adding Release version (#263) --- .github/workflows/build-and-publish-docker-image.yml | 1 + Dockerfile | 2 ++ app.py | 11 +++++++++-- entrypoint.sh | 1 + env.py | 7 ++++++- genDebug.sh | 2 +- templates/index.html | 7 ++++++- tor.sh | 1 + 8 files changed, 27 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build-and-publish-docker-image.yml b/.github/workflows/build-and-publish-docker-image.yml index 3115aafe..c7b6277a 100644 --- a/.github/workflows/build-and-publish-docker-image.yml +++ b/.github/workflows/build-and-publish-docker-image.yml @@ -70,6 +70,7 @@ jobs: push: ${{ github.event_name != 'pull_request' }} build-args: | BUILD_VERSION=${{ steps.date.outputs.date }}-${{ github.sha }} + RELEASE_VERSION=${{ github.ref_name }} tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} diff --git a/Dockerfile b/Dockerfile index 0d44ca1e..3827ccb7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,6 +4,8 @@ FROM python:3.10-slim AS base # Add build argument for version ARG BUILD_VERSION ENV BUILD_VERSION=${BUILD_VERSION} +ARG RELEASE_VERSION +ENV RELEASE_VERSION=${RELEASE_VERSION} # Set shell to bash with pipefail option SHELL ["/bin/bash", "-o", "pipefail", "-c"] diff --git a/app.py b/app.py index d03db2c2..7b80685f 100644 --- a/app.py +++ b/app.py @@ -13,7 +13,7 @@ import typing from logger import setup_logger from config import _SUPPORTED_BOOK_LANGUAGE, BOOK_LANGUAGE -from env import FLASK_HOST, FLASK_PORT, APP_ENV, CWA_DB_PATH, DEBUG, USING_EXTERNAL_BYPASSER +from env import FLASK_HOST, FLASK_PORT, APP_ENV, CWA_DB_PATH, DEBUG, USING_EXTERNAL_BYPASSER, BUILD_VERSION, RELEASE_VERSION import backend from models import SearchFilters @@ -103,7 +103,14 @@ def index() -> str: """ Render main page with search and status table. """ - return render_template('index.html', book_languages=_SUPPORTED_BOOK_LANGUAGE, default_language=BOOK_LANGUAGE, debug=DEBUG) + return render_template('index.html', + book_languages=_SUPPORTED_BOOK_LANGUAGE, + default_language=BOOK_LANGUAGE, + debug=DEBUG, + build_version=BUILD_VERSION, + release_version=RELEASE_VERSION, + app_env=APP_ENV + ) diff --git a/entrypoint.sh b/entrypoint.sh index 1ff25e5c..8c9791ec 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -20,6 +20,7 @@ set -e # Print build version echo "Build version: $BUILD_VERSION" +echo "Release version: $RELEASE_VERSION" # Configure timezone if [ "$TZ" ]; then diff --git a/env.py b/env.py index 43df8e6f..c825bb8f 100644 --- a/env.py +++ b/env.py @@ -26,8 +26,13 @@ _CUSTOM_SCRIPT = os.getenv("CUSTOM_SCRIPT", "").strip() FLASK_HOST = os.getenv("FLASK_HOST", "0.0.0.0") FLASK_PORT = int(os.getenv("FLASK_PORT", "8084")) DEBUG = string_to_bool(os.getenv("DEBUG", "false")) +APP_ENV = os.getenv("APP_ENV", "N/A").lower() PRIORITIZE_WELIB = string_to_bool(os.getenv("PRIORITIZE_WELIB", "false")) +# Version information from Docker build +BUILD_VERSION = os.getenv("BUILD_VERSION", "N/A") +RELEASE_VERSION = os.getenv("RELEASE_VERSION", "N/A") + # If debug is true, we want to log everything if DEBUG: LOG_LEVEL = "DEBUG" @@ -41,7 +46,7 @@ DOCKERMODE = string_to_bool(os.getenv("DOCKERMODE", "false")) _CUSTOM_DNS = os.getenv("CUSTOM_DNS", "").strip() USE_DOH = string_to_bool(os.getenv("USE_DOH", "false")) BYPASS_RELEASE_INACTIVE_MIN = int(os.getenv("BYPASS_RELEASE_INACTIVE_MIN", "5")) -APP_ENV = os.getenv("APP_ENV", "prod").lower() + # Logging settings LOG_FILE = LOG_DIR / "cwa-book-downloader.log" diff --git a/genDebug.sh b/genDebug.sh index 1f91c24e..3c345217 100755 --- a/genDebug.sh +++ b/genDebug.sh @@ -3,7 +3,7 @@ # Set up log paths LOG_ROOT=${LOG_ROOT:-"/var/log"} LOG_DIR="$LOG_ROOT/cwa-book-downloader" -OUTPUT_FILE_NAME="cwa-book-downloader-debug_BUILD-${BUILD_VERSION:-local}_$(date +%Y%m%d-%H%M%S)" +OUTPUT_FILE_NAME="cwa-book-downloader-debug_BUILD-${BUILD_VERSION:-local}_RELEASE-${RELEASE_VERSION:-NA}_$(date +%Y%m%d-%H%M%S)" OUTPUT_FILE="/tmp/$OUTPUT_FILE_NAME.zip" # Create LOG_DIR if it doesn't exist diff --git a/templates/index.html b/templates/index.html index 023a868d..169cec7f 100644 --- a/templates/index.html +++ b/templates/index.html @@ -193,7 +193,12 @@