-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·96 lines (76 loc) · 2.22 KB
/
install.sh
File metadata and controls
executable file
·96 lines (76 loc) · 2.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
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
#!/usr/bin/env bash
set -euo pipefail
REPO="AxmeAI/axme-code"
INSTALL_DIR="${AXME_INSTALL_DIR:-$HOME/.local/bin}"
# Detect OS and architecture
detect_platform() {
local os arch
os="$(uname -s | tr '[:upper:]' '[:lower:]')"
arch="$(uname -m)"
case "$os" in
linux) os="linux" ;;
darwin) os="darwin" ;;
*) echo "Unsupported OS: $os" >&2; exit 1 ;;
esac
case "$arch" in
x86_64|amd64) arch="x64" ;;
aarch64|arm64) arch="arm64" ;;
*) echo "Unsupported architecture: $arch" >&2; exit 1 ;;
esac
echo "${os}-${arch}"
}
# Get latest release tag from GitHub API
get_latest_version() {
local url="https://api.github.com/repos/${REPO}/releases/latest"
if command -v curl &>/dev/null; then
curl -fsSL "$url" | grep '"tag_name"' | head -1 | sed 's/.*"tag_name": *"//;s/".*//'
elif command -v wget &>/dev/null; then
wget -qO- "$url" | grep '"tag_name"' | head -1 | sed 's/.*"tag_name": *"//;s/".*//'
else
echo "Neither curl nor wget found" >&2; exit 1
fi
}
# Download binary
download() {
local url="$1" dest="$2"
if command -v curl &>/dev/null; then
curl -fsSL -o "$dest" "$url"
else
wget -qO "$dest" "$url"
fi
}
main() {
local platform version download_url tmp
platform="$(detect_platform)"
echo "Detected platform: ${platform}"
if [ -n "${1:-}" ]; then
version="$1"
else
echo "Fetching latest release..."
version="$(get_latest_version)"
fi
if [ -z "$version" ]; then
echo "Could not determine latest version. Specify version: ./install.sh v0.1.0" >&2
exit 1
fi
echo "Installing axme-code ${version} (${platform})..."
download_url="https://github.com/${REPO}/releases/download/${version}/axme-code-${platform}"
tmp="$(mktemp)"
trap 'rm -f "${tmp:-}"' EXIT INT TERM
download "$download_url" "$tmp"
mkdir -p "$INSTALL_DIR"
mv "$tmp" "${INSTALL_DIR}/axme-code"
chmod +x "${INSTALL_DIR}/axme-code"
echo ""
echo "Installed axme-code to ${INSTALL_DIR}/axme-code"
if ! echo "$PATH" | tr ':' '\n' | grep -qx "$INSTALL_DIR"; then
echo ""
echo "Add to your PATH:"
echo " export PATH=\"${INSTALL_DIR}:\$PATH\""
fi
echo ""
echo "Get started:"
echo " cd your-project"
echo " axme-code setup"
}
main "$@"