diff --git a/.github/workflows/build-publish.yml b/.github/workflows/build-publish.yml new file mode 100644 index 0000000..1789133 --- /dev/null +++ b/.github/workflows/build-publish.yml @@ -0,0 +1,55 @@ +name: Publish python distribution to PyPI + +on: + release: + types: + - published + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: "3.9" + + - name: Install Dependencies + run: | + python -m pip install --upgrade pip + python -m pip install setuptools wheel twine + + - name: Build a binary wheel and a source tarball + run: | + python setup.py sdist bdist_wheel + + - name: Upload distributions + uses: actions/upload-artifact@v4 + with: + name: "distributions-for-${{ github.event.release.tag_name }}" + path: dist/ + + publish-to-pypi: + name: Publish to PyPI + needs: build + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Download distributions + uses: actions/download-artifact@v4 + with: + name: "distributions-for-${{ github.event.release.tag_name }}" + path: dist/ + + - name: Publish to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 + with: + username: __token__ + repository-url: https://pypi.org/legacy/ + password: ${{ secrets.PYPI_API_TOKEN }} +