mirror of
https://github.com/aljazceru/goose.git
synced 2025-12-18 06:34:26 +01:00
Co-authored-by: Michael Neale <michael.neale@gmail.com> Co-authored-by: Wendy Tang <wendytang@squareup.com> Co-authored-by: Jarrod Sibbison <72240382+jsibbison-square@users.noreply.github.com> Co-authored-by: Alex Hancock <alex.hancock@example.com> Co-authored-by: Alex Hancock <alexhancock@block.xyz> Co-authored-by: Lifei Zhou <lifei@squareup.com> Co-authored-by: Wes <141185334+wesrblock@users.noreply.github.com> Co-authored-by: Max Novich <maksymstepanenko1990@gmail.com> Co-authored-by: Zaki Ali <zaki@squareup.com> Co-authored-by: Salman Mohammed <smohammed@squareup.com> Co-authored-by: Kalvin C <kalvinnchau@users.noreply.github.com> Co-authored-by: Alec Thomas <alec@swapoff.org> Co-authored-by: lily-de <119957291+lily-de@users.noreply.github.com> Co-authored-by: kalvinnchau <kalvin@block.xyz> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Rizel Scarlett <rizel@squareup.com> Co-authored-by: bwrage <bwrage@squareup.com> Co-authored-by: Kalvin Chau <kalvin@squareup.com> Co-authored-by: Alice Hau <110418948+ahau-square@users.noreply.github.com> Co-authored-by: Alistair Gray <ajgray@stripe.com> Co-authored-by: Nahiyan Khan <nahiyan.khan@gmail.com> Co-authored-by: Alex Hancock <alexhancock@squareup.com> Co-authored-by: Nahiyan Khan <nahiyan@squareup.com> Co-authored-by: marcelle <1852848+laanak08@users.noreply.github.com> Co-authored-by: Yingjie He <yingjiehe@block.xyz> Co-authored-by: Yingjie He <yingjiehe@squareup.com> Co-authored-by: Lily Delalande <ldelalande@block.xyz> Co-authored-by: Adewale Abati <acekyd01@gmail.com> Co-authored-by: Ebony Louis <ebony774@gmail.com> Co-authored-by: Angie Jones <jones.angie@gmail.com> Co-authored-by: Ebony Louis <55366651+EbonyLouis@users.noreply.github.com>
107 lines
2.9 KiB
Bash
Executable File
107 lines
2.9 KiB
Bash
Executable File
#!/usr/bin/env bash
|
||
set -euo pipefail
|
||
|
||
##############################################################################
|
||
# Goose CLI Install Script
|
||
#
|
||
# This script downloads the latest stable 'goose' CLI binary from GitHub releases
|
||
# and installs it to your system.
|
||
#
|
||
# Supported OS: macOS (darwin), Linux
|
||
# Supported Architectures: x86_64, arm64
|
||
#
|
||
# Usage:
|
||
# curl -fsSL https://github.com/block/goose/releases/download/stable/download_cli.sh | sh
|
||
#
|
||
# Environment variables:
|
||
# GOOSE_BIN_DIR - Directory to which Goose will be installed (default: $HOME/.local/bin)
|
||
# GOOSE_PROVIDER - Optional: provider for goose
|
||
# GOOSE_MODEL - Optional: model for goose
|
||
# ** other provider specific environment variables (eg. DATABRICKS_HOST)
|
||
##############################################################################
|
||
|
||
# --- 1) Check for curl ---
|
||
if ! command -v curl >/dev/null 2>&1; then
|
||
echo "Error: 'curl' is required to download Goose. Please install curl and try again."
|
||
exit 1
|
||
fi
|
||
|
||
# --- 2) Variables ---
|
||
REPO="block/goose"
|
||
OUT_FILE="goose"
|
||
GOOSE_BIN_DIR="${GOOSE_BIN_DIR:-"$HOME/.local/bin"}"
|
||
|
||
# --- 3) Detect OS/Architecture ---
|
||
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
|
||
ARCH=$(uname -m)
|
||
|
||
case "$OS" in
|
||
linux|darwin) ;;
|
||
*)
|
||
echo "Error: Unsupported OS '$OS'. Goose currently only supports Linux and macOS."
|
||
exit 1
|
||
;;
|
||
esac
|
||
|
||
case "$ARCH" in
|
||
x86_64)
|
||
ARCH="x86_64"
|
||
;;
|
||
arm64|aarch64)
|
||
# Some systems use 'arm64' and some 'aarch64' – standardize to 'aarch64'
|
||
ARCH="aarch64"
|
||
;;
|
||
*)
|
||
echo "Error: Unsupported architecture '$ARCH'."
|
||
exit 1
|
||
;;
|
||
esac
|
||
|
||
# Build the filename and URL for the stable release
|
||
if [ "$OS" = "darwin" ]; then
|
||
FILE="goose-$ARCH-apple-darwin.tar.bz2"
|
||
else
|
||
FILE="goose-$ARCH-unknown-linux-gnu.tar.bz2"
|
||
fi
|
||
|
||
DOWNLOAD_URL="https://github.com/$REPO/releases/download/stable/$FILE"
|
||
|
||
# --- 4) Download & extract 'goose' binary ---
|
||
echo "Downloading stable release: $FILE..."
|
||
if ! curl -sLf "$DOWNLOAD_URL" --output "$FILE"; then
|
||
echo "Error: Failed to download $DOWNLOAD_URL"
|
||
exit 1
|
||
fi
|
||
|
||
echo "Extracting $FILE..."
|
||
tar -xjf "$FILE"
|
||
rm "$FILE" # clean up the downloaded tarball
|
||
|
||
# Make binaries executable
|
||
chmod +x goose
|
||
|
||
# --- 5) Install to $GOOSE_BIN_DIR ---
|
||
if [ ! -d "$GOOSE_BIN_DIR" ]; then
|
||
echo "Creating directory: $GOOSE_BIN_DIR"
|
||
mkdir -p "$GOOSE_BIN_DIR"
|
||
fi
|
||
|
||
echo "Moving goose to $GOOSE_BIN_DIR/$OUT_FILE"
|
||
mv goose "$GOOSE_BIN_DIR/$OUT_FILE"
|
||
|
||
# --- 6) Configure Goose (Optional) ---
|
||
echo ""
|
||
echo "Configuring Goose"
|
||
echo ""
|
||
"$GOOSE_BIN_DIR/$OUT_FILE" configure
|
||
|
||
# --- 7) Check PATH and give instructions if needed ---
|
||
if [[ ":$PATH:" != *":$GOOSE_BIN_DIR:"* ]]; then
|
||
echo ""
|
||
echo "Warning: Goose installed, but $GOOSE_BIN_DIR is not in your PATH."
|
||
echo "Add it to your PATH by editing ~/.bashrc, ~/.zshrc, or similar:"
|
||
echo " export PATH=\"$GOOSE_BIN_DIR:\$PATH\""
|
||
echo "Then reload your shell (e.g. 'source ~/.bashrc', 'source ~/.zshrc') to apply changes."
|
||
echo ""
|
||
fi
|