Skip to content

Commit afe0436

Browse files
authored
Fix tag updating (#98)
1 parent f632482 commit afe0436

File tree

7 files changed

+27
-13
lines changed

7 files changed

+27
-13
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
* @pavelzw @borchero
1+
* @pavelzw @borchero @ytausch

pixi.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[project]
1+
[workspace]
22
name = "copier-template-python-open-source"
33
description = "Copier template for python projects using pixi"
44
channels = ["conda-forge"]

scripts/common.py

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,27 @@
1+
# Copyright (c) QuantCo 2024-2025
2+
# SPDX-License-Identifier: LicenseRef-QuantCo
3+
14
import json
5+
import re
26
import subprocess
37

8+
TAG_REGEX = r"^v(\d+)\.(\d+)\.(\d+)$"
9+
410

511
def get_latest_github_tag(repo_name: str) -> tuple[str, str]:
612
output = subprocess.check_output(["gh", "api", f"repos/{repo_name}/tags"])
713

8-
latest_tag = json.loads(output)[0]
9-
return latest_tag["name"], latest_tag["commit"]["sha"]
14+
# This is a heuristic to get the "latest" tag.
15+
# Unfortunately, you cannot query the GitHub API for the latest release
16+
# because of things like https://github.com/actions/github-script/issues/676.
17+
all_tags = set()
18+
for tag in json.loads(output):
19+
tag_name = tag["name"]
20+
if match := re.match(TAG_REGEX, tag_name):
21+
major, minor, patch = match.groups()
22+
all_tags.add(
23+
(tag_name, tag["commit"]["sha"], (int(major), int(minor), int(patch)))
24+
)
25+
26+
tag_name, commit, _ = max(all_tags, key=lambda x: x[2])
27+
return tag_name, commit

scripts/update_actions.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,7 @@ def update_workflow_actions(file_path: Path):
2121
current_sha = current_sha.strip()
2222
current_version = current_version.strip()
2323
new_version, new_sha = get_latest_github_tag(action_repo)
24-
print(
25-
f"{action}:"
26-
f" current version: {current_version},"
27-
f" latest version: {new_version}"
28-
)
24+
print(f"{action}: {current_version} -> {new_version}")
2925
new_line = line.replace(current_sha, new_sha).replace(
3026
current_version, new_version
3127
)

template/.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
with:
1818
fetch-depth: 0
1919
- name: Set up pixi
20-
uses: prefix-dev/setup-pixi@28eb668aafebd9dede9d97c4ba1cd9989a4d0004 # v0.9.2
20+
uses: prefix-dev/setup-pixi@82d477f15f3a381dbcc8adc1206ce643fe110fb7 # v0.9.3
2121
with:
2222
environments: build
2323
- name: Build project

template/.github/workflows/ci.yml.jinja

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
- name: Checkout branch
2323
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
2424
- name: Set up pixi
25-
uses: prefix-dev/setup-pixi@28eb668aafebd9dede9d97c4ba1cd9989a4d0004 # v0.9.2
25+
uses: prefix-dev/setup-pixi@82d477f15f3a381dbcc8adc1206ce643fe110fb7 # v0.9.3
2626
with:
2727
environments: default lint
2828
- name: pre-commit
@@ -51,7 +51,7 @@ jobs:
5151
with:
5252
fetch-depth: 0
5353
- name: Set up pixi
54-
uses: prefix-dev/setup-pixi@28eb668aafebd9dede9d97c4ba1cd9989a4d0004 # v0.9.2
54+
uses: prefix-dev/setup-pixi@82d477f15f3a381dbcc8adc1206ce643fe110fb7 # v0.9.3
5555
with:
5656
environments: ${{ matrix.environment }}
5757
- name: Install repository

template/.github/workflows/{% if add_autobump_workflow %}update-lockfiles.yml{% endif %}

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
steps:
1515
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
1616
- name: Set up pixi
17-
uses: prefix-dev/setup-pixi@28eb668aafebd9dede9d97c4ba1cd9989a4d0004 # v0.9.2
17+
uses: prefix-dev/setup-pixi@82d477f15f3a381dbcc8adc1206ce643fe110fb7 # v0.9.3
1818
with:
1919
run-install: false
2020
- name: Update lockfiles

0 commit comments

Comments
 (0)