#!/bin/sh # foundry CLI installer — curl -fsSL https://raw.githubusercontent.com/Allonsygmbh/foundry-cli/main/install.sh | sh # # Installs the latest released binary to ~/.local/bin/foundry. The box only # ever touches the PUBLIC releases repo — the source stays private. # # Idempotent: re-running replaces the binary with the same (or newer) release # and changes nothing else. The write is temp+rename, so a crash mid-download # never leaves half a binary where a working one used to be. # # The legacy bash `foundry` (in ~/workspace/dev-vm/bin) stays untouched: the Go # binary delegates every subcommand it has not taken over yet, so `foundry todo` # keeps working through the transition. set -eu REPO="Allonsygmbh/foundry-cli" INSTALL_DIR="${FOUNDRY_INSTALL_DIR:-$HOME/.local/bin}" case "$(uname -m)" in x86_64) ARCH="amd64" ;; aarch64|arm64) ARCH="arm64" ;; *) echo "foundry install: unsupported architecture: $(uname -m)" >&2; exit 1 ;; esac ASSET="foundry_linux_${ARCH}" URL="https://github.com/${REPO}/releases/latest/download/${ASSET}" mkdir -p "$INSTALL_DIR" TMP="$(mktemp "${INSTALL_DIR}/.foundry.XXXXXX")" trap 'rm -f "$TMP"' EXIT echo "foundry install: fetching ${ASSET} …" >&2 curl -fsSL -o "$TMP" "$URL" chmod 755 "$TMP" # A binary that cannot say its own version is not a binary we install. "$TMP" version >/dev/null 2>&1 || { echo "foundry install: downloaded binary failed its own version check" >&2 exit 1 } mv -f "$TMP" "${INSTALL_DIR}/foundry" trap - EXIT echo "foundry install: $("${INSTALL_DIR}/foundry" version)" >&2 case ":$PATH:" in *":${INSTALL_DIR}:"*) ;; *) echo "foundry install: NOTE — ${INSTALL_DIR} is not in PATH" >&2 ;; esac