Specify matrix Python version in uv run #20
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
on: | |
# Run on any push to master. | |
push: | |
branches: | |
- master | |
# Run on published releases. | |
release: | |
types: | |
- published | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"] | |
steps: | |
- uses: actions/checkout@v4 | |
- id: cache | |
uses: actions/cache@v4 | |
# Keep uv cache and Python virtual environment. | |
with: | |
key: ${{ hashFiles('pyproject.toml', 'uv.lock') }}-${{ matrix.python-version }} | |
path: | | |
~/.local/share/uv | |
.venv | |
- run: | | |
# Run tests. | |
curl -LsSf https://astral.sh/uv/install.sh | sh | |
uv run --python ${{ matrix.python-version }} --m pytest -v | |
publish: | |
needs: test | |
# Only publish if releasing. | |
if: startsWith(github.ref, 'refs/tags/') | |
runs-on: ubuntu-latest | |
permissions: | |
# Allows JWT to be requested from GitHub's OIDC provider for publishing to PyPI. | |
id-token: write | |
steps: | |
- uses: actions/checkout@v4 | |
- id: cache | |
uses: actions/cache@v4 | |
# Keep uv cache and Python virtual environment. | |
with: | |
key: ${{ hashFiles('pyproject.toml', 'uv.lock') }} | |
path: | | |
~/.local/share/uv | |
.venv | |
- run: | | |
# Build and publish to PyPI. | |
curl -LsSf https://astral.sh/uv/install.sh | sh | |
uv build | |
uv publish |