From eddfa4b6ca845b5ebcec833f0c7d9bcce2df43a4 Mon Sep 17 00:00:00 2001 From: Richard Levasseur Date: Mon, 20 Jul 2026 18:10:50 +0000 Subject: [PATCH 1/3] refactor(release): extract pypi publishing to standalone workflow Factor out PyPI publishing from release_publish.yaml into a new standalone workflow publish_pypi.yaml. This allows PyPI publishing to be manually triggered via workflow_dispatch while remaining callable by release_publish.yaml. --- .github/workflows/publish_pypi.yaml | 32 ++++++++++++++++++++++++++ .github/workflows/release_publish.yaml | 20 ++++------------ 2 files changed, 37 insertions(+), 15 deletions(-) create mode 100644 .github/workflows/publish_pypi.yaml diff --git a/.github/workflows/publish_pypi.yaml b/.github/workflows/publish_pypi.yaml new file mode 100644 index 0000000000..44f0a1d9fb --- /dev/null +++ b/.github/workflows/publish_pypi.yaml @@ -0,0 +1,32 @@ +name: Publish to PyPI + +on: + workflow_call: + inputs: + tag_name: + description: "release tag: tag that will be released" + required: true + type: string + workflow_dispatch: + inputs: + tag_name: + description: "release tag: tag that will be released" + required: true + type: string + +jobs: + publish_pypi: + name: Publish runfiles to PyPI + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v7 + with: + ref: ${{ inputs.tag_name || github.ref_name }} + - env: + # This special value tells pypi that the user identity is supplied within the token + TWINE_USERNAME: __token__ + # Note, the PYPI_API_TOKEN is for the rules-python pypi user, added by @rickylev on + # https://github.com/bazel-contrib/rules_python/settings/secrets/actions + TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} + run: bazel run --stamp --embed_label=${{ inputs.tag_name || github.ref_name }} //python/runfiles:wheel.publish diff --git a/.github/workflows/release_publish.yaml b/.github/workflows/release_publish.yaml index 8379c3d46d..eedf653fc1 100644 --- a/.github/workflows/release_publish.yaml +++ b/.github/workflows/release_publish.yaml @@ -77,19 +77,9 @@ jobs: publish_pypi: # We just want publish_pypi last, since once uploaded, it can't be changed. - name: Publish runfiles to PyPI needs: publish_bcr - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v7 - with: - ref: ${{ inputs.tag_name || github.ref_name }} - - if: github.event_name == 'push' || github.event.inputs.publish_to_pypi - env: - # This special value tells pypi that the user identity is supplied within the token - TWINE_USERNAME: __token__ - # Note, the PYPI_API_TOKEN is for the rules-python pypi user, added by @rickylev on - # https://github.com/bazel-contrib/rules_python/settings/secrets/actions - TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} - run: bazel run --stamp --embed_label=${{ inputs.tag_name || github.ref_name }} //python/runfiles:wheel.publish + if: github.event_name == 'push' || inputs.publish_to_pypi + uses: ./.github/workflows/publish_pypi.yaml + with: + tag_name: ${{ inputs.tag_name || github.ref_name }} + secrets: inherit From 7be685950ca3c915590c25b2b387ef993e74295c Mon Sep 17 00:00:00 2001 From: Richard Levasseur Date: Mon, 20 Jul 2026 18:16:21 +0000 Subject: [PATCH 2/3] docs(release): document manual pypi publishing in RELEASING.md Add instructions in RELEASING.md detailing how to manually trigger publish_pypi.yaml via gh CLI or GitHub UI. --- RELEASING.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/RELEASING.md b/RELEASING.md index a03cd83652..d612b1c078 100644 --- a/RELEASING.md +++ b/RELEASING.md @@ -63,6 +63,16 @@ you can set the `publish_to_pypi` input to `false`: gh workflow run release_publish.yaml --ref -f publish_to_pypi=false ``` +### Manually publishing to PyPI + +If PyPI publishing failed or was skipped during the main release, the PyPI +publishing workflow can be triggered manually using the GitHub CLI (`gh`) or +via the GitHub Actions UI: + +```shell +gh workflow run publish_pypi.yaml --ref -f tag_name= +``` + ### Determining Semantic Version **rules_python** uses [semantic version](https://semver.org), so releases with From 9f66234d5a1e79938f58e89dd668918351cbb4ac Mon Sep 17 00:00:00 2001 From: Richard Levasseur Date: Mon, 20 Jul 2026 18:17:03 +0000 Subject: [PATCH 3/3] docs(release): hyperlink GitHub Actions UI in RELEASING.md Add link to publish_pypi.yaml workflow UI in RELEASING.md. --- RELEASING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RELEASING.md b/RELEASING.md index d612b1c078..1942553538 100644 --- a/RELEASING.md +++ b/RELEASING.md @@ -67,7 +67,7 @@ gh workflow run release_publish.yaml --ref -f publish_to_pypi=false If PyPI publishing failed or was skipped during the main release, the PyPI publishing workflow can be triggered manually using the GitHub CLI (`gh`) or -via the GitHub Actions UI: +via the [GitHub Actions UI](https://github.com/bazel-contrib/rules_python/actions/workflows/publish_pypi.yaml): ```shell gh workflow run publish_pypi.yaml --ref -f tag_name=