From 278037b8f04036ce28a6ae94ee08c2721f2538bb Mon Sep 17 00:00:00 2001 From: meisnate12 Date: Thu, 19 Jan 2023 10:48:49 -0500 Subject: [PATCH] [7] add version to docker --- .github/workflows/develop.yml | 2 ++ .github/workflows/nightly.yml | 2 ++ Dockerfile | 2 ++ VERSION | 2 +- modules/config.py | 3 ++- modules/util.py | 6 ++++-- plex_meta_manager.py | 4 +++- 7 files changed, 16 insertions(+), 5 deletions(-) diff --git a/.github/workflows/develop.yml b/.github/workflows/develop.yml index b09a26a1..a3fc1d2f 100644 --- a/.github/workflows/develop.yml +++ b/.github/workflows/develop.yml @@ -38,6 +38,8 @@ jobs: with: context: ./ file: ./Dockerfile + build-args: | + "BRANCH=develop" platforms: linux/amd64,linux/arm64,linux/arm/v7 push: true tags: ${{ secrets.DOCKER_HUB_USERNAME }}/plex-meta-manager:develop diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 203d8ca5..7391dd92 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -38,6 +38,8 @@ jobs: with: context: ./ file: ./Dockerfile + build-args: | + "BRANCH=nightly" platforms: linux/amd64,linux/arm64 push: true tags: ${{ secrets.DOCKER_HUB_USERNAME }}/plex-meta-manager:nightly diff --git a/Dockerfile b/Dockerfile index 0a150204..9f486e57 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,6 @@ FROM python:3.11-slim-buster +ARG BRANCH_NAME=master +ENV BRANCH_NAME ${BRANCH_NAME} ENV TINI_VERSION v0.19.0 ENV PMM_DOCKER True COPY . / diff --git a/VERSION b/VERSION index 262a7f89..d05eda44 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.18.3-develop6 +1.18.3-develop7 diff --git a/modules/config.py b/modules/config.py index d0ba1f9e..99b6007e 100644 --- a/modules/config.py +++ b/modules/config.py @@ -114,6 +114,7 @@ class ConfigFile: self.default_dir = default_dir self.read_only = attrs["read_only"] if "read_only" in attrs else False self.version = attrs["version"] if "version" in attrs else None + self.env_version = attrs["env_version"] if "env_version" in attrs else None self.no_missing = attrs["no_missing"] if "no_missing" in attrs else None self.no_report = attrs["no_report"] if "no_report" in attrs else None self.ignore_schedules = attrs["ignore_schedules"] if "ignore_schedules" in attrs else False @@ -385,7 +386,7 @@ class ConfigFile: repo = repo.replace("https://github.com/", "https://raw.githubusercontent.com/").replace("/tree/", "/") self.custom_repo = repo self.check_nightly = self.general["check_nightly"] - self.latest_version = util.current_version(self.version, nightly=self.check_nightly) + self.latest_version = util.current_version(self.version, env_version=self.env_version, nightly=self.check_nightly) self.session = requests.Session() if not self.general["verify_ssl"]: diff --git a/modules/util.py b/modules/util.py index 47339a1d..ce57fadb 100644 --- a/modules/util.py +++ b/modules/util.py @@ -103,9 +103,11 @@ parental_labels = [f"{t.capitalize()}:{v}" for t in parental_types for v in pare previous_time = None start_time = None -def current_version(version, nightly=False): - if nightly: +def current_version(version, env_version=None, nightly=False): + if nightly or env_version == "nightly": return get_nightly() + elif env_version == "develop": + return get_develop() elif version[2] > 0: new_version = get_develop() if version[1] != new_version[1] or new_version[2] >= version[2]: diff --git a/plex_meta_manager.py b/plex_meta_manager.py index f5023aad..af61ef10 100644 --- a/plex_meta_manager.py +++ b/plex_meta_manager.py @@ -76,6 +76,7 @@ def get_arg(env_str, default, arg_bool=False, arg_int=False): else: return default +env_version = get_arg("BRANCH_NAME", "master") is_docker = get_arg("PMM_DOCKER", False, arg_bool=True) is_linuxserver = get_arg("PMM_LINUXSERVER", False, arg_bool=True) run_arg = " ".join([f'"{s}"' if " " in s else s for s in sys.argv[:]]) @@ -192,7 +193,7 @@ def start(attrs): logger.info_center(" |___/ ") system_ver = "Docker" if is_docker else "Linuxserver" if is_linuxserver else f"Python {platform.python_version()}" logger.info(f" Version: {version[0]} ({system_ver})") - latest_version = util.current_version(version) + latest_version = util.current_version(version, env_version=env_version) new_version = latest_version[0] if latest_version and (version[1] != latest_version[1] or (version[2] and version[2] < latest_version[2])) else None if new_version: logger.info(f" Newest Version: {new_version}") @@ -209,6 +210,7 @@ def start(attrs): attrs["time_obj"] = start_time attrs["read_only"] = read_only_config attrs["version"] = version + attrs["env_version"] = env_version attrs["no_missing"] = no_missing attrs["no_report"] = no_report attrs["collection_only"] = collection_only