diff --git a/.github/workflows/manual-build.yml b/.github/workflows/manual-build.yml index 207a3ec..beb7ef2 100644 --- a/.github/workflows/manual-build.yml +++ b/.github/workflows/manual-build.yml @@ -24,6 +24,18 @@ jobs: version=$(python3 -c "import version; print(f'dev-{version.__version__}')") echo "VERSION=$version" >> $GITHUB_ENV + # Extract branch name and latest commit SHA + - name: Extract branch name and commit SHA + id: branch_info + run: | + echo "BRANCH_NAME=${{ github.event.inputs.branch }}" >> $GITHUB_ENV + echo "COMMIT_SHA=$(git rev-parse --short HEAD)" >> $GITHUB_ENV + + # Create a file indicating this is a dev build + - name: Create DEV_BUILD file + run: | + echo "${{ env.BRANCH_NAME }}-${{ env.COMMIT_SHA }}" > DEV_BUILD + # Set up Docker - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 diff --git a/app/__init__.py b/app/__init__.py index 89ed81a..f16fec0 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -139,13 +139,19 @@ app.config.update( result_backend=app.config['REDIS_URL'] ) - +def read_dev_build_file(file_path="/jellyplist/DEV_BUILD"): + if os.path.exists(file_path): + with open(file_path, "r") as file: + content = file.read().strip() + return f"-{content}" + else: + return None app.logger.info(f"initializing celery") celery = make_celery(app) socketio = SocketIO(app, message_queue=app.config['REDIS_URL'], async_mode='eventlet') celery.set_default() -app.logger.info(f'Jellyplist {__version__} started') +app.logger.info(f'Jellyplist {__version__}{read_dev_build_file()} started') from app import routes from app import jellyfin_routes, tasks if "worker" in sys.argv: diff --git a/app/routes.py b/app/routes.py index 8c44be5..d460aee 100644 --- a/app/routes.py +++ b/app/routes.py @@ -1,5 +1,5 @@ from flask import Flask, Response, jsonify, render_template, request, redirect, url_for, session, flash -from app import app, db, functions, sp, jellyfin, celery, jellyfin_admin_token, jellyfin_admin_id,device_id, cache +from app import app, db, functions, sp, jellyfin, celery, jellyfin_admin_token, jellyfin_admin_id,device_id, cache, read_dev_build_file from app.models import JellyfinUser,Playlist,Track from celery.result import AsyncResult from .version import __version__ @@ -7,7 +7,7 @@ from .version import __version__ @app.context_processor def add_context(): unlinked_track_count = len(Track.query.filter_by(downloaded=True,jellyfin_id=None).all()) - version = f"v{__version__}" + version = f"v{__version__}{read_dev_build_file()}" return dict(unlinked_track_count = unlinked_track_count, version = version) @app.after_request