forked from trunk-io/flake-farm-staging
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathget-trunk-cli
More file actions
executable file
·48 lines (39 loc) · 1.18 KB
/
get-trunk-cli
File metadata and controls
executable file
·48 lines (39 loc) · 1.18 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
#!/bin/bash
# get-trunk-cli.sh
set -euo pipefail
REPO="trunk-io/analytics-cli"
VERSION="${TRUNK_CLI_VERSION:-0.12.11-beta.1}"
# Normalize OS/arch to match launcher script platform naming
OS="$(uname -s | tr '[:upper:]' '[:lower:]')" # linux | darwin
ARCH="$(uname -m)"
# Map to platform names used by trunk-analytics-cli releases
if [[ ${OS} == "darwin" ]]; then
case "${ARCH}" in
arm64 | aarch64) PLATFORM="aarch64-apple-darwin" ;;
x86_64) PLATFORM="x86_64-apple-darwin" ;;
*)
echo "Unsupported macOS architecture: ${ARCH}" >&2
exit 1
;;
esac
elif [[ ${OS} == "linux" ]]; then
case "${ARCH}" in
aarch64 | arm64) PLATFORM="aarch64-unknown-linux" ;;
x86_64) PLATFORM="x86_64-unknown-linux" ;;
*)
echo "Unsupported Linux architecture: ${ARCH}" >&2
exit 1
;;
esac
else
echo "Unsupported OS: ${OS}" >&2
exit 1
fi
ASSET="trunk-analytics-cli-${PLATFORM}.tar.gz"
URL="https://github.com/${REPO}/releases/download/${VERSION}/${ASSET}"
echo "Downloading and installing ${ASSET}…"
curl -fL --retry 3 "${URL}" | tar -xz
# Tarball contains a single file named trunk-analytics-cli
chmod +x trunk-analytics-cli
echo "Installed to ./trunk-analytics-cli"
./trunk-analytics-cli --version