| 1 | name: Publish Package |
| 2 | |
| 3 | permissions: |
| 4 | id-token: write |
| 5 | |
| 6 | on: |
| 7 | push: |
| 8 | tags: |
| 9 | - '[0-9]+.[0-9]+.[0-9]+' |
| 10 | |
| 11 | jobs: |
| 12 | build-and-publish: |
| 13 | name: Build and publish Python package |
| 14 | runs-on: ubuntu-latest |
| 15 | steps: |
| 16 | - uses: actions/checkout@v6 |
| 17 | - name: Set up Python 3.13 |
| 18 | uses: actions/setup-python@v6 |
| 19 | with: |
| 20 | python-version: 3.13 |
| 21 | - name: Install pypa/build |
| 22 | run: | |
| 23 | python -m pip install --upgrade setuptools pip wheel twine |
| 24 | python -m pip install build --user |
| 25 | - name: Build a binary wheel and a source tarball |
| 26 | run: | |
| 27 | python -m build --sdist --wheel --outdir dist/ . |
| 28 | twine check --strict dist/* |
| 29 | - name: Publish package to test PyPI |
| 30 | if: startsWith(github.ref, 'refs/tags') |
| 31 | uses: pypa/gh-action-pypi-publish@release/v1 |
| 32 | with: |
| 33 | verbose: true |
| 34 | skip-existing: true |
| 35 | user: __token__ |
| 36 | password: ${{ secrets.TEST_PYPI_API_TOKEN }} |
| 37 | repository-url: https://test.pypi.org/legacy/ |
| 38 | - name: Publish package to PyPI |
| 39 | if: startsWith(github.ref, 'refs/tags') |
| 40 | uses: pypa/gh-action-pypi-publish@release/v1 |
| 41 | with: |
| 42 | verbose: true |
| 43 | user: __token__ |
| 44 | password: ${{ secrets.PYPI_API_TOKEN }} |