| 1 |
name: CI |
| 2 |
|
| 3 |
on: |
| 4 |
push: |
| 5 |
branches: |
| 6 |
- main |
| 7 |
pull_request: |
| 8 |
|
| 9 |
env: |
| 10 |
UV_VERSION: "0.11.21" # renovate: depName=uv datasource=pypi |
| 11 |
|
| 12 |
permissions: write-all |
| 13 |
|
| 14 |
concurrency: |
| 15 |
group: ${{ github.head_ref || github.run_id }} |
| 16 |
cancel-in-progress: true |
| 17 |
|
| 18 |
jobs: |
| 19 |
lint: |
| 20 |
env: |
| 21 |
SKIP: no-commit-to-branch |
| 22 |
runs-on: ubuntu-latest |
| 23 |
steps: |
| 24 |
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6 |
| 25 |
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6 |
| 26 |
with: |
| 27 |
python-version: "3.14" # renovate: depName=python datasource=python-version |
| 28 |
- uses: j178/prek-action@bdca6f102f98e2b4c7029491a53dfd366469e33d # v2 |
| 29 |
|
| 30 |
# Make sure commit messages follow the conventional commits convention: |
| 31 |
# https://www.conventionalcommits.org |
| 32 |
commitlint: |
| 33 |
name: Lint Commit Messages |
| 34 |
runs-on: ubuntu-latest |
| 35 |
steps: |
| 36 |
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6 |
| 37 |
with: |
| 38 |
fetch-depth: 0 |
| 39 |
- uses: wagoid/commitlint-github-action@b948419dd99f3fd78a6548d48f94e3df7f6bf3ed # v6.2.1 |
| 40 |
|
| 41 |
test: |
| 42 |
strategy: |
| 43 |
fail-fast: false |
| 44 |
matrix: |
| 45 |
python-version: |
| 46 |
- "3.12" |
| 47 |
- "3.13" |
| 48 |
- "3.14" # renovate: depName=python datasource=python-version |
| 49 |
os: |
| 50 |
- ubuntu-latest |
| 51 |
- windows-latest |
| 52 |
- macOS-latest |
| 53 |
runs-on: ${{ matrix.os }} |
| 54 |
steps: |
| 55 |
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6 |
| 56 |
- name: Set up Python |
| 57 |
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6 |
| 58 |
with: |
| 59 |
python-version: ${{ matrix.python-version }} |
| 60 |
- uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0 |
| 61 |
with: |
| 62 |
version: ${{ env.UV_VERSION }} |
| 63 |
- name: Sync Dependencies |
| 64 |
run: uv sync --frozen --group dev |
| 65 |
shell: bash |
| 66 |
- name: Test with Pytest |
| 67 |
run: uv run pytest --cov-report=xml |
| 68 |
shell: bash |
| 69 |
- name: Upload coverage to Codecov |
| 70 |
uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f # v7 |
| 71 |
with: |
| 72 |
token: ${{ secrets.CODECOV_TOKEN }} |
| 73 |
|
| 74 |
release: |
| 75 |
needs: |
| 76 |
- test |
| 77 |
- lint |
| 78 |
- commitlint |
| 79 |
|
| 80 |
runs-on: ubuntu-latest |
| 81 |
environment: release |
| 82 |
permissions: |
| 83 |
id-token: write |
| 84 |
contents: write |
| 85 |
|
| 86 |
steps: |
| 87 |
# Checkout must work for both PRs (including forks) and pushes to main |
| 88 |
- name: Checkout code |
| 89 |
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6 |
| 90 |
with: |
| 91 |
fetch-depth: 0 |
| 92 |
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.ref || github.ref_name }} |
| 93 |
repository: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name || github.repository }} |
| 94 |
|
| 95 |
- name: Set up Python |
| 96 |
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6 |
| 97 |
with: |
| 98 |
python-version: "3.14" # renovate: depName=python datasource=python-version |
| 99 |
|
| 100 |
# Do a dry run of PSR |
| 101 |
- name: Test release |
| 102 |
uses: python-semantic-release/python-semantic-release@350c48fcb3ffcdfd2e0a235206bc2ecea6b69df0 # v10.5.3 |
| 103 |
if: github.event_name == 'pull_request' |
| 104 |
with: |
| 105 |
no_operation_mode: true |
| 106 |
vcs_release: false |
| 107 |
push: false |
| 108 |
tag: false |
| 109 |
github_token: ${{ github.token }} |
| 110 |
|
| 111 |
# On main branch: actual PSR + upload to PyPI & GitHub |
| 112 |
- name: Release |
| 113 |
uses: python-semantic-release/python-semantic-release@350c48fcb3ffcdfd2e0a235206bc2ecea6b69df0 # v10.5.3 |
| 114 |
id: release |
| 115 |
if: github.event_name == 'push' && github.ref_name == 'main' |
| 116 |
with: |
| 117 |
verbosity: 2 # equivalent to "-vv" |
| 118 |
github_token: ${{ secrets.GITHUB_TOKEN }} |
| 119 |
|
| 120 |
- name: Publish package distributions to PyPI |
| 121 |
uses: pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b # release/v1 |
| 122 |
if: steps.release.outputs.released == 'true' |
| 123 |
with: |
| 124 |
packages-dir: dist |
| 125 |
|
| 126 |
- name: Publish package distributions to GitHub Releases |
| 127 |
uses: python-semantic-release/publish-action@310a9983a0ae878b29f3aac778d7c77c1db27378 # v10.5.3 |
| 128 |
if: steps.release.outputs.released == 'true' |
| 129 |
with: |
| 130 |
github_token: ${{ secrets.GITHUB_TOKEN }} |
| 131 |
tag: ${{ steps.release.outputs.tag }} |