diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 4ada1e0..a5b218e 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -58,7 +58,8 @@ jobs: build-args: | MAINTAINER=${{ github.repository_owner }} BRANCH=${{ github.ref_name }} - SOURCE_COMMIT=${{ github.sha }} + BUILD_SHA=${{ github.sha }} + BUILD_TAG=${{ github.ref }} context: . platforms: | linux/amd64 diff --git a/Dockerfile b/Dockerfile index cae8042..18b6e17 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,6 +13,12 @@ RUN pip install flask apscheduler requests treelib # 时区 ENV TZ="Asia/Shanghai" +#构建版本 +ARG BUILD_SHA +ARG BUILD_TAG +ENV BUILD_SHA=$BUILD_SHA +ENV BUILD_TAG=$BUILD_TAG + # 端口 EXPOSE 5005 diff --git a/app/run.py b/app/run.py index a3316c9..08bb973 100644 --- a/app/run.py +++ b/app/run.py @@ -19,13 +19,22 @@ import os +def get_app_ver(): + BUILD_SHA = os.environ.get("BUILD_SHA", "") + BUILD_TAG = os.environ.get("BUILD_TAG", "") + if BUILD_TAG[:1] == "v": + return BUILD_TAG + else: + return f"{BUILD_TAG}({BUILD_SHA[:7]})" + + # 文件路径 python_path = "python3" if os.path.exists("/usr/bin/python3") else "python" script_path = os.environ.get("SCRIPT_PATH", "./quark_auto_save.py") config_path = os.environ.get("CONFIG_PATH", "./config/quark_config.json") app = Flask(__name__) -app.config["APP_VERSION"] = "0.2.9.2" +app.config["APP_VERSION"] = get_app_ver() app.secret_key = "ca943f6db6dd34823d36ab08d8d6f65d" app.json.ensure_ascii = False app.json.sort_keys = False