Skip to content

Instantly share code, notes, and snippets.

@abbott
Created July 28, 2025 21:36
Show Gist options
  • Select an option

  • Save abbott/9b0a3a10274a05517d30ec39f1ee34a0 to your computer and use it in GitHub Desktop.

Select an option

Save abbott/9b0a3a10274a05517d30ec39f1ee34a0 to your computer and use it in GitHub Desktop.
Install Supabase CLI binary on macOS (no brew)
#!/usr/bin/env bash
# supabase_install.sh — install Supabase CLI to ~/.local/bin on macOS
# Supports both "supabase_${VERSION}_${PLATFORM}.tar.gz" and "supabase_${PLATFORM}.tar.gz"
set -euo pipefail
# —— Configuration ——
VERSION=${VERSION:-"latest"} # e.g. v2.31.8 or latest
BIN_DIR=${BIN_DIR:-"$HOME/.local/bin"}
# —— Detect platform ——
ARCH=$(uname -m)
case "$ARCH" in
arm64*) PLATFORM="darwin_arm64" ;;
x86_64*) PLATFORM="darwin_amd64" ;;
*) echo "Unsupported architecture: $ARCH" >&2; exit 1 ;;
esac
# —— Resolve “latest” via GitHub API ——
if [[ "$VERSION" == "latest" ]]; then
echo "Fetching latest Supabase CLI version..."
VERSION=$(curl -s https://api.github.com/repos/supabase/cli/releases/latest \
| grep '"tag_name":' \
| sed -E 's/.*"([^"]+)".*/\1/')
fi
DOWNLOAD_BASE="https://github.com/supabase/cli/releases/download/${VERSION}"
TMPDIR=$(mktemp -d)
# Try versioned asset first...
ASSET1="supabase_${VERSION}_${PLATFORM}.tar.gz"
ASSET2="supabase_${PLATFORM}.tar.gz"
ARCHIVE="$TMPDIR/$ASSET1"
URL1="${DOWNLOAD_BASE}/${ASSET1}"
URL2="${DOWNLOAD_BASE}/${ASSET2}"
echo "→ Attempting to download $ASSET1..."
if ! curl --fail -L -o "$ARCHIVE" "$URL1"; then
echo "[INFO] $ASSET1 not found, falling back to $ASSET2"
ARCHIVE="$TMPDIR/$ASSET2"
curl --fail -L -o "$ARCHIVE" "$URL2"
fi
echo "→ Extracting..."
mkdir -p "$TMPDIR/extracted"
tar -xzf "$ARCHIVE" -C "$TMPDIR/extracted"
# —— Install ——
mkdir -p "$BIN_DIR"
mv "$TMPDIR/extracted/supabase" "$BIN_DIR/supabase"
chmod +x "$BIN_DIR/supabase"
# —— Clear macOS quarantine ——
if command -v xattr >/dev/null 2>&1; then
xattr -dr com.apple.quarantine "$BIN_DIR/supabase" 2>/dev/null || true
fi
rm -rf "$TMPDIR"
echo
echo "✔ supabase CLI ${VERSION} installed to $BIN_DIR/supabase"
echo "👉 Ensure ~/.local/bin is in your PATH, e.g.:"
echo " export PATH=\"\$HOME/.local/bin:\$PATH\""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment