From 7abc3d3c1d9c061aa94a2d8c50ada38843099e43 Mon Sep 17 00:00:00 2001 From: meisnate12 Date: Fri, 20 Sep 2024 13:18:37 -0400 Subject: [PATCH] [39] fix build conflict issues (#2230) --- .github/workflows/increment-build.yml | 11 +++++----- .github/workflows/validate-pull.yml | 29 +++++++++------------------ PART | 1 + VERSION | 2 +- kometa.py | 10 ++++++++- modules/request.py | 15 ++++++-------- 6 files changed, 32 insertions(+), 36 deletions(-) create mode 100644 PART diff --git a/.github/workflows/increment-build.yml b/.github/workflows/increment-build.yml index c93a0100..958af784 100644 --- a/.github/workflows/increment-build.yml +++ b/.github/workflows/increment-build.yml @@ -80,13 +80,10 @@ jobs: old_msg=$(git log -1 HEAD --pretty=format:%s) version="${value%-build*}" + part_value=$(cat PART) + if [[ "$value" == *"-"* ]]; then - value2="${value#*-build}" - if [[ "$value2" == *"."* ]]; then - build_value="$((${value2%.*} + 1))" - else - build_value="$((${value2} + 1))" - fi + build_value="$((${value#*-build} + 1))" else build_value="1" fi @@ -101,9 +98,11 @@ jobs: echo "commit-short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT echo "$new_value" > "VERSION" + echo "" > "PART" git config --local user.email "action@github.com" git config --local user.name "GitHub Action" git add VERSION + git add PART git commit -m "${new_msg}" --amend git push origin nightly --force-with-lease diff --git a/.github/workflows/validate-pull.yml b/.github/workflows/validate-pull.yml index 28eb44b9..f3a6b256 100644 --- a/.github/workflows/validate-pull.yml +++ b/.github/workflows/validate-pull.yml @@ -64,7 +64,7 @@ jobs: if: needs.validate-pull.outputs.build == 'true' && (contains(github.event.pull_request.labels.*.name, 'docker') || contains(github.event.pull_request.labels.*.name, 'tester')) outputs: commit-msg: ${{ steps.update-version.outputs.commit-msg }} - version: ${{ steps.update-version.outputs.version }} + part_value: ${{ steps.update-version.outputs.part_value }} tag-name: ${{ steps.update-version.outputs.tag-name }} extra-text: ${{ steps.update-version.outputs.extra-text }} steps: @@ -106,29 +106,20 @@ jobs: value=$(cat VERSION) old_msg=$(git log -1 HEAD --pretty=format:%s) echo "commit-msg=${old_msg}" >> $GITHUB_OUTPUT - version="${value%-build*}" - - if [[ "$value" == *"-"* ]]; then - value2="${value#*-build}" - if [[ "$value2" == *"."* ]]; then - build_value="${value2%.*}" - part_value="$((${value2#*.} + 1))" - else - build_value="${value#*-build}" - part_value="1" - fi + + part=$(cat PART) + if [ -n "$part" ]; then + new_value="$((${part} + 1))" else - build_value="0" - part_value="1" + new_value="1" fi - new_value="${version}-build${build_value}.${part_value}" - echo "version=${new_value}" >> $GITHUB_OUTPUT + echo "part_value=${new_value}" >> $GITHUB_OUTPUT - echo "$new_value" > "VERSION" + echo "$new_value" > "PART" git config --local user.email "action@github.com" git config --local user.name "GitHub Action" - git add VERSION + git add PART git commit -m "${tag_name} Part: ${part_value}" git push @@ -233,7 +224,7 @@ jobs: uses: Kometa-Team/discord-notifications@master with: webhook_id_token: ${{ secrets.TESTERS_WEBHOOK }} - message: 'New Commit Pushed to `${{ needs.docker-build-pull.outputs.tag-name }}`: ${{ needs.docker-build-pull.outputs.version }}' + message: 'New Commit Pushed to `${{ needs.docker-build-pull.outputs.tag-name }}`: Part ${{ needs.docker-build-pull.outputs.part_value }}' title: ${{ github.event.pull_request.title }} description: ${{ needs.docker-build-pull.outputs.commit-msg }} url: https://github.com/Kometa-Team/${{ vars.REPO_NAME }}/pull/${{ github.event.number }} diff --git a/PART b/PART new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/PART @@ -0,0 +1 @@ + diff --git a/VERSION b/VERSION index 71157251..67d170b2 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2.0.2-build38 +2.0.2-build39 diff --git a/kometa.py b/kometa.py index 63571188..ff5619af 100644 --- a/kometa.py +++ b/kometa.py @@ -232,6 +232,14 @@ with open(os.path.join(os.path.dirname(os.path.abspath(__file__)), "VERSION")) a local_version = line break +local_part = "" +with open(os.path.join(os.path.dirname(os.path.abspath(__file__)), "PART")) as handle: + for line in handle.readlines(): + line = line.strip() + if len(line) > 0: + local_part = line + break + uuid_file = os.path.join(default_dir, "UUID") uuid_num = None if os.path.exists(uuid_file): @@ -265,7 +273,7 @@ def start(attrs): logger.info_center("| . \\ | `--` | | | | | | |____ | | / _____ \\ ") logger.info_center("|__|\\__\\ \\______/ |__| |__| |_______| |__| /__/ \\__\\ ") logger.info("") - my_requests = Requests(local_version, env_branch, git_branch, verify_ssl=False if run_args["no-verify-ssl"] else True) + my_requests = Requests(local_version, local_part, env_branch, git_branch, verify_ssl=False if run_args["no-verify-ssl"] else True) if is_linuxserver or is_docker: system_ver = f"{'Linuxserver' if is_linuxserver else 'Docker'}: {env_branch}" else: diff --git a/modules/request.py b/modules/request.py index d1ad169e..f08e79ae 100644 --- a/modules/request.py +++ b/modules/request.py @@ -40,17 +40,14 @@ def urlparse(data): return parse.urlparse(str(data)) class Version: - def __init__(self, version_string="Unknown"): + def __init__(self, version_string="Unknown", part_string=""): self.full = version_string.replace("develop", "build") version_parts = self.full.split("-build") self.main = version_parts[0] self.build = 0 - self.part = 0 + self.part = int(part_string) if part_string else 0 if len(version_parts) > 1: - sub_parts = str(version_parts[1]).split(".") - self.build = int(sub_parts[0]) - if len(sub_parts) > 1: - self.parts = int(sub_parts[1]) + self.build = int(version_parts[1]) def __bool__(self): return self.full != "Unknown" @@ -59,11 +56,11 @@ class Version: return str(self) def __str__(self): - return self.full + return f"{self.full}.{self.part}" if self.part else self.full class Requests: - def __init__(self, local, env_branch, git_branch, verify_ssl=True): - self.local = Version(local) + def __init__(self, local, part, env_branch, git_branch, verify_ssl=True): + self.local = Version(local, part) self.env_branch = env_branch self.git_branch = git_branch self.image_content_types = ["image/png", "image/jpeg", "image/webp"]