1414 - ' gh-pages' # GitHub Pages do not trigger all tests
1515 tags-ignore :
1616 - ' v*' # Avoid re-running existing commit on release
17- pull_request :
18- branches :
19- - ' main'
2017
2118permissions :
2219 contents : read
2522 FORCE_COLOR : 1
2623
2724jobs :
28- test :
25+ generate-matrix :
26+ name : Derive Python version matrix from pyproject.toml
27+ runs-on : ubuntu-latest
28+ outputs :
29+ python-versions : ${{ steps.python-versions.outputs.python-versions }}
30+ steps :
31+
32+ - name : Checkout repository
33+ uses : actions/checkout@v7
34+
35+ - name : Read supported versions from classifiers
36+ id : python-versions
37+ run : |
38+ python - <<'EOF' >> "$GITHUB_OUTPUT"
39+ import json
40+ import tomllib
41+
42+ with open("pyproject.toml", "rb") as f:
43+ classifiers = tomllib.load(f)["project"]["classifiers"]
44+
45+ prefix = "Programming Language :: Python :: 3."
46+ versions = [
47+ classifier.rsplit("::", 1)[-1].strip()
48+ for classifier in classifiers
49+ if classifier.startswith(prefix)
50+ ]
51+ print(f"python-versions={json.dumps(versions)}")
52+ EOF
53+
54+ test-and-build :
55+ needs : generate-matrix
2956 runs-on : ${{ matrix.os }}
3057 strategy :
3158 fail-fast : false
3259 matrix :
3360 os : [macos-latest, ubuntu-latest, windows-latest]
34- python-version : [
35- ' 3.11' ,
36- ' 3.12' ,
37- ' 3.13' ,
38- ]
61+ python-version : ${{ fromJson(needs.generate-matrix.outputs.python-versions) }}
3962
4063 env :
4164 PYTHON_VERSION : ${{ matrix.python-version }}
@@ -51,16 +74,16 @@ jobs:
5174 cache-dependency-glob : " uv.lock"
5275 enable-cache : false
5376 python-version : ${{ matrix.python-version }}
54- version : " 0.5.13"
5577
5678 - name : Install library and dependencies
5779 run : |
5880 uv sync --frozen
59- uv run maturin develop
81+ uvx maturin develop
6082
61- - name : Run Tox (Pytest + Coverage)
83+ - name : Run tests (Pytest + Coverage)
6284 run : |
63- uvx --with tox-uv tox
85+ uv run --frozen pytest
86+ uv run --frozen coverage report
6487 env :
6588 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
6689 PLATFORM : ${{ matrix.os }}
@@ -69,46 +92,43 @@ jobs:
6992 if : success()
7093 uses : codecov/codecov-action@v7
7194 with :
72- env_vars : TOXENV
95+ env_vars : PYTHON_VERSION
7396 fail_ci_if_error : false
7497 files : ./tests/reports/coverage-html/index.html,./tests/reports/coverage.xml
7598 flags : unittests
7699 name : " ${{ matrix.os }} - Python ${{ matrix.python-version }}"
77100 token : ${{ secrets.CODECOV_TOKEN }}
78101
102+ - name : Build binaries for ${{ matrix.os }}-${{ matrix.python-version }}
103+ run : |
104+ uv build
105+
106+ - name : Upload builds
107+ uses : actions/upload-artifact@v7
108+ with :
109+ name : ${{ matrix.os }}-${{ matrix.python-version }}
110+ path : dist/
111+
79112
80113 testpypi-deploy :
81114 name : Build and publish Python 🐍 distributions 📦 to TestPyPI
115+ environment : testpypi
116+ permissions :
117+ id-token : write
82118 runs-on : ubuntu-latest
83- needs : test
119+ needs : test-and-build
84120 steps :
85121
86- - name : Checkout repository
87- uses : actions/checkout@v7
88-
89- - name : Install uv
90- uses : astral-sh/setup-uv@v7
91- with :
92- cache-dependency-glob : " uv.lock"
93- enable-cache : true
94-
95- - name : Install Python
96- uses : actions/setup-python@v7
122+ - name : Download Artifacts
123+ uses : actions/download-artifact@v8
97124 with :
98- python-version-file : " pyproject.toml"
125+ merge-multiple : true
126+ path : dist/
99127
100- - name : Build test release 📦
101- uses : messense/maturin-action@v1
102- with :
103- manylinux : auto
104- command : build
105- args : --release --sdist -o dist --find-interpreter
106-
107- - name : Publish test release 📦 to Test PyPI
108- uses : messense/maturin-action@v1
128+ - name : Publish to Test PyPI
129+ uses : pypa/gh-action-pypi-publish@release/v1
109130 continue-on-error : true
110- env :
111- MATURIN_PYPI_TOKEN : ${{ secrets.TEST_PYPI_PASSWORD }}
112131 with :
113- command : upload
114- args : --skip-existing * --repository-url "https://test.pypi.org/legacy"
132+ print-hash : true
133+ repository-url : https://test.pypi.org/legacy/
134+ skip-existing : true
0 commit comments