#!/bin/sh # Festoon installer. # # curl -fsSL https://get.festoon.dev | sh # # Downloads the standalone binary for this platform and puts it on PATH. # No Python, no package manager, no repository clone. set -eu # The PUBLIC release repository, not the private source one — a private # repo's assets 404 for unauthenticated curl. Keep in step with REPO in # src/festoon/cli/upgrade.py and RELEASE_REPO in the release workflow. REPO="${FESTOON_REPO:-standley-brent/festoon-cli}" VERSION="${FESTOON_VERSION:-latest}" # Prefer a user-writable location so the common case needs no sudo. INSTALL_DIR="${FESTOON_INSTALL_DIR:-$HOME/.local/bin}" err() { printf 'festoon: %s\n' "$1" >&2; exit 1; } detect_target() { os=$(uname -s) arch=$(uname -m) case "$os" in Darwin) os=macos ;; Linux) os=linux ;; *) err "unsupported operating system: $os (Windows: see the MSI installer)" ;; esac case "$arch" in arm64|aarch64) arch=arm64 ;; x86_64|amd64) arch=x64 ;; *) err "unsupported architecture: $arch" ;; esac printf '%s-%s' "$os" "$arch" } main() { command -v curl >/dev/null 2>&1 || err "curl is required" target=$(detect_target) if [ "$VERSION" = "latest" ]; then url="https://github.com/$REPO/releases/latest/download/festoon-$target" else url="https://github.com/$REPO/releases/download/$VERSION/festoon-$target" fi tmp=$(mktemp -d) # Always clean up, including on failure — a half-downloaded binary left in # /tmp is worse than none. trap 'rm -rf "$tmp"' EXIT INT TERM printf 'Downloading festoon (%s)...\n' "$target" if ! curl -fsSL "$url" -o "$tmp/festoon"; then err "download failed: $url If this version has no build for $target yet, check: https://github.com/$REPO/releases" fi chmod +x "$tmp/festoon" # Verify before installing, so a corrupt download cannot replace a # working install. if ! "$tmp/festoon" --version >/dev/null 2>&1; then err "the downloaded binary did not run — installation aborted" fi mkdir -p "$INSTALL_DIR" mv "$tmp/festoon" "$INSTALL_DIR/festoon" version=$("$INSTALL_DIR/festoon" --version 2>/dev/null || echo festoon) printf '\n%s installed to %s\n' "$version" "$INSTALL_DIR/festoon" case ":$PATH:" in *":$INSTALL_DIR:"*) printf '\nNext: festoon join \n' ;; *) printf '\n%s is not on your PATH. Add it:\n' "$INSTALL_DIR" printf ' echo '"'"'export PATH="%s:$PATH"'"'"' >> ~/.zshrc && exec zsh\n' "$INSTALL_DIR" printf '\nThen: festoon join \n' ;; esac } main "$@"