diff --git a/.github/workflows/pypi.yaml b/.github/workflows/pypi.yaml index 7422f62..4720d15 100644 --- a/.github/workflows/pypi.yaml +++ b/.github/workflows/pypi.yaml @@ -2,19 +2,15 @@ name: Publish package to PyPi # See https://docs.pypi.org/trusted-publishers/adding-a-publisher/ on: - push: - tags: - - v* + pull_request: + branches: + - main workflow_dispatch: # Uncomment line if you also want to trigger action manually -permissions: - id-token: write - jobs: - build-release: + build: + name: Build Package runs-on: ubuntu-latest - environment: pypi-publish - name: Publish package to PyPi steps: - uses: actions/checkout@v4 with: @@ -25,15 +21,62 @@ jobs: python-version: 3.11 - name: Installing the package run: | - pip3 install . pip3 install .[pypi] - name: Build package run: | pip3 install --upgrade setuptools export DEB_PYTHON_INSTALL_LAYOUT=deb_system python -m build --no-isolation - - name: Publish package to PyPI + - name: Store the distribution packages + uses: actions/upload-artifact@v4 + with: + name: python-package-distributions + path: dist/ + + publish-to-pypi: + name: Publish Python 🐍 distribution 📦 to PyPI + if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes + needs: + - build + runs-on: ubuntu-latest + permissions: + id-token: write + environment: + name: pypi-publish + url: https://pypi.org/p/topostats + steps: + - name: Download all the dists + uses: actions/download-artifact@v4 + with: + name: python-package-distributions + path: dist/ + + - name: Publish distribution 📦 to PyPI uses: pypa/gh-action-pypi-publish@release/v1 with: user: __token__ password: ${{ secrets.PYPI_API_TOKEN }} + + # publish-to-testpypi: + # name: Publish Python 🐍 distribution 📦 to TestPyPI + # needs: + # - build + # runs-on: ubuntu-latest + + # environment: + # name: testpypi + # url: https://test.pypi.org/p/topostats + + # permissions: + # id-token: write # IMPORTANT: mandatory for trusted publishing + + # steps: + # - name: Download all the dists + # uses: actions/download-artifact@v4 + # with: + # name: python-package-distributions + # path: dist/ + # - name: Publish distribution 📦 to TestPyPI + # uses: pypa/gh-action-pypi-publish@release/v1 + # with: + # repository-url: https://test.pypi.org/legacy/