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 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..d75a9db 100644 --- a/scripts/common.py +++ b/scripts/common.py @@ -1,9 +1,27 @@ +# 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. + all_tags = set() + for tag in json.loads(output): + tag_name = tag["name"] + 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))) + ) + + tag_name, commit, _ = max(all_tags, key=lambda x: x[2]) + return tag_name, commit 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