feat(cli): install release binaries with a shell script (#5082)

Install the public CLI from GitHub Releases with `sh
scripts/install.sh`. The script selects the macOS Apple Silicon or Linux
ARM64/x86-64 archive, verifies its SHA-256 and reported version, and
installs it under the user's home directory. Set `LANCEDB_VERSION` to
pin a release, including a beta. The default resolves GitHub's latest
stable tag, which must have CLI assets.

If an Enterprise or other `lancedb` is already on PATH, the installer
asks for a separate install directory. An existing destination
(including a symlink) is always preserved.

The installer workflow exercises that same release on all three native
targets and checks checksum failures and existing executable handling.
This commit is contained in:
Bruno Ramirez
2026-11-18 08:40:53 -08:00
committed by GitHub
parent a6d7d02f71
commit dd69a2c535
4 changed files with 187 additions and 0 deletions
+32
View File
@@ -0,0 +1,32 @@
name: CLI shell installer
on:
pull_request:
paths:
- 'scripts/install.sh'
- 'ci/tests/test_cli_installer.sh'
- '.github/workflows/cli-installer.yml'
workflow_dispatch:
permissions:
contents: read
jobs:
install:
strategy:
fail-fast: false
matrix:
os: [ubuntu-24.04, ubuntu-24.04-arm, macos-15]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v6
with:
persist-credentials: false
- run: sh ci/tests/test_cli_installer.sh
- name: Install a pinned public release and run it
env:
LANCEDB_VERSION: v0.42.0-beta.19
run: |
export LANCEDB_INSTALL_DIR="$RUNNER_TEMP/cli bin"
sh scripts/install.sh
test "$("$LANCEDB_INSTALL_DIR/lancedb" --version)" = "lancedb ${LANCEDB_VERSION#v}"
"$LANCEDB_INSTALL_DIR/lancedb" profile list
+42
View File
@@ -0,0 +1,42 @@
#!/bin/sh
# Run from repository root. The fake transport serves a deliberately corrupt archive.
set -eu
work=$(mktemp -d)
trap 'rm -rf "$work"' EXIT
export HOME="$work/home" LANCEDB_VERSION=v0.42.0-beta.19
unset LANCEDB_INSTALL_DIR
mkdir -p "$work/bin" "$HOME"
export PATH="$work/bin:$PATH"
cat > "$work/bin/curl" <<'MOCK'
#!/bin/sh
while [ "$1" != -o ]; do shift; done
case "$3" in
*/SHA256SUMS)
for target in x86_64-unknown-linux-gnu aarch64-unknown-linux-gnu aarch64-apple-darwin; do
printf '%064d lancedb-%s-%s.tar.gz\n' 0 "$LANCEDB_VERSION" "$target"
done > "$2" ;;
*) printf 'corrupt archive' > "$2" ;;
esac
MOCK
chmod +x "$work/bin/curl"
reject() {
if sh scripts/install.sh > "$work/log" 2>&1; then
echo "Unexpected install success" >&2
exit 1
fi
grep -F "$1" "$work/log"
}
printf 'existing admin CLI\n' > "$work/bin/lancedb"
chmod +x "$work/bin/lancedb"
reject 'on PATH'
test ! -e "$HOME/.local/bin/lancedb"
export LANCEDB_INSTALL_DIR="$work/separate bin"
mkdir -p "$LANCEDB_INSTALL_DIR"
ln -s "$work/bin/lancedb" "$LANCEDB_INSTALL_DIR/lancedb"
reject 'already exists'
test -L "$LANCEDB_INSTALL_DIR/lancedb"
rm "$LANCEDB_INSTALL_DIR/lancedb"
reject 'Checksum mismatch'
test -z "$(ls -A "$LANCEDB_INSTALL_DIR")"
test "$(cat "$work/bin/lancedb")" = 'existing admin CLI'
+15
View File
@@ -18,6 +18,21 @@ statements supported by your deployment.
## Install
From a repository checkout, use the shell installer to select the archive for
your machine. For example, to install a specific published beta:
```sh
LANCEDB_VERSION=v0.42.0-beta.19 sh scripts/install.sh
```
Omit `LANCEDB_VERSION` to select the latest stable GitHub release. The selected
release must include CLI archives. The installer verifies the archive checksum
and installs to `$HOME/.local/bin/lancedb`. If you already use an Enterprise CLI,
set `LANCEDB_INSTALL_DIR` to a separate absolute directory and invoke the public
client by its full path. To upgrade, move the existing executable first.
### Manual download
Download a CLI archive and `SHA256SUMS` from the
[LanceDB releases page](https://github.com/lancedb/lancedb/releases). The CLI
shares the SDK release version, including beta versions.
+98
View File
@@ -0,0 +1,98 @@
#!/bin/sh
# Install the public LanceDB command-line client from GitHub Releases.
set -eu
fail() {
printf 'lancedb installer: %s\n' "$*" >&2
exit 1
}
download() {
curl -q --proto '=https' --proto-redir '=https' -fsSL "$@"
}
main() {
[ "$#" -eq 0 ] || fail 'Set LANCEDB_VERSION and LANCEDB_INSTALL_DIR via the environment.'
releases=https://github.com/lancedb/lancedb/releases
platform=$(uname -s)-$(uname -m)
case "$platform" in
Darwin-arm64) target=aarch64-apple-darwin ;;
Linux-aarch64|Linux-arm64) target=aarch64-unknown-linux-gnu ;;
Linux-x86_64) target=x86_64-unknown-linux-gnu ;;
*) fail "No CLI archive for $platform. Supported: Apple Silicon macOS, Linux ARM64 and Linux x86-64." ;;
esac
case "$target" in
*-linux-gnu)
libc=$(getconf GNU_LIBC_VERSION 2>/dev/null) || fail 'Linux requires glibc 2.28 or newer.'
printf '%s\n' "$libc" | awk -F '[ .]' '$1 == "glibc" && ($2 > 2 || ($2 == 2 && $3 >= 28)) { ok=1 } END { exit !ok }' ||
fail 'Linux requires glibc 2.28 or newer.'
if [ "$target" = x86_64-unknown-linux-gnu ]; then
for feature in avx2 fma f16c; do
grep -qw "$feature" /proc/cpuinfo || fail "The Linux x86-64 binary requires CPU feature $feature."
done
fi ;;
*-apple-darwin)
os_version=$(sw_vers -productVersion)
[ "${os_version%%.*}" -ge 14 ] || fail 'Apple Silicon requires macOS 14 or newer.' ;;
esac
dir=${LANCEDB_INSTALL_DIR:-"$HOME/.local/bin"}
case "$dir" in /*) ;; *) fail 'LANCEDB_INSTALL_DIR must be an absolute path.' ;; esac
dest=$dir/lancedb
if [ -e "$dest" ] || [ -L "$dest" ]; then
fail "$dest already exists. Move it first or choose a separate LANCEDB_INSTALL_DIR."
fi
if existing=$(command -v lancedb); then
if [ -z "${LANCEDB_INSTALL_DIR:-}" ]; then
fail "Found $existing on PATH. To install alongside it, set LANCEDB_INSTALL_DIR to a separate directory."
fi
fi
tag=${LANCEDB_VERSION:-}
if [ -z "$tag" ]; then
latest=$(download --head --output /dev/null --write-out '%{url_effective}' "$releases/latest")
tag=${latest##*/}
fi
version=${tag#v}
# Match the stable and beta tag formats supported by ci/package_cli.py.
case "$version" in *[!0-9a-z.-]*|'') fail "Invalid release version: $tag" ;; esac
printf '%s\n' "$version" | grep -Eq '^[0-9]+\.[0-9]+\.[0-9]+(-beta\.[0-9]+)?$' ||
fail "Invalid release version: $tag"
stem=lancedb-v$version-$target
archive=$stem.tar.gz
url=$releases/download/v$version
mkdir -p "$dir"
# Stage on the destination filesystem so the final hard link is atomic and cannot overwrite a file.
stage=$(mktemp -d "$dir/.lancedb-install.XXXXXXXX")
trap 'rm -rf "$stage"' EXIT
trap 'exit 1' HUP INT TERM
download -o "$stage/SHA256SUMS" "$url/SHA256SUMS" ||
fail "Could not fetch CLI checksums for v$version. Choose a release with CLI assets using LANCEDB_VERSION."
expected=$(awk -v name="$archive" '$2 == name { count++; hash=$1 } END { if (count != 1) exit 1; print hash }' "$stage/SHA256SUMS") ||
fail "Expected exactly one checksum for $archive."
download -o "$stage/$archive" "$url/$archive"
if command -v sha256sum >/dev/null 2>&1; then
actual=$(sha256sum < "$stage/$archive")
else
actual=$(shasum -a 256 < "$stage/$archive")
fi
[ "${actual%% *}" = "$expected" ] || fail "Checksum mismatch for $archive."
tar -xzOf "$stage/$archive" "$stem/lancedb" > "$stage/lancedb"
chmod 755 "$stage/lancedb"
reported=$("$stage/lancedb" --version) ||
fail "Cannot run $target on this machine. Check the CPU and OS requirements in the CLI install guide."
[ "$reported" = "lancedb $version" ] || fail "Unexpected CLI version: $reported"
ln "$stage/lancedb" "$dest"
printf 'Installed %s at %s\n' "$reported" "$dest"
case ":${PATH:-}:" in
*:"$dir":*) ;;
*) printf 'Add %s to PATH or invoke the full path above.\n' "$dir" ;;
esac
}
# Keep the entry point last so a truncated download cannot start installation.
main "$@"