-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·62 lines (51 loc) · 1.62 KB
/
install.sh
File metadata and controls
executable file
·62 lines (51 loc) · 1.62 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
#!/bin/bash
set -euo pipefail
# Script to install secret CLI from GitHub releases
REPO="Avdushin/secret"
BINARY_NAME="secret"
INSTALL_DIR="/usr/local/bin"
# Fetch latest version tag
LATEST_TAG=$(curl -s https://api.github.com/repos/${REPO}/releases/latest | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')
if [ -z "$LATEST_TAG" ]; then
echo "Failed to fetch latest release tag. Check if the repo exists and has releases."
exit 1
fi
# Detect OS
OS="$(uname -s | tr '[:upper:]' '[:lower:]')"
if [ "$OS" = "darwin" ]; then
OS="darwin"
elif [ "$OS" = "linux" ]; then
OS="linux"
else
echo "Unsupported OS: $OS. For Windows, download manually from releases."
exit 1
fi
# Detect architecture
ARCH="$(uname -m)"
if [ "$ARCH" = "x86_64" ]; then
ARCH="amd64"
elif [ "$ARCH" = "aarch64" ] || [ "$ARCH" = "arm64" ]; then
ARCH="arm64"
else
echo "Unsupported architecture: $ARCH"
exit 1
fi
# Construct download URL
if [ "$OS" = "windows" ]; then
EXT=".exe"
else
EXT=""
fi
FILE_NAME="${BINARY_NAME}-${OS}-${ARCH}${EXT}"
RELEASE_URL="https://github.com/${REPO}/releases/download/${LATEST_TAG}/${FILE_NAME}"
# Download the binary
echo "Downloading ${FILE_NAME} from ${RELEASE_URL}..."
curl -L -o "${BINARY_NAME}" "${RELEASE_URL}" || { echo "Download failed. Check if the asset exists in the release."; exit 1; }
# Make executable (skip for Windows .exe)
if [ "$OS" != "windows" ]; then
chmod +x "${BINARY_NAME}"
fi
# Move to install dir
echo "Installing to ${INSTALL_DIR}/${BINARY_NAME}..."
sudo mv "${BINARY_NAME}" "${INSTALL_DIR}/${BINARY_NAME}"
echo "Installation complete! Run 'secret --help' to get started."