Skip to content

Commit d065c8a

Browse files
authored
Merge pull request #2 from samuelcolvin/uv
switch to uv
2 parents 758a13b + 9e136dd commit d065c8a

File tree

9 files changed

+73
-41
lines changed

9 files changed

+73
-41
lines changed

.github/workflows/ci.yml

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,51 +5,45 @@ on:
55
branches:
66
- main
77
tags:
8-
- '**'
8+
- "**"
99
pull_request: {}
1010

11+
env:
12+
UV_PYTHON: 3.13
13+
UV_FROZEN: "1"
14+
1115
jobs:
12-
test-docker:
16+
test-package:
1317
runs-on: ubuntu-latest
1418

1519
steps:
16-
- uses: actions/checkout@v3
20+
- uses: actions/checkout@v4
1721

18-
- run: docker build . -t check-python-version
22+
- uses: astral-sh/setup-uv@v6
23+
with:
24+
enable-cache: true
1925

2026
- run: |
2127
mkdir foobar
2228
echo "VERSION = '1.0a1'" > foobar/version.py
2329
24-
- run: >
25-
docker run --rm
26-
-e INPUT_TEST_GITHUB_REF
27-
-e INPUT_VERSION_FILE_PATH
28-
-e ALT_GITHUB_OUTPUT
29-
-v `pwd`:/app
30-
check-python-version
30+
- run: uv run main.py
3131
env:
3232
# we can't use GITHUB_REF, so we use the backup var name
3333
INPUT_TEST_GITHUB_REF: refs/tags/v1.0.0a1
3434
INPUT_VERSION_FILE_PATH: foobar/version.py
35-
ALT_GITHUB_OUTPUT: /app/output1.txt
35+
ALT_GITHUB_OUTPUT: output1.txt
3636

3737
- run: cat output1.txt
3838
- run: grep -q 'IS_PRERELEASE=true' output1.txt
3939
- run: grep -q 'VERSION=1.0a1' output1.txt
4040

4141
- run: echo "VERSION = '1.1.1'" > foobar/version.py
42-
- run: >
43-
docker run --rm
44-
-e INPUT_SKIP_ENV_CHECK
45-
-e INPUT_VERSION_FILE_PATH
46-
-e ALT_GITHUB_OUTPUT
47-
-v `pwd`:/app
48-
check-python-version
42+
- run: uv run main.py
4943
env:
5044
INPUT_SKIP_ENV_CHECK: true
5145
INPUT_VERSION_FILE_PATH: foobar/version.py
52-
ALT_GITHUB_OUTPUT: /app/output2.txt
46+
ALT_GITHUB_OUTPUT: output2.txt
5347

5448
- run: cat output2.txt
5549
- run: grep -q 'IS_PRERELEASE=false' output2.txt

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
/.idea/
44
*.py[cod]
55
/foobar/
6+
.python-version

Dockerfile

Lines changed: 0 additions & 12 deletions
This file was deleted.

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ Check the release tag matches the library version before deploy.
77
This is designed to be used in deploy jobs to check that GitHub release tag matches the version in your code.
88

99
The following output variables are set by the action for use in later steps:
10-
* `IS_PRERELEASE`, either `'true'` or `'false'` whether the version is a pre-release,
10+
* `IS_PRERELEASE`, either `'true'` or `'false'` whether the version is a pre-release,
1111
uses [`packing.Version.is_prerelease`](https://packaging.pypa.io/en/latest/version.html#usage)
12-
* `VERSION`, which is the "pretty" version string,
12+
* `VERSION`, which is the "pretty" version string,
1313
using [`str(packing.Version)`](https://packaging.pypa.io/en/latest/version.html#usage)
1414
* `VERSION_MAJOR_MINOR`, major and minor version numbers, e.g. `1.2.3` would output `1.2`
1515

@@ -25,7 +25,7 @@ jobs:
2525
deploy:
2626
steps:
2727
- ...
28-
- uses: samuelcolvin/check-python-version@v1
28+
- uses: samuelcolvin/check-python-version@v5
2929
id: check-python-version
3030
with:
3131
version_file_path: mypackage/version.py
@@ -42,8 +42,8 @@ jobs:
4242
4343
* **`version_file_path`**: Path to python file containing the version number string (**required**)
4444
* **`version_pattern`**: Custom regular expression to find version with,
45-
defaults to `(?i)^(__version__|VERSION) *= *([\'"])v?(?P<version>.+?)\2`
45+
defaults to `(?i)^(__version__|VERSION) *= *([\'"])v?(?P<version>.+?)\2`
4646
(which matches [hatchling](https://hatch.pypa.io/latest/plugins/build-hook/version/))
4747
* **`test_github_ref`**: Version to check, defaults to using `GITHUB_REF` - this is mostly for testing
48-
* **`skip_env_check`**: Set to "true" to skip environment variable (e.g. `GITHUB_REF`, or `input.test_github_ref`)
48+
* **`skip_env_check`**: Set to "true" to skip environment variable (e.g. `GITHUB_REF`, or `input.test_github_ref`)
4949
check, mostly useful when you want to use outputs in later steps

action.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,14 @@ inputs:
2121
required: false
2222

2323
runs:
24-
using: docker
25-
image: Dockerfile
24+
using: composite
25+
steps:
26+
- uses: astral-sh/setup-uv@v6
27+
with:
28+
enable-cache: true
29+
python-version: 3.13
30+
- run: uv run main.py
31+
shell: bash
2632

2733
branding:
2834
icon: check-circle

main.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#!/usr/bin/env python3
21
import os
32
import re
43
import sys

pyproject.toml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
[project]
2+
name = "check-python-version"
3+
version = "5.0"
4+
description = "Check the release tag matches the library version before deploy."
5+
readme = "README.md"
6+
requires-python = ">=3.12"
7+
dependencies = ["packaging>=25.0"]
8+
9+
[tool.ruff]
10+
line-length = 120
11+
target-version = "py312"
12+
13+
[tool.ruff.lint]
14+
extend-select = ["Q", "RUF100", "C90", "UP", "I"]
15+
flake8-quotes = { inline-quotes = "single", multiline-quotes = "double" }
16+
isort = { combine-as-imports = true }
17+
mccabe = { max-complexity = 18 }
18+
19+
[tool.ruff.format]
20+
# don't format python in docstrings, pytest-examples takes care of it
21+
docstring-code-format = false
22+
quote-style = "single"

requirements.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

uv.lock

Lines changed: 23 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)