-
-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathinstall
More file actions
executable file
·160 lines (138 loc) · 4.57 KB
/
install
File metadata and controls
executable file
·160 lines (138 loc) · 4.57 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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
#!/bin/bash
set -euo pipefail
RED='\033[0;31m'
MUTED='\033[0;2m'
NC='\033[0m'
usage() {
cat <<EOF
Sentry CLI Installer
Usage: install [options]
Options:
-h, --help Display this help message
-v, --version <version> Install a specific version (e.g., 0.2.0) or "nightly"
--no-modify-path Don't modify shell config files (.zshrc, .bashrc, etc.)
--no-completions Don't install shell completions
Environment Variables:
SENTRY_INSTALL_DIR Override the installation directory
Examples:
curl -fsSL https://cli.sentry.dev/install | bash
curl -fsSL https://cli.sentry.dev/install | bash -s -- --version nightly
curl -fsSL https://cli.sentry.dev/install | bash -s -- --version 0.2.0
SENTRY_INSTALL_DIR=~/.local/bin curl -fsSL https://cli.sentry.dev/install | bash
EOF
}
requested_version=""
no_modify_path=false
no_completions=false
while [[ $# -gt 0 ]]; do
case "$1" in
-h|--help) usage; exit 0 ;;
-v|--version)
if [[ -n "${2:-}" ]]; then
requested_version="$2"
shift 2
else
echo -e "${RED}Error: --version requires a version argument${NC}"
exit 1
fi
;;
--no-modify-path)
no_modify_path=true
shift
;;
--no-completions)
no_completions=true
shift
;;
*) shift ;;
esac
done
# Detect OS
case "$(uname -s)" in
Darwin*) os="darwin" ;;
Linux*) os="linux" ;;
MINGW*|MSYS*|CYGWIN*) os="windows" ;;
*) echo -e "${RED}Unsupported OS: $(uname -s)${NC}"; exit 1 ;;
esac
# Detect architecture
arch=$(uname -m)
case "$arch" in
x86_64) arch="x64" ;;
aarch64|arm64) arch="arm64" ;;
*) echo -e "${RED}Unsupported architecture: $arch${NC}"; exit 1 ;;
esac
# Validate supported combinations
suffix=""
if [[ "$os" == "windows" ]]; then
suffix=".exe"
if [[ "$arch" != "x64" ]]; then
echo -e "${RED}Unsupported: windows-$arch (only windows-x64 is supported)${NC}"
exit 1
fi
fi
# Resolve version and download tag.
#
# "nightly" is a special value that installs from the rolling nightly prerelease
# built from the main branch. In this case both `version` and `download_tag`
# are set to the literal string "nightly".
#
# For stable releases both are the same version string (e.g. "0.5.0").
channel="stable"
download_tag=""
if [[ -z "$requested_version" ]]; then
version=$(curl -fsSL https://api.github.com/repos/getsentry/cli/releases/latest | sed -n 's/.*"tag_name": *"\([^"]*\)".*/\1/p')
if [[ -z "$version" ]]; then
echo -e "${RED}Failed to fetch latest version${NC}"
exit 1
fi
download_tag="$version"
elif [[ "$requested_version" == "nightly" ]]; then
channel="nightly"
download_tag="nightly"
version="nightly"
else
version="$requested_version"
download_tag="$requested_version"
fi
# Strip leading 'v' if present (releases use version without 'v' prefix)
version="${version#v}"
download_tag="${download_tag#v}"
filename="sentry-${os}-${arch}${suffix}"
url="https://github.com/getsentry/cli/releases/download/${download_tag}/${filename}"
# Download binary to a temp location
tmpdir="${TMPDIR:-${TMP:-${TEMP:-/tmp}}}"
tmp_binary="${tmpdir}/sentry-install-$$${suffix}"
# Clean up temp binary on failure (setup handles cleanup on success)
trap 'rm -f "$tmp_binary"' EXIT
# For nightly the version string is literally "nightly", not a semver, so
# skip the "v" prefix that's only meaningful for numbered releases.
if [[ "$version" == "nightly" ]]; then
echo -e "${MUTED}Downloading sentry nightly...${NC}"
else
echo -e "${MUTED}Downloading sentry v${version}...${NC}"
fi
# Try gzip-compressed download first (~60% smaller, ~37 MB vs ~99 MB).
# gunzip is POSIX and available on all Unix systems.
# Falls back to raw binary if the .gz asset doesn't exist yet.
if curl -fsSL "${url}.gz" 2>/dev/null | gunzip > "$tmp_binary" 2>/dev/null; then
: # Compressed download succeeded
else
curl -fsSL --progress-bar "$url" -o "$tmp_binary"
fi
chmod +x "$tmp_binary"
# Delegate installation and configuration to the binary itself.
# setup --install handles: directory selection, binary placement, PATH,
# completions, agent skills, and the welcome message.
# --channel persists the release channel so future `sentry cli upgrade`
# calls track the same channel without requiring a flag.
setup_args="--install --method curl --channel $channel"
if [[ "$no_modify_path" == "true" ]]; then
setup_args="$setup_args --no-modify-path"
fi
if [[ "$no_completions" == "true" ]]; then
setup_args="$setup_args --no-completions"
fi
# Remove trap — setup will handle temp cleanup on success
trap - EXIT
# shellcheck disable=SC2086
"$tmp_binary" cli setup $setup_args