diff --git a/scripts/install.sh b/scripts/install.sh index 0ad6f18..234ce90 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -1,13 +1,13 @@ #!/bin/bash -set -e +set -euo pipefail # Get the latest release version if not provided -VERSION=${1:-$(curl -s https://api.github.com/repos/prompt-ops/pops/releases/latest | grep tag_name | cut -d '"' -f 4)} +VERSION=${1:-$(curl -s https://api.github.com/repos/prompt-ops/pops/releases/latest | grep '"tag_name"' | cut -d '"' -f 4)} # Check if the version is valid if [[ ! "$VERSION" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then - echo "Invalid version format: '$VERSION'. Expected format: vX.Y.Z" + echo "Error: Invalid version format: '$VERSION'. Expected format: vX.Y.Z" exit 1 fi @@ -17,14 +17,14 @@ echo "Installing Prompt-Ops $VERSION..." OS=$(uname | tr '[:upper:]' '[:lower:]') ARCH=$(uname -m) -if [[ "$ARCH" == "x86_64" ]]; then - ARCH="amd64" -elif [[ "$ARCH" == "arm64" || "$ARCH" == "aarch64" ]]; then - ARCH="arm64" -else - echo "Unsupported architecture: $ARCH" +case "$ARCH" in +x86_64) ARCH="amd64" ;; +arm64 | aarch64) ARCH="arm64" ;; +*) + echo "Error: Unsupported architecture: $ARCH" exit 1 -fi + ;; +esac echo "Detected OS: $OS" echo "Detected ARCH: $ARCH" @@ -32,12 +32,20 @@ echo "Detected ARCH: $ARCH" # Construct download URL URL="https://github.com/prompt-ops/pops/releases/download/$VERSION/pops-${OS}-${ARCH}" +# Download binary echo "Downloading Prompt-Ops $VERSION from $URL..." curl -Lo pops "$URL" chmod +x pops -# Move to /usr/local/bin +# Move to /usr/local/bin (requires sudo) echo "Installing Prompt-Ops to /usr/local/bin..." sudo mv pops /usr/local/bin/ -echo "Prompt-Ops $VERSION installed successfully!" +# Verify installation +if command -v pops >/dev/null 2>&1; then + echo "Prompt-Ops $VERSION installed successfully!" + pops version +else + echo "Error: Installation failed. 'pops' command not found." + exit 1 +fi