-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
37 lines (32 loc) · 1.08 KB
/
install.sh
File metadata and controls
37 lines (32 loc) · 1.08 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
#!/bin/sh
set -e
REPO="andrearcaina/goforge"
BIN="goforge"
# get the latest tag from GitHub
TAG=$(curl -s "https://api.github.com/repos/$REPO/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')
# detect OS/Arch
OS="$(uname -s)"
ARCH="$(uname -m)"
EXT="tar.gz"
# detects architecture for naming consistency
case "$OS" in
Linux*) OS="Linux" ;;
Darwin*) OS="Darwin" ;;
MINGW*|MSYS*) OS="Windows"; EXT="zip"; BIN="${BIN}.exe" ;;
*) echo "Unsupported OS: $OS"; exit 1 ;;
esac
# download and extract
URL="https://github.com/$REPO/releases/download/$TAG/${BIN%.*}_${OS}_${ARCH}.$EXT"
echo "Downloading goforge $TAG for $OS..."
if [ "$EXT" = "zip" ]; then
# windows: download zip, unzip, install to ~/bin (no sudo needed)
curl -sL "$URL" -o tmp.zip
unzip -qo tmp.zip "$BIN" && rm tmp.zip
mkdir -p ~/bin && mv "$BIN" ~/bin/
echo "Installed to ~/bin/$BIN (Ensure ~/bin is in your PATH)"
else
# mac/linux: stream tar, sudo move to /usr/local/bin
curl -sL "$URL" | tar xz
sudo mv "$BIN" /usr/local/bin/
echo "Installed to /usr/local/bin/$BIN"
fi