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:
+8 -8
View File
@@ -172,9 +172,9 @@ release designation.
### Python CLI wheels
Run the **CLI Python wheels** workflow with a published CLI tag to build the
`lancedb-tools` wheels. It verifies the release archives against `SHA256SUMS`,
bundles the native executable and its notices, and saves the three wheels as
When **GitHub Release** finishes, **CLI Python wheels** runs from `main` for the
stable tag if that attempt published the CLI archives. It verifies the archives
against `SHA256SUMS`, bundles the native executable and its notices, and saves the three wheels as
the `lancedb-tools-wheels` Actions artifact. Python package versions follow
PEP 440 (for example, CLI `v0.42.0-beta.30` becomes `0.42.0b30`).
@@ -188,16 +188,16 @@ pipx install "$wheel"
lancedb profile list
```
To publish a stable CLI release, wait until its three CLI archives and
`SHA256SUMS` are on GitHub Releases. Dispatch the workflow from `main` with
the exact release tag and request publication:
To recover a missed automatic run, first check the **CLI Python wheels** run
history for the tag. If the release archives are published and the tag has no
wheel run, dispatch it from `main`:
```sh
gh workflow run cli-wheels.yml --repo lancedb/lancedb --ref main -f tag=v0.42.0 -f publish=true
```
After all three native install jobs pass, a release maintainer checks the tag
and install results and approves the `pypi-cli` deployment in the workflow run.
After all three native install jobs pass, a member of the `release` team checks
the tag and install results and approves the `pypi-cli` deployment in the workflow run.
The upload job publishes the tested wheels and verifies their SHA-256 digests
against PyPI. If an upload stops partway, rerun the failed job in the same run
to finish uploading the original wheels. To verify the public install: