diff --git a/.github/workflows/publish_to_pypi.yaml b/.github/workflows/publish_to_pypi.yaml index 4f6bdb8d..982e4096 100644 --- a/.github/workflows/publish_to_pypi.yaml +++ b/.github/workflows/publish_to_pypi.yaml @@ -30,15 +30,13 @@ permissions: contents: read jobs: - pypi_publish: - name: PyPI publish + # Runs without `id-token: write`, so the build (the composite actions and the project's dev dependencies) can't + # request a PyPI token. Only the `pypi_publish` job below can. + build: + name: Build runs-on: ubuntu-latest permissions: contents: read - id-token: write # Required for OIDC authentication. - environment: - name: pypi - url: https://pypi.org/project/apify-client steps: # Also pins the ref to a commit, so the checked commit is the one that gets built. - name: Check that the ref is on a release branch @@ -78,6 +76,30 @@ jobs: ApifyClient(token='x') ApifyClientAsync(token='x') + - name: Upload distribution + uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 + with: + name: dist + path: dist/ + if-no-files-found: error + retention-days: 1 + + pypi_publish: + name: PyPI publish + needs: build + runs-on: ubuntu-latest + permissions: + id-token: write # Required for OIDC authentication. + environment: + name: pypi + url: https://pypi.org/project/apify-client + steps: + - name: Download distribution + uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2 + with: + name: dist + path: dist/ + # Publish the package to PyPI using PyPA official GitHub action with OIDC authentication. - name: Publish package to PyPI uses: pypa/gh-action-pypi-publish@7245906fb61fa33a13554f9d5fb856fe61758086 # release/v1