-
Notifications
You must be signed in to change notification settings - Fork 37
Expand file tree
/
Copy pathinstall-latest-linux.sh
More file actions
executable file
·36 lines (28 loc) · 1.22 KB
/
install-latest-linux.sh
File metadata and controls
executable file
·36 lines (28 loc) · 1.22 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
#!/usr/bin/env bash
set -eo pipefail
# Install the latest version of the Linux binary
DOWNLOAD_URL="$(curl -s https://api.github.com/repos/brevdev/brev-cli/releases/latest | grep "browser_download_url.*linux.*amd64" | cut -d '"' -f 4)"
# Create temporary directory and ensure cleanup
TMP_DIR="$(mktemp -d)"
trap 'rm -rf "${TMP_DIR}"' EXIT
# Download the latest release
curl -L "${DOWNLOAD_URL}" -o "${TMP_DIR}/$(basename "${DOWNLOAD_URL}")"
# Find and extract the archive
ARCHIVE_FILE="$(find "${TMP_DIR}" -name "brev*.tar.gz" -type f)"
tar -xzf "${ARCHIVE_FILE}" -C "${TMP_DIR}"
# Install the binary to the user's local bin
INSTALL_DIR="${HOME}/.local/bin"
mkdir -p "${INSTALL_DIR}"
mv "${TMP_DIR}/brev" "${INSTALL_DIR}/brev"
chmod +x "${INSTALL_DIR}/brev"
echo "Successfully installed brev CLI to ${INSTALL_DIR}/brev"
case ":${PATH}:" in
*":${INSTALL_DIR}:"*) ;;
*)
echo
echo "Warning: ${INSTALL_DIR} is not in your PATH." >&2
echo "Add it by appending the following line to your shell profile (e.g. ~/.bashrc, ~/.zshrc):" >&2
echo " export PATH=\"\${HOME}/.local/bin:\${PATH}\"" >&2
echo "Then restart your shell or run 'source' on the profile to pick up the change." >&2
;;
esac