ci(cli): start PyPI publishing after stable CLI releases (#5313)

Publishing `lancedb-tools` currently requires a maintainer to dispatch
the wheel workflow after each stable CLI release. This PR starts the
workflow on `main` when the GitHub release run finishes and its
asset-publication job succeeded for that tag. This also covers tags cut
from existing release branches. The `release` team still approves the
PyPI upload after the three native install checks pass.

This was accomplished with the following changes:

- Pass the originating release tag to the build, install checks, and
upload job.
- Check the `gh-release` job in the triggering attempt so a Homebrew
failure can’t block packaging and a Homebrew-only retry won’t rebuild
wheels.
- Keep manual dispatch available for recovery and document it in the
release guide.
This commit is contained in:
Bruno Ramirez
2026-11-30 15:14:49 -08:00
committed by GitHub
parent ca4c2ae5de
commit b29666cbc2
2 changed files with 49 additions and 12 deletions
+41 -4
View File
@@ -1,6 +1,10 @@
name: CLI Python wheels
run-name: ${{ github.event.pull_request.title || format('CLI Python wheels for {0}', github.event.workflow_run.head_branch || inputs.tag) }}
on:
workflow_run:
workflows: [GitHub Release]
types: [completed]
pull_request:
paths:
- ci/cli_wheel/**
@@ -22,10 +26,42 @@ permissions:
contents: read
env:
CLI_TAG: ${{ inputs.tag || 'v0.42.0-beta.30' }}
CLI_TAG: ${{ github.event.workflow_run.head_branch || inputs.tag || 'v0.42.0-beta.30' }}
jobs:
select-release:
if: >-
github.event_name != 'workflow_run' || (
github.repository == 'lancedb/lancedb' &&
github.event.workflow_run.head_repository.full_name == github.repository &&
github.event.workflow_run.event == 'push' &&
startsWith(github.event.workflow_run.head_branch, 'v') &&
!contains(github.event.workflow_run.head_branch, '-'))
runs-on: ubuntu-24.04
permissions:
actions: read
outputs:
published: ${{ steps.release.outputs.published }}
steps:
- name: Check that this attempt published the CLI archives
id: release
if: github.event_name == 'workflow_run'
shell: bash
env:
GH_TOKEN: ${{ github.token }}
RUN_ID: ${{ github.event.workflow_run.id }}
ATTEMPT: ${{ github.event.workflow_run.run_attempt }}
run: |
# Homebrew runs independently. A retry of just that job should not start another wheel build.
published=$(gh api --paginate --slurp \
"repos/$GITHUB_REPOSITORY/actions/runs/$RUN_ID/attempts/$ATTEMPT/jobs" |
jq --argjson attempt "$ATTEMPT" 'any(.[].jobs[];
.name == "gh-release" and .run_attempt == $attempt and .conclusion == "success")')
echo "published=$published" >> "$GITHUB_OUTPUT"
build:
needs: select-release
if: github.event_name != 'workflow_run' || needs.select-release.outputs.published == 'true'
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v6
@@ -74,7 +110,8 @@ jobs:
run: bash ci/cli_wheel/test_install.sh "$CLI_TAG" "$PWD/wheels"
check-publish:
if: github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/main' && inputs.publish
needs: build
if: github.ref == 'refs/heads/main' && (github.event_name == 'workflow_run' || inputs.publish)
runs-on: ubuntu-24.04
permissions:
actions: read
@@ -89,13 +126,13 @@ jobs:
run: bash ci/cli_wheel/check_publish.sh "$CLI_TAG"
publish:
name: Publish ${{ inputs.tag }} to PyPI
name: Publish ${{ github.event.workflow_run.head_branch || inputs.tag }} to PyPI
needs: [install, check-publish]
runs-on: ubuntu-24.04
environment:
name: pypi-cli
url: https://pypi.org/project/lancedb-tools/
concurrency: pypi-lancedb-tools-${{ inputs.tag }}
concurrency: pypi-lancedb-tools-${{ github.event.workflow_run.head_branch || inputs.tag }}
permissions:
id-token: write
steps: