diff --git a/.github/workflows/pypi.yml b/.github/workflows/pypi.yml new file mode 100644 index 0000000..4b0bed5 --- /dev/null +++ b/.github/workflows/pypi.yml @@ -0,0 +1,46 @@ +name: Build and Publish wheels to PyPI + +on: + # allows running workflows manually + workflow_dispatch: + + release: + types: [published] + +jobs: + publish: + runs-on: ubuntu-latest + environment: + name: pypi + permissions: + id-token: write + + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: 3.x + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install build + + - name: Build wheel + run: | + python -m build -w + + - name: Publish to TestPyPI (on manual dispatch) + if: github.event_name == 'workflow_dispatch' + uses: pypa/gh-action-pypi-publish@release/v1 + with: + repository-url: https://test.pypi.org/legacy/ + + - name: Publish to PyPI (on release) + if: github.event_name == 'release' + uses: pypa/gh-action-pypi-publish@release/v1