|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + pull_request: |
| 8 | + |
| 9 | +concurrency: |
| 10 | + group: ${{ github.head_ref || github.run_id }} |
| 11 | + cancel-in-progress: true |
| 12 | + |
| 13 | +jobs: |
| 14 | + lint: |
| 15 | + runs-on: ubuntu-latest |
| 16 | + steps: |
| 17 | + - uses: actions/checkout@v4 |
| 18 | + - uses: actions/setup-python@v5 |
| 19 | + with: |
| 20 | + python-version: 3.x |
| 21 | + - uses: pre-commit/action@v3.0.1 |
| 22 | + |
| 23 | + # Make sure commit messages follow the conventional commits convention: |
| 24 | + # https://www.conventionalcommits.org |
| 25 | + commitlint: |
| 26 | + name: Lint Commit Messages |
| 27 | + runs-on: ubuntu-latest |
| 28 | + steps: |
| 29 | + - uses: actions/checkout@v4 |
| 30 | + with: |
| 31 | + fetch-depth: 0 |
| 32 | + - uses: wagoid/commitlint-github-action@v6.0.1 |
| 33 | + |
| 34 | + test: |
| 35 | + strategy: |
| 36 | + fail-fast: false |
| 37 | + matrix: |
| 38 | + python-version: |
| 39 | + - "3.9" |
| 40 | + - "3.10" |
| 41 | + - "3.11" |
| 42 | + - "3.12" |
| 43 | + - "3.13" |
| 44 | + os: |
| 45 | + - ubuntu-latest |
| 46 | + runs-on: ${{ matrix.os }} |
| 47 | + steps: |
| 48 | + - uses: actions/checkout@v4 |
| 49 | + - uses: actions/setup-python@v5 |
| 50 | + id: setup-python |
| 51 | + with: |
| 52 | + python-version: ${{ matrix.python-version }} |
| 53 | + - uses: astral-sh/setup-uv@v5 |
| 54 | + - run: uv sync --no-python-downloads |
| 55 | + shell: bash |
| 56 | + - run: uv run pytest |
| 57 | + shell: bash |
| 58 | + - uses: codecov/codecov-action@v5 |
| 59 | + with: |
| 60 | + token: ${{ secrets.CODECOV_TOKEN }} |
| 61 | + |
| 62 | + release: |
| 63 | + needs: |
| 64 | + - test |
| 65 | + - lint |
| 66 | + - commitlint |
| 67 | + |
| 68 | + runs-on: ubuntu-latest |
| 69 | + environment: release |
| 70 | + concurrency: release |
| 71 | + permissions: |
| 72 | + id-token: write |
| 73 | + attestations: write |
| 74 | + contents: write |
| 75 | + |
| 76 | + steps: |
| 77 | + - uses: actions/checkout@v4 |
| 78 | + with: |
| 79 | + fetch-depth: 0 |
| 80 | + ref: ${{ github.sha }} |
| 81 | + |
| 82 | + - name: Checkout commit for release |
| 83 | + run: | |
| 84 | + git checkout -B ${{ github.ref_name }} ${{ github.sha }} |
| 85 | +
|
| 86 | + # Do a dry run of PSR |
| 87 | + - name: Test release |
| 88 | + uses: python-semantic-release/python-semantic-release@v9.15.1 |
| 89 | + if: github.ref_name != 'main' |
| 90 | + with: |
| 91 | + root_options: --noop |
| 92 | + github_token: noop |
| 93 | + |
| 94 | + # On main branch: actual PSR + upload to PyPI & GitHub |
| 95 | + - name: Release |
| 96 | + uses: python-semantic-release/python-semantic-release@v9.15.1 |
| 97 | + id: release |
| 98 | + if: github.ref_name == 'main' |
| 99 | + with: |
| 100 | + github_token: ${{ secrets.GITHUB_TOKEN }} |
| 101 | + |
| 102 | + - name: Attest build provenance |
| 103 | + uses: actions/attest-build-provenance@v1 |
| 104 | + if: steps.release.outputs.released == 'true' |
| 105 | + with: |
| 106 | + subject-path: "dist/*" |
| 107 | + |
| 108 | + - name: Publish package distributions to PyPI |
| 109 | + uses: pypa/gh-action-pypi-publish@release/v1 |
| 110 | + if: steps.release.outputs.released == 'true' |
| 111 | + |
| 112 | + - name: Publish package distributions to GitHub Releases |
| 113 | + uses: python-semantic-release/publish-action@v9.15.1 |
| 114 | + if: steps.release.outputs.released == 'true' |
| 115 | + with: |
| 116 | + github_token: ${{ secrets.GITHUB_TOKEN }} |
| 117 | + tag: ${{ steps.release.outputs.tag }} |
0 commit comments