Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pixi.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[project]
[workspace]
name = "copier-template-python-open-source"
description = "Copier template for python projects using pixi"
channels = ["conda-forge"]
Expand Down
22 changes: 20 additions & 2 deletions scripts/common.py
Original file line number Diff line number Diff line change
@@ -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
6 changes: 1 addition & 5 deletions scripts/update_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand Down
2 changes: 1 addition & 1 deletion template/.github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions template/.github/workflows/ci.yml.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down