From 9bc76fd4e9cacd2de3cc755ebd25f8a17306e485 Mon Sep 17 00:00:00 2001 From: Miles Wells Date: Thu, 16 Jan 2025 18:41:54 +0200 Subject: [PATCH] Publish workflow with build --- .github/workflows/python-publish.yaml | 42 ++++++++++++++++++++------- 1 file changed, 32 insertions(+), 10 deletions(-) diff --git a/.github/workflows/python-publish.yaml b/.github/workflows/python-publish.yaml index f21fd20f..cb487d6f 100644 --- a/.github/workflows/python-publish.yaml +++ b/.github/workflows/python-publish.yaml @@ -11,27 +11,49 @@ permissions: contents: read jobs: - deploy: - name: Build and publish Python distributions to PyPI + build: + name: Build Python distributions runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - uses: actions/setup-python@v4 + - uses: actions/setup-python@v5 with: python-version: '3.x' - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install setuptools wheel + run: python -m pip install build - name: Build package - run: python setup.py sdist bdist_wheel + run: python -m build - - name: Publish package - # GitHub recommends pinning 3rd party actions to a commit SHA. - uses: pypa/gh-action-pypi-publish@37f50c210e3d2f9450da2cd423303d6a14a6e29f + - name: Store the distribution packages + uses: actions/upload-artifact@v4 + with: + name: python-package-distributions + path: dist/ + + publish: + name: >- + Publish Python distributions to PyPI + if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes + needs: + - build + runs-on: ubuntu-latest + environment: + name: pypi + url: https://pypi.org/p/ONE-api + 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 PyPI + # GitHub recommends pinning 3rd party actions to a commit SHA. + uses: pypa/gh-action-pypi-publish@6f7e8d9c0b1a2c3d4e5f6a7b8c9d0e1f2a3b4c5d with: user: __token__ password: ${{ secrets.PYPI_API_TOKEN }}