mirror of
https://github.com/supabase/setup-cli.git
synced 2026-08-12 08:45:15 +00:00
## Summary - install the Supabase CLI through the `supabase` npm package instead of GitHub release archives - support npm-backed `latest`, `beta`, and fixed published versions, with root lockfile detection preserved - remove the `github-token` input and use Node.js/npm without clobbering an already configured Node.js 20+ runtime - update CI/docs for the v3 action contract and remove stale license cache entries for removed dependencies Addresses CLI-1480: https://linear.app/supabase/issue/CLI-1480/source-cli-install-from-npm-registry No earlier pull request found to supersede. ## Validation - `bun run ci` - real npm install spot checks for `supabase@latest`, `supabase@beta`, `supabase@1.178.2`, `supabase@2.33.0`, and legacy `supabase@1.15.1` preinstall handling - external fixture run: https://github.com/jgoux/setup-cli-testing/actions/runs/28656824691 - hosted runners: Ubuntu, macOS, and Windows for `latest`, `beta`, `1.178.2`, and `2.33.0` - package-lock detection: resolved and installed `supabase@2.108.0` - legacy preinstall: installed `supabase@1.15.1` - Node preservation: kept a caller-provided Node.js 22 runtime active after the action - Alpine 3.20 container: `latest`, `beta`, and `2.100.0`, including Node.js 20+ and runtime dependency checks - Alpine 3.18 container: rejected Node.js 18 with a clear setup error
158 lines
5.4 KiB
YAML
158 lines
5.4 KiB
YAML
name: Supabase CLI Action
|
|
description: Setup Supabase CLI, supabase, on GitHub Actions runners
|
|
author: Supabase
|
|
inputs:
|
|
version:
|
|
description: Supabase CLI version to install. Supports latest, beta, or a fixed version published to npm. If omitted, detect from the root lockfile and otherwise use latest.
|
|
required: false
|
|
outputs:
|
|
version:
|
|
description: Version of installed Supabase CLI
|
|
value: ${{ steps.setup-cli.outputs.version }}
|
|
runs:
|
|
using: composite
|
|
steps:
|
|
- id: bun-download
|
|
name: Resolve Bun Download URL
|
|
shell: sh
|
|
working-directory: ${{ github.action_path }}
|
|
run: |
|
|
set -eu
|
|
|
|
is_musl=false
|
|
|
|
if [ "${RUNNER_OS}" = "Linux" ]; then
|
|
# setup-bun does not detect Linux musl yet, so Alpine-like containers need the musl asset explicitly.
|
|
if [ -f /etc/alpine-release ]; then
|
|
is_musl=true
|
|
elif command -v ldd >/dev/null 2>&1 && ldd --version 2>&1 | grep -qi musl; then
|
|
is_musl=true
|
|
fi
|
|
fi
|
|
|
|
echo "is-musl=${is_musl}" >> "$GITHUB_OUTPUT"
|
|
|
|
if [ "${is_musl}" != "true" ]; then
|
|
exit 0
|
|
fi
|
|
|
|
version="$(cat .bun-version)"
|
|
case "$(uname -m)" in
|
|
x86_64) arch="x64" ;;
|
|
aarch64|arm64) arch="aarch64" ;;
|
|
*)
|
|
echo "Unsupported Linux musl architecture: $(uname -m)" >&2
|
|
exit 1
|
|
;;
|
|
esac
|
|
|
|
echo "url=https://github.com/oven-sh/bun/releases/download/bun-v${version}/bun-linux-${arch}-musl.zip" >> "$GITHUB_OUTPUT"
|
|
|
|
- name: Install Alpine Runtime Dependencies
|
|
shell: sh
|
|
run: |
|
|
set -eu
|
|
|
|
if [ "${{ steps.bun-download.outputs.is-musl }}" != "true" ]; then
|
|
exit 0
|
|
fi
|
|
|
|
# Alpine/musl containers need runtime packages for Bun and the npm CLI shim.
|
|
# actions/setup-node uses glibc Node builds, so install Alpine's Node/npm instead.
|
|
if command -v apk >/dev/null 2>&1; then
|
|
missing_packages=""
|
|
for package in libstdc++ libgcc nodejs npm; do
|
|
if ! apk info -e "${package}" >/dev/null 2>&1; then
|
|
missing_packages="${missing_packages} ${package}"
|
|
fi
|
|
done
|
|
|
|
if [ -z "${missing_packages}" ]; then
|
|
exit 0
|
|
fi
|
|
|
|
if [ "$(id -u)" != "0" ]; then
|
|
echo "::error::Alpine/musl containers need${missing_packages} to run Supabase CLI. Add 'apk add --no-cache${missing_packages}' before supabase/setup-cli, or run this job container as root."
|
|
exit 1
|
|
fi
|
|
|
|
apk add --no-cache ${missing_packages}
|
|
exit 0
|
|
fi
|
|
|
|
echo "::error::Linux musl containers need libstdc++, libgcc, nodejs, and npm to run Supabase CLI. Install them before supabase/setup-cli."
|
|
exit 1
|
|
|
|
- id: node-runtime
|
|
name: Resolve Node Runtime
|
|
shell: sh
|
|
run: |
|
|
set -eu
|
|
|
|
node_version=""
|
|
node_major=""
|
|
has_npm=false
|
|
|
|
if command -v node >/dev/null 2>&1; then
|
|
node_version="$(node -p 'process.versions.node' 2>/dev/null || true)"
|
|
node_major="${node_version%%.*}"
|
|
fi
|
|
|
|
if command -v npm >/dev/null 2>&1; then
|
|
has_npm=true
|
|
fi
|
|
|
|
if [ -n "${node_version}" ] && [ "${has_npm}" = "true" ]; then
|
|
case "${node_major}" in
|
|
''|*[!0-9]*)
|
|
echo "::error::Could not determine Node.js version from '${node_version}'. Supabase CLI npm installs require Node.js 20 or newer."
|
|
exit 1
|
|
;;
|
|
esac
|
|
|
|
if [ "${node_major}" -lt 20 ]; then
|
|
echo "::error::Supabase CLI npm installs require Node.js 20 or newer, but found Node.js ${node_version}. Set up Node.js 20+ before supabase/setup-cli, or use a runner image with Node.js 20+ and npm."
|
|
exit 1
|
|
fi
|
|
|
|
echo "setup-node=false" >> "$GITHUB_OUTPUT"
|
|
exit 0
|
|
fi
|
|
|
|
if [ "${{ steps.bun-download.outputs.is-musl }}" = "true" ]; then
|
|
echo "::error::Linux musl containers need Node.js 20 or newer and npm from musl-compatible packages. Install libstdc++, libgcc, nodejs, and npm before supabase/setup-cli, or run this job container as root so the action can install them."
|
|
exit 1
|
|
fi
|
|
|
|
if [ -n "${node_version}" ] || [ "${has_npm}" = "true" ]; then
|
|
echo "::error::Supabase CLI npm installs need both Node.js 20+ and npm. Found Node.js '${node_version:-missing}' and npm '${has_npm}'. Configure both before supabase/setup-cli."
|
|
exit 1
|
|
fi
|
|
|
|
echo "setup-node=true" >> "$GITHUB_OUTPUT"
|
|
|
|
- name: Setup Node
|
|
if: ${{ steps.node-runtime.outputs.setup-node == 'true' }}
|
|
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
|
|
with:
|
|
node-version: 24
|
|
|
|
- name: Setup Bun
|
|
uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0
|
|
with:
|
|
bun-version-file: ${{ github.action_path }}/.bun-version
|
|
bun-download-url: ${{ steps.bun-download.outputs.url }}
|
|
|
|
- name: Install Action Dependencies
|
|
shell: sh
|
|
working-directory: ${{ github.action_path }}
|
|
run: bun install --frozen-lockfile --production
|
|
|
|
- id: setup-cli
|
|
name: Setup Supabase CLI
|
|
shell: sh
|
|
working-directory: ${{ github.action_path }}
|
|
env:
|
|
INPUT_VERSION: ${{ inputs.version }}
|
|
run: bun src/main.ts
|