From 1751eecd8a91ed8f5acdd55c9b811aac9e78e537 Mon Sep 17 00:00:00 2001 From: Pavel Zwerschke Date: Tue, 4 Nov 2025 10:33:10 +0100 Subject: [PATCH 1/3] Fix tag updating --- pixi.toml | 2 +- scripts/common.py | 17 +++++++++++++++-- scripts/update_actions.py | 6 +----- template/.github/workflows/build.yml | 2 +- template/.github/workflows/ci.yml.jinja | 4 ++-- ...p_workflow %}update-lockfiles.yml{% endif %} | 2 +- 6 files changed, 21 insertions(+), 12 deletions(-) diff --git a/pixi.toml b/pixi.toml index 2bd76ba..a6a48f2 100644 --- a/pixi.toml +++ b/pixi.toml @@ -1,4 +1,4 @@ -[project] +[workspace] name = "copier-template-python-open-source" description = "Copier template for python projects using pixi" channels = ["conda-forge"] diff --git a/scripts/common.py b/scripts/common.py index 0e2dfea..753d1d4 100644 --- a/scripts/common.py +++ b/scripts/common.py @@ -1,9 +1,22 @@ +# Copyright (c) QuantCo 2024-2025 +# SPDX-License-Identifier: LicenseRef-QuantCo + import json +import re import subprocess +TAG_REGEX = r"^v\d+\.\d+\.\d+$" + def get_latest_github_tag(repo_name: str) -> tuple[str, str]: output = subprocess.check_output(["gh", "api", f"repos/{repo_name}/tags"]) - latest_tag = json.loads(output)[0] - return latest_tag["name"], latest_tag["commit"]["sha"] + # This is a heuristic to get the "latest" tag. + # Unfortunately, you cannot query the GitHub API for the latest release + # because of things like https://github.com/actions/github-script/issues/676. + for tag in json.loads(output): + tag_name = tag["name"] + if re.match(TAG_REGEX, tag_name): + return tag_name, tag["commit"]["sha"] + + raise ValueError("No valid tag found") diff --git a/scripts/update_actions.py b/scripts/update_actions.py index 34f0c57..ccfbf25 100644 --- a/scripts/update_actions.py +++ b/scripts/update_actions.py @@ -21,11 +21,7 @@ def update_workflow_actions(file_path: Path): current_sha = current_sha.strip() current_version = current_version.strip() new_version, new_sha = get_latest_github_tag(action_repo) - print( - f"{action}:" - f" current version: {current_version}," - f" latest version: {new_version}" - ) + print(f"{action}: {current_version} -> {new_version}") new_line = line.replace(current_sha, new_sha).replace( current_version, new_version ) diff --git a/template/.github/workflows/build.yml b/template/.github/workflows/build.yml index 8c867fc..14c1c05 100644 --- a/template/.github/workflows/build.yml +++ b/template/.github/workflows/build.yml @@ -17,7 +17,7 @@ jobs: with: fetch-depth: 0 - name: Set up pixi - uses: prefix-dev/setup-pixi@28eb668aafebd9dede9d97c4ba1cd9989a4d0004 # v0.9.2 + uses: prefix-dev/setup-pixi@82d477f15f3a381dbcc8adc1206ce643fe110fb7 # v0.9.3 with: environments: build - name: Build project diff --git a/template/.github/workflows/ci.yml.jinja b/template/.github/workflows/ci.yml.jinja index 7a06065..1485dab 100644 --- a/template/.github/workflows/ci.yml.jinja +++ b/template/.github/workflows/ci.yml.jinja @@ -22,7 +22,7 @@ jobs: - name: Checkout branch uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 - name: Set up pixi - uses: prefix-dev/setup-pixi@28eb668aafebd9dede9d97c4ba1cd9989a4d0004 # v0.9.2 + uses: prefix-dev/setup-pixi@82d477f15f3a381dbcc8adc1206ce643fe110fb7 # v0.9.3 with: environments: default lint - name: pre-commit @@ -51,7 +51,7 @@ jobs: with: fetch-depth: 0 - name: Set up pixi - uses: prefix-dev/setup-pixi@28eb668aafebd9dede9d97c4ba1cd9989a4d0004 # v0.9.2 + uses: prefix-dev/setup-pixi@82d477f15f3a381dbcc8adc1206ce643fe110fb7 # v0.9.3 with: environments: ${{ matrix.environment }} - name: Install repository diff --git a/template/.github/workflows/{% if add_autobump_workflow %}update-lockfiles.yml{% endif %} b/template/.github/workflows/{% if add_autobump_workflow %}update-lockfiles.yml{% endif %} index 46969db..d994c8c 100644 --- a/template/.github/workflows/{% if add_autobump_workflow %}update-lockfiles.yml{% endif %} +++ b/template/.github/workflows/{% if add_autobump_workflow %}update-lockfiles.yml{% endif %} @@ -14,7 +14,7 @@ jobs: steps: - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 - name: Set up pixi - uses: prefix-dev/setup-pixi@28eb668aafebd9dede9d97c4ba1cd9989a4d0004 # v0.9.2 + uses: prefix-dev/setup-pixi@82d477f15f3a381dbcc8adc1206ce643fe110fb7 # v0.9.3 with: run-install: false - name: Update lockfiles From d7ed4e72104e80b84144995f03452acdc92ff109 Mon Sep 17 00:00:00 2001 From: Pavel Zwerschke Date: Tue, 4 Nov 2025 10:49:29 +0100 Subject: [PATCH 2/3] sort tags --- scripts/common.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/scripts/common.py b/scripts/common.py index 753d1d4..d75a9db 100644 --- a/scripts/common.py +++ b/scripts/common.py @@ -5,7 +5,7 @@ import re import subprocess -TAG_REGEX = r"^v\d+\.\d+\.\d+$" +TAG_REGEX = r"^v(\d+)\.(\d+)\.(\d+)$" def get_latest_github_tag(repo_name: str) -> tuple[str, str]: @@ -14,9 +14,14 @@ def get_latest_github_tag(repo_name: str) -> tuple[str, str]: # This is a heuristic to get the "latest" tag. # Unfortunately, you cannot query the GitHub API for the latest release # because of things like https://github.com/actions/github-script/issues/676. + all_tags = set() for tag in json.loads(output): tag_name = tag["name"] - if re.match(TAG_REGEX, tag_name): - return tag_name, tag["commit"]["sha"] + if match := re.match(TAG_REGEX, tag_name): + major, minor, patch = match.groups() + all_tags.add( + (tag_name, tag["commit"]["sha"], (int(major), int(minor), int(patch))) + ) - raise ValueError("No valid tag found") + tag_name, commit, _ = max(all_tags, key=lambda x: x[2]) + return tag_name, commit From c3c9d90ad7d07eabad3f740e3f3bb8e27bdc9a08 Mon Sep 17 00:00:00 2001 From: Pavel Zwerschke Date: Tue, 4 Nov 2025 10:52:34 +0100 Subject: [PATCH 3/3] add @ytausch to codeowners --- .github/CODEOWNERS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 4436d89..114b49a 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1 +1 @@ -* @pavelzw @borchero +* @pavelzw @borchero @ytausch