[pre-commit.ci] pre-commit autoupdate #306
This file contains hidden or 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
| name: Test | |
| on: [push, pull_request] | |
| jobs: | |
| check-tag: | |
| # Run on external PRs, but not on internal PRs, to avoid duplicate runs | |
| if: | | |
| github.event_name == 'push' || | |
| github.event.pull_request.head.repo.full_name != github.repository | |
| runs-on: ubuntu-latest | |
| outputs: | |
| publish_url: ${{ steps.check-publish.outputs.publish_url }} | |
| steps: | |
| - name: Check if this is a release/prerelease | |
| id: check-publish | |
| run: | | |
| tag_name="${GITHUB_REF#refs/tags/}" | |
| if [[ "$tag_name" =~ ^v[0-9]+\.[0-9]+\.[0-9]+[ab][0-9]+$ ]]; then | |
| publish_url="https://test.pypi.org/legacy/" | |
| elif [[ "$tag_name" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then | |
| publish_url="https://upload.pypi.org/legacy/" | |
| else | |
| publish_url="none" | |
| fi | |
| echo "publish_url=$publish_url" >> "$GITHUB_OUTPUT" | |
| echo "tag_name=$tag_name" | |
| echo "publish_url=$publish_url" | |
| build-sdist: | |
| name: Build source distribution | |
| needs: check-tag | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Build sdist | |
| run: pipx run build --sdist | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: build-sdist | |
| path: ${{ github.workspace }}/dist/*.tar.gz | |
| test: | |
| needs: build-sdist | |
| runs-on: ${{ matrix.os }} | |
| defaults: | |
| run: | |
| shell: bash -l {0} | |
| strategy: | |
| matrix: | |
| os: [ubuntu-latest, macos-latest, windows-latest] | |
| python-version: ["3.11", "3.12", "3.13"] | |
| fail-fast: false | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - uses: actions/download-artifact@v4 | |
| with: | |
| pattern: "build-*" | |
| merge-multiple: true | |
| path: ${{ github.workspace }}/dist | |
| - name: Test | |
| run: | | |
| pip install nox | |
| nox --non-interactive --error-on-missing-interpreter -s test test-cli -- dist/*.tar.gz | |
| - name: Upload coverage reports to Codecov | |
| uses: codecov/codecov-action@v5 | |
| with: | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| publish: | |
| needs: | |
| - check-tag | |
| - test | |
| name: "Publish to PyPI/TestPyPI" | |
| runs-on: ubuntu-latest | |
| permissions: | |
| id-token: write | |
| steps: | |
| - uses: actions/download-artifact@v4 | |
| with: | |
| pattern: "build-*" | |
| merge-multiple: true | |
| path: ${{ github.workspace }}/dist | |
| - uses: pypa/gh-action-pypi-publish@release/v1 | |
| if: ${{ startsWith(needs.check-tag.outputs.publish_url, 'http') }} | |
| with: | |
| repository-url: ${{ needs.check-tag.outputs.publish_url }} | |
| skip-existing: true | |
| print-hash: true | |
| verify-metadata: false |