Files
lancedb/.github/workflows/gh-release.yml
T
Bruno Ramirez 09b8ec1134 ci: open Homebrew tap PRs for stable CLI releases (#5173)
Stable CLI releases already publish three binary archives and their
checksums, but a maintainer would have to copy those checksums into the
Homebrew formula for every release. This adds a job that opens a PR in
the tap after GitHub publishes a stable release. Tap CI tests the
published binaries and a maintainer merges the update. Before the first
automated update, merge the initial [stable
formula](https://github.com/lancedb/homebrew-tap/pull/1) and configure
the GitHub App as described in `release_process.md`.

This was accomplished with the following changes:

- Read `SHA256SUMS` from the published tag and update the formula
version and the hash for each matching platform archive.
- Use a tap-scoped App token and a branch per release so retries update
the same PR. Older release retries preserve newer formula versions.

### Testing

All 38 CI-script tests passed locally, including checksum mapping,
invalid or incomplete manifests, prerelease rejection, and retries. A
dry run against the actual draft formula with a simulated stable
manifest produced valid Ruby and a second run produced no changes. Live
App authentication and tap PR creation require the installation
credentials.
2026-11-24 09:10:04 -08:00

169 lines
6.1 KiB
YAML

name: GitHub Release
# All SDKs share one version, so a single `vX.Y.Z` tag produces a single GitHub
# release covering all of them, including CLI binaries. The per-package publish
# workflows (PyPI, NPM, Cargo, Maven) trigger off the same tag independently.
on:
push:
tags:
- "v*"
permissions:
contents: read
jobs:
cli:
uses: ./.github/workflows/cli-release.yml
gh-release:
needs: cli
runs-on: ubuntu-latest
outputs:
prerelease: ${{ steps.extract_version.outputs.prerelease }}
permissions:
contents: write
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
lfs: true
- uses: actions/setup-python@v6
with:
python-version: '3.13'
- uses: actions/download-artifact@v8
with:
name: cli-release
path: dist
- name: Verify CLI release assets
run: python ci/package_cli.py verify --output dist
- name: Extract version
id: extract_version
env:
GITHUB_REF: ${{ github.ref }}
run: |
set -e
echo "Extracting tag and version from $GITHUB_REF"
if [[ $GITHUB_REF =~ refs/tags/v(.*) ]]; then
VERSION=${BASH_REMATCH[1]}
TAG=v$VERSION
echo "tag=$TAG" >> $GITHUB_OUTPUT
echo "version=$VERSION" >> $GITHUB_OUTPUT
else
echo "Failed to extract version from $GITHUB_REF"
exit 1
fi
echo "Extracted version $VERSION from $GITHUB_REF"
if [[ $VERSION =~ beta ]]; then
echo "This is a beta release"
echo "prerelease=true" >> $GITHUB_OUTPUT
# Get last release (that is not this one)
FROM_TAG=$(git tag --sort='version:refname' \
| grep ^v \
| grep -vF "$TAG" \
| python ci/semver_sort.py v \
| tail -n 1)
else
echo "This is a stable release"
echo "prerelease=false" >> $GITHUB_OUTPUT
# Get last stable tag (ignore betas)
FROM_TAG=$(git tag --sort='version:refname' \
| grep ^v \
| grep -vF "$TAG" \
| grep -v beta \
| python ci/semver_sort.py v \
| tail -n 1)
fi
echo "Found from tag $FROM_TAG"
echo "from_tag=$FROM_TAG" >> $GITHUB_OUTPUT
- name: Create Release Notes
id: release_notes
uses: mikepenz/release-changelog-builder-action@32e3c96f29a6532607f638797455e9e98cfc703d # v4.2.2
with:
configuration: .github/release_notes.json
toTag: ${{ steps.extract_version.outputs.tag }}
fromTag: ${{ steps.extract_version.outputs.from_tag }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create GH release
uses: softprops/action-gh-release@3bb12739c298aeb8a4eeaf626c5b8d85266b0e65 # v2.6.2
with:
# Marking betas as pre-releases keeps them from taking the "Latest"
# badge on the releases page.
prerelease: ${{ steps.extract_version.outputs.prerelease }}
make_latest: ${{ steps.extract_version.outputs.prerelease == 'false' }}
tag_name: ${{ steps.extract_version.outputs.tag }}
token: ${{ secrets.GITHUB_TOKEN }}
generate_release_notes: false
name: LanceDB v${{ steps.extract_version.outputs.version }}
body: ${{ steps.release_notes.outputs.changelog }}
files: |
dist/lancedb-*.tar.gz
dist/SHA256SUMS
fail_on_unmatched_files: true
overwrite_files: true
homebrew:
name: Open Homebrew formula PR
needs: gh-release
if: github.repository == 'lancedb/lancedb' && needs.gh-release.outputs.prerelease == 'false'
runs-on: ubuntu-24.04
environment: homebrew-tap
concurrency: homebrew-tap-${{ github.ref_name }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
repository: lancedb/homebrew-tap
ref: main
path: tap
persist-credentials: false
- name: Update formula from the published checksums
env:
GH_TOKEN: ${{ github.token }}
run: |
gh release download "$GITHUB_REF_NAME" --repo "$GITHUB_REPOSITORY" \
--pattern SHA256SUMS --dir "$RUNNER_TEMP"
python3 -m ci.update_homebrew_formula "$GITHUB_REF_NAME" \
"$RUNNER_TEMP/SHA256SUMS" tap/Formula/lancedb.rb
- name: Create tap installation token
id: app
uses: actions/create-github-app-token@f418cff399f7aef4c2f0ad47e25ca7a6abbdd6fc # v3.4.0
with:
client-id: ${{ vars.HOMEBREW_TAP_APP_CLIENT_ID }}
private-key: ${{ secrets.HOMEBREW_TAP_APP_PRIVATE_KEY }}
owner: lancedb
repositories: homebrew-tap
permission-contents: write
permission-pull-requests: write
- name: Open or update the tap PR
uses: peter-evans/create-pull-request@3ffccacd46053766916f087ce41d627c0b8cf2d1 # v8.1.3
with:
path: tap
token: ${{ steps.app.outputs.token }}
base: main
branch: release/lancedb-${{ github.ref_name }}
add-paths: Formula/lancedb.rb
commit-message: Update LanceDB CLI to ${{ github.ref_name }}
title: Update LanceDB CLI to ${{ github.ref_name }}
body: |
Update the formula to [${{ github.ref_name }}](https://github.com/lancedb/lancedb/releases/tag/${{ github.ref_name }}) using its published SHA256SUMS.
Review and merge after the tap's install tests pass.
report-failure:
runs-on: ubuntu-24.04
needs: [cli, gh-release, homebrew]
if: always() && failure()
permissions:
contents: read
issues: write
steps:
- uses: actions/checkout@v6
- uses: ./.github/actions/create-failure-issue
with:
job-results: ${{ toJSON(needs) }}
workflow-name: ${{ github.workflow }}