cli/tools/install/ci.sh
Snider cb5f7030d6 feat(cli): wire release command and add installer scripts
- Wire up `core build release` subcommand (was orphaned)
- Wire up `core monitor` command (missing import in full variant)
- Add installer scripts for Unix (.sh) and Windows (.bat)
  - setup: Interactive with variant selection
  - ci: Minimal for CI/CD environments
  - dev: Full development variant
  - go/php/agent: Targeted development variants
- All scripts include security hardening:
  - Secure temp directories (mktemp -d)
  - Architecture validation
  - Version validation after GitHub API call
  - Proper cleanup on exit
  - PowerShell PATH updates on Windows (avoids setx truncation)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-03 06:22:07 +00:00

50 lines
1.4 KiB
Bash

#!/bin/bash
# Core CLI installer for CI environments
# Minimal, fast, no interactive prompts
# Usage: curl -fsSL https://core.io.in/ci.sh | bash
# VERSION=v1.0.0 curl -fsSL https://core.io.in/ci.sh | bash
set -eo pipefail
VERSION="${VERSION:-${1:-latest}}"
REPO="host-uk/core"
BINARY="core"
# Detect platform
OS="$(uname -s | tr '[:upper:]' '[:lower:]')"
ARCH="$(uname -m)"
case "$ARCH" in
x86_64|amd64) ARCH="amd64" ;;
arm64|aarch64) ARCH="arm64" ;;
*) echo "Unsupported architecture: $ARCH" >&2; exit 1 ;;
esac
# Resolve latest
if [ "$VERSION" = "latest" ]; then
VERSION=$(curl -fsSL "https://api.github.com/repos/${REPO}/releases/latest" | grep '"tag_name"' | sed -E 's/.*"([^"]+)".*/\1/')
if [ -z "$VERSION" ]; then
echo "Failed to fetch latest version from GitHub API" >&2
exit 1
fi
fi
echo "Installing ${BINARY} ${VERSION} (${OS}/${ARCH})..."
# Download and extract to secure temp dir
ARCHIVE="${BINARY}-${OS}-${ARCH}.tar.gz"
TMPDIR=$(mktemp -d)
trap 'rm -rf "$TMPDIR"' EXIT
if ! curl -fsSL "https://github.com/${REPO}/releases/download/${VERSION}/${ARCHIVE}" -o "$TMPDIR/$ARCHIVE"; then
echo "Failed to download ${ARCHIVE}" >&2
exit 1
fi
tar -xzf "$TMPDIR/$ARCHIVE" -C "$TMPDIR"
# Install (CI runners typically have write access to /usr/local/bin)
if [ -w /usr/local/bin ]; then
mv "$TMPDIR/${BINARY}" /usr/local/bin/
else
sudo mv "$TMPDIR/${BINARY}" /usr/local/bin/
fi
${BINARY} --version