Skip to content

Commit 906cdce

Browse files
replaces build backend with uv and automates release.
Co-authored-by: Piotr Kaznowski <piotr@kazno.dev>
1 parent 99d8499 commit 906cdce

8 files changed

Lines changed: 343 additions & 17 deletions

File tree

.github/workflows/release.yml

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*.*.*'
7+
workflow_dispatch:
8+
9+
jobs:
10+
test:
11+
uses: ./.github/workflows/test.yml
12+
13+
build_package:
14+
runs-on: ubuntu-latest
15+
needs: test
16+
steps:
17+
- name: Checkout code
18+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
19+
20+
- name: Set up Python
21+
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
22+
with:
23+
python-version: '3.13'
24+
25+
- name: Install uv
26+
uses: astral-sh/setup-uv@bd01e18f51369d5a26f1651c3cb451d3417e3bba # v6.3.1
27+
28+
- name: Check tag matches pyproject.toml version
29+
run: |
30+
TAG_VERSION="${GITHUB_REF##*/}"
31+
TAG_VERSION_NO_PREFIX="${TAG_VERSION#v}"
32+
echo "Tag version: $TAG_VERSION (stripped: $TAG_VERSION_NO_PREFIX)"
33+
PYPROJECT_VERSION=$(grep '^version =' pyproject.toml | sed 's/version = "\(.*\)"/\1/')
34+
echo "pyproject.toml version: $PYPROJECT_VERSION"
35+
if [ "$TAG_VERSION_NO_PREFIX" != "$PYPROJECT_VERSION" ]; then
36+
echo "Tag version ($TAG_VERSION_NO_PREFIX) does not match pyproject.toml version ($PYPROJECT_VERSION)" >&2
37+
exit 1
38+
fi
39+
shell: bash
40+
41+
- name: Build package
42+
run: uv build
43+
44+
- name: Publish to PyPI
45+
uses: pypa/gh-action-pypi-publish@release/v1
46+
with:
47+
user: __token__
48+
password: ${{ secrets.PYPI_API_TOKEN }}
49+
50+
- name: Upload Python artifacts
51+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
52+
with:
53+
name: python-dist
54+
path: dist/
55+
56+
create_release:
57+
runs-on: ubuntu-latest
58+
needs: build_package
59+
steps:
60+
- name: Download Python artifacts
61+
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
62+
with:
63+
name: python-dist
64+
path: dist/
65+
66+
- name: Create Release
67+
uses: softprops/action-gh-release@72f2c25fcb47643c292f7107632f7a47c1df5cd8 # v2.3.2
68+
with:
69+
files: |
70+
dist/*
71+
env:
72+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
name: Test
22

3-
on: [push, pull_request]
3+
on:
4+
push:
5+
branches: [ master ]
6+
pull_request:
7+
branches: [ master ]
8+
workflow_call:
49

510
jobs:
611
build:
@@ -19,16 +24,14 @@ jobs:
1924
with:
2025
python-version: ${{ matrix.python-version }}
2126

27+
- name: Install uv
28+
uses: astral-sh/setup-uv@bd01e18f51369d5a26f1651c3cb451d3417e3bba # v6.3.1
2229

2330
- name: Install dependencies
24-
run: |
25-
python -m pip install --upgrade pip
26-
python -m pip install -r requirements-dev.txt
31+
run: uv sync --extra dev
2732

2833
- name: Test with pytest
29-
run: |
30-
pytest
34+
run: uv run pytest
3135

3236
- name: Check coverage
33-
run: |
34-
pytest --cov=snakesay --cov-fail-under=65
37+
run: uv run pytest --cov=snakesay --cov-fail-under=65

pyproject.toml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,12 @@ classifiers = [
2020
[project.scripts]
2121
snakesay = "snakesay.snakesay:main"
2222

23-
[build-system]
24-
requires = ["setuptools>=77.0.3", "wheel"]
25-
build-backend = "setuptools.build_meta"
23+
[project.optional-dependencies]
24+
dev = [
25+
"pytest",
26+
"pytest-cov"
27+
]
2628

29+
[build-system]
30+
requires = ["uv_build>=0.8.14,<0.9.0"]
31+
build-backend = "uv_build"

pytest.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
[pytest]
2-
pythonpath = .
2+
pythonpath = ./src

requirements-dev.txt

Lines changed: 0 additions & 2 deletions
This file was deleted.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
from snakesay.snakesay import snakesay
22

3-
__version__ = "0.10.3"
3+
__version__ = "0.10.4"
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ def rewrap(speech: str) -> Tuple[List[str], int]:
4343
return [line.ljust(width) for line in lines], width
4444

4545

46-
def main():
46+
def main(): # pragma: no cover
4747
print(snakesay(*sys.argv[1:]))
4848

4949

50-
if __name__ == '__main__':
50+
if __name__ == '__main__': # pragma: no cover
5151
main()

uv.lock

Lines changed: 248 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)