diff --git a/.github/workflows/publish-tag-to-pypi.yaml b/.github/workflows/publish-tag-to-pypi.yaml new file mode 100644 index 00000000..f02b7bef --- /dev/null +++ b/.github/workflows/publish-tag-to-pypi.yaml @@ -0,0 +1,47 @@ +name: Publish Tag to PyPI + +on: push + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + persist-credentials: false + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: "3.x" + - name: Install build tool + run: python3 -m pip install build --user + - name: Build wheel and source distribution + run: python3 -m build + - name: Upload distributables as artifact + uses: actions/upload-artifact@v4 + with: + name: python-package-distributions + path: dist/ + + publish-to-pypi: + needs: build + if: startsWith(github.ref, 'refs/tags/') + runs-on: ubuntu-latest + environment: + name: pypi + steps: + - name: Download distributables + uses: actions/download-artifact@v4 + with: + name: python-package-distributions + path: dist/ + + - name: Install Twine + run: python3 -m pip install --user twine + + - name: Publish to PyPI + env: + TWINE_USERNAME: __token__ + TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} + run: | + python3 -m twine upload dist/*