-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·103 lines (88 loc) · 3.21 KB
/
install.sh
File metadata and controls
executable file
·103 lines (88 loc) · 3.21 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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#!/bin/sh
set -eu
REPO="TeamCadenceAI/cadence-cli"
INSTALL_DIR="${HOME}/.local/bin"
OS_NAME="$(uname -s)"
# --- Main installer ---
main() {
# Optional GitHub org to scope Cadence uploads (e.g. sh -s MyOrg).
# Defaults to empty when omitted — install proceeds without org filtering.
org="${1:-}" # $org becomes an empty string when $1 is unset
# Detect architecture and OS
arch=$(uname -m)
case "$OS_NAME" in
Darwin)
case "$arch" in
arm64) target="aarch64-apple-darwin" ;;
x86_64) target="x86_64-apple-darwin" ;;
*)
echo "Error: unsupported architecture: $arch" >&2
exit 1
;;
esac
;;
Linux)
case "$arch" in
arm64|aarch64) target="aarch64-unknown-linux-gnu" ;;
x86_64|amd64) target="x86_64-unknown-linux-gnu" ;;
*)
echo "Error: unsupported architecture: $arch" >&2
exit 1
;;
esac
;;
*)
echo "Error: cadence-cli only supports macOS and Linux." >&2
exit 1
;;
esac
echo "Detected $OS_NAME $arch ($target)"
# Download tarball (uses /releases/latest/download/ redirect to avoid API rate limits)
tarball="cadence-cli-${target}.tar.gz"
download_url="https://github.com/${REPO}/releases/latest/download/${tarball}"
tmpdir=$(mktemp -d)
trap 'rm -rf "$tmpdir"' EXIT
echo "Downloading ${tarball}..."
curl -sSfL -o "${tmpdir}/${tarball}" "$download_url" || {
echo "Error: download failed." >&2
echo "Check that ${REPO} has at least one published release." >&2
echo "URL: $download_url" >&2
exit 1
}
# Extract and install
echo "Extracting..."
tar xzf "${tmpdir}/${tarball}" -C "$tmpdir" --strip-components=1
mkdir -p "$INSTALL_DIR"
echo "Installing to ${INSTALL_DIR}/cadence..."
cp "${tmpdir}/cadence" "${INSTALL_DIR}/cadence"
chmod +x "${INSTALL_DIR}/cadence"
# Show installed version for debugging
installed_version=$("${INSTALL_DIR}/cadence" --version 2>/dev/null || echo "unknown")
echo "Installed ${installed_version}"
echo "Running initial setup..."
# Pass --org to scope Cadence session uploads to a specific GitHub org.
if [ -n "$org" ]; then
echo "Installing for org: $org"
"${INSTALL_DIR}/cadence" install --org "$org" || {
echo "Warning: 'cadence install' failed. You can run it manually later." >&2
}
else
"${INSTALL_DIR}/cadence" install || {
echo "Warning: 'cadence install' failed. You can run it manually later." >&2
}
fi
echo ""
echo "${installed_version} installed successfully!"
# Check if install dir is on PATH
case ":${PATH}:" in
*":${INSTALL_DIR}:"*) ;;
*)
echo ""
echo "WARNING: ${INSTALL_DIR} is not on your PATH."
echo "Add it by running:"
echo " echo 'export PATH=\"\$HOME/.local/bin:\$PATH\"' >> ~/.zshrc"
;;
esac
}
# Forward script args so `sh -s MyOrg` passes the org to main()
main "$@"