-
Notifications
You must be signed in to change notification settings - Fork 102
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·79 lines (63 loc) · 1.99 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·79 lines (63 loc) · 1.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/usr/bin/env bash
set -euo pipefail
REPO="google/sam"
INSTALL_DIR="/usr/local/bin"
echo "Installing SAM from $REPO..."
# Get OS and Arch
OS="$(uname -s)"
case "${OS}" in
Linux*) OS_NAME="Linux";;
Darwin*) OS_NAME="Darwin";;
*) echo "Unsupported OS: ${OS}"; exit 1;;
esac
ARCH="$(uname -m)"
case "${ARCH}" in
x86_64*) ARCH_NAME="x86_64";;
aarch64*) ARCH_NAME="arm64";;
arm64*) ARCH_NAME="arm64";;
*) echo "Unsupported architecture: ${ARCH}"; exit 1;;
esac
# Get latest release version
echo "Fetching latest release information..."
LATEST_RELEASE_URL="https://api.github.com/repos/${REPO}/releases/latest"
VERSION=$(curl -s $LATEST_RELEASE_URL | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')
if [ -z "$VERSION" ]; then
echo "Error: Could not find the latest release."
exit 1
fi
echo "Found latest version: ${VERSION}"
# Construct download URL (matches goreleaser name template)
TAR_NAME="sam_${OS_NAME}_${ARCH_NAME}.tar.gz"
DOWNLOAD_URL="https://github.com/${REPO}/releases/download/${VERSION}/${TAR_NAME}"
# Create a temporary directory
TMP_DIR=$(mktemp -d)
trap 'rm -rf "$TMP_DIR"' EXIT
cd "$TMP_DIR"
echo "Downloading ${DOWNLOAD_URL}..."
if ! curl -sfL -o "${TAR_NAME}" "${DOWNLOAD_URL}"; then
echo "Error: Failed to download ${DOWNLOAD_URL}"
exit 1
fi
echo "Extracting..."
tar -xzf "${TAR_NAME}"
echo "Installing to ${INSTALL_DIR} (may require sudo)..."
INSTALLED_BINS=()
for b in sam-node sam-control-plane sam-router mcp-client sam-box sam-console nano-init; do
if [ -f "$b" ]; then
INSTALLED_BINS+=("$b")
fi
done
if [ ${#INSTALLED_BINS[@]} -eq 0 ]; then
echo "Error: No SAM binaries found in release archive."
exit 1
fi
if [ -w "$INSTALL_DIR" ]; then
mv "${INSTALLED_BINS[@]}" "$INSTALL_DIR/"
else
sudo mv "${INSTALLED_BINS[@]}" "$INSTALL_DIR/"
fi
# Cleanup
cd - > /dev/null
rm -rf "$TMP_DIR"
echo "Successfully installed SAM (${VERSION}) to ${INSTALL_DIR}"
echo "Run 'sam-node --help' to get started."