| 1 | name: Publish to PyPI |
| 2 | on: push |
| 3 | jobs: |
| 4 | build: |
| 5 | runs-on: ubuntu-latest |
| 6 | steps: |
| 7 | - uses: actions/checkout@v6 |
| 8 | - uses: actions/setup-python@v6 |
| 9 | with: |
| 10 | python-version: '3.10' |
| 11 | - run: pip install --upgrade build |
| 12 | - run: python -m build --sdist --wheel |
| 13 | - uses: actions/upload-artifact@v6 |
| 14 | with: |
| 15 | name: python-package-distributions |
| 16 | path: dist/ |
| 17 | test: |
| 18 | needs: build |
| 19 | permissions: |
| 20 | id-token: write |
| 21 | runs-on: ubuntu-latest |
| 22 | steps: |
| 23 | - uses: actions/download-artifact@v7 |
| 24 | with: |
| 25 | name: python-package-distributions |
| 26 | path: dist/ |
| 27 | - uses: pypa/gh-action-pypi-publish@release/v1 |
| 28 | with: |
| 29 | repository-url: https://test.pypi.org/legacy/ |
| 30 | skip-existing: true |
| 31 | verbose: true |
| 32 | publish: |
| 33 | if: startsWith(github.ref, 'refs/tags/') |
| 34 | needs: test |
| 35 | permissions: |
| 36 | id-token: write |
| 37 | runs-on: ubuntu-latest |
| 38 | steps: |
| 39 | - uses: actions/download-artifact@v7 |
| 40 | with: |
| 41 | name: python-package-distributions |
| 42 | path: dist/ |
| 43 | - uses: pypa/gh-action-pypi-publish@release/v1 |