Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
7 changes: 7 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,19 @@ on:
branches-ignore:
- gh-readonly-queue/** # Temporary merge queue-related GH-made branches
pull_request:
types:
- opened # default
- synchronize # default
- reopened # default
- ready_for_review # used in PRs created from GitHub Actions workflows
workflow_call:

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: true

permissions: {}

jobs:
build:
name: ${{ matrix.noxenv }}
Expand Down
43 changes: 43 additions & 0 deletions .github/workflows/update-uv-build-version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
---

name: Update uv build version

on:
schedule:
- cron: "0 6 * * 1" # mondays at 6am
workflow_dispatch:

jobs:
update-uv-build-version:
name: Update uv_build version
if: github.repository_owner == 'pypa' # suppress noise in forks
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Set up uv
uses: astral-sh/setup-uv@v5
- name: Update uv_build version
id: update_script
run: uv run scripts/update_uv_build_version.py
- # If there are no changes, no pull request will be created and the action exits silently.
name: Create Pull Request
uses: peter-evans/create-pull-request@v7
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: Update uv_build version to ${{ steps.update_script.outputs.version }}
title: Update uv_build version to ${{ steps.update_script.outputs.version }}
draft: true # Trigger CI by un-drafting the PR, otherwise `GITHUB_TOKEN` PRs don't trigger CI.
body: |
Automated update of uv_build version bounds for uv ${{ steps.update_script.outputs.version }}.

This PR was created automatically by the cron workflow, ping `@konstin` for problems.
branch: bot/update-uv-build-version
delete-branch: true

...
64 changes: 64 additions & 0 deletions scripts/update_uv_build_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# /// script
# requires-python = ">= 3.12"
# dependencies = [
# "httpx>=0.28.1,<0.29",
# "packaging>=25.0",
# ]
# ///
import os
import re
from pathlib import Path

import httpx
from packaging.utils import parse_wheel_filename
from packaging.version import Version


def main():
response = httpx.get(
"https://pypi.org/simple/uv-build/",
headers={"Accept": "application/vnd.pypi.simple.v1+json"},
)
response.raise_for_status()
data = response.json()
current_release = None
for file in data["files"]:
if not file["filename"].endswith(".whl"):
continue
_name, version, _build, _tags = parse_wheel_filename(file["filename"])
if version.is_prerelease:
continue
if current_release is None or version > current_release:
current_release = version

[major, minor, _patch] = current_release.release
if major != 0:
raise NotImplementedError("The script needs to be updated for uv 1.x")
upper_bound = Version(f"{major}.{minor + 1}.0")

repository_root = Path(__file__).parent.parent
existing = repository_root.joinpath(
"source/shared/build-backend-tabs.rst"
).read_text()
replacement = f'requires = ["uv_build >= {current_release}, <{upper_bound}"]'
searcher = re.compile(re.escape('requires = ["uv_build') + ".*" + re.escape('"]'))
if not searcher.search(existing):
raise RuntimeError("Could not `uv-build` entry")
updated = searcher.sub(replacement, existing)

if existing != updated:
print("Updating source/shared/build-backend-tabs.rst")
Path("source/shared/build-backend-tabs.rst").write_text(updated)
if github_output := os.environ.get("GITHUB_OUTPUT"):
with open(github_output, "a") as f:
f.write(f"version={current_release}\n")
f.write("updated=true\n")
else:
print("Already up-to-date source/shared/build-backend-tabs.rst")
if github_output := os.environ.get("GITHUB_OUTPUT"):
with open(github_output, "a") as f:
f.write("updated=false\n")


if __name__ == "__main__":
main()