Skip to content

Commit

Permalink
Updating install.sh script
Browse files Browse the repository at this point in the history
Signed-off-by: ytimocin <ytimocin@microsoft.com>
  • Loading branch information
ytimocin committed Jan 12, 2025
1 parent 1e68276 commit 35d7283
Showing 1 changed file with 20 additions and 12 deletions.
32 changes: 20 additions & 12 deletions scripts/install.sh
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -17,27 +17,35 @@ 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"

# 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

0 comments on commit 35d7283

Please sign in to comment.