-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
129 lines (114 loc) · 4.7 KB
/
Copy pathinstall.sh
File metadata and controls
129 lines (114 loc) · 4.7 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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
#!/bin/sh
# GitIntel AI — installer
# https://github.com/gitintel-ai/GitIntelAI
#
# Usage:
# curl -fsSL https://gitintel.com/install | sh
# curl -fsSL https://raw.githubusercontent.com/gitintel-ai/GitIntelAI/main/install.sh | sh
#
# Options (env vars):
# GITINTEL_INSTALL_DIR — destination directory (default: ~/.local/bin)
# GITINTEL_VERSION — pin a specific release tag (default: latest)
set -e
REPO="gitintel-ai/GitIntelAI"
BIN_NAME="gitintel"
INSTALL_DIR="${GITINTEL_INSTALL_DIR:-$HOME/.local/bin}"
# ── Detect OS ──────────────────────────────────────────────────────────────────
OS=$(uname -s 2>/dev/null | tr '[:upper:]' '[:lower:]')
case "$OS" in
linux*) OS="linux" ;;
darwin*) OS="macos" ;;
msys*|cygwin*|mingw*)
echo "Windows detected. Please use the PowerShell installer instead:"
echo ""
echo " irm https://gitintel.com/install.ps1 | iex"
echo ""
echo "Or download the binary directly from:"
echo " https://github.com/$REPO/releases"
exit 1
;;
*)
echo "Unsupported OS: $OS"
echo "Build from source: https://github.com/$REPO#build-from-source"
exit 1
;;
esac
# ── Detect architecture ────────────────────────────────────────────────────────
ARCH=$(uname -m 2>/dev/null)
case "$ARCH" in
x86_64|amd64) ARCH="amd64" ;;
arm64|aarch64) ARCH="arm64" ;;
*)
echo "Unsupported architecture: $ARCH"
echo "Build from source: https://github.com/$REPO#build-from-source"
exit 1
;;
esac
ARTIFACT="${BIN_NAME}-${OS}-${ARCH}"
# ── Resolve version ────────────────────────────────────────────────────────────
if [ -n "$GITINTEL_VERSION" ]; then
VERSION="$GITINTEL_VERSION"
else
printf "Fetching latest release... "
VERSION=$(curl -fsSL "https://api.github.com/repos/$REPO/releases/latest" \
2>/dev/null \
| grep '"tag_name"' \
| sed 's/.*"tag_name": *"\([^"]*\)".*/\1/')
if [ -z "$VERSION" ]; then
echo ""
echo "Error: Could not determine latest version."
echo "Check https://github.com/$REPO/releases for available versions."
echo "To pin a version: GITINTEL_VERSION=v0.1.0 curl -fsSL https://gitintel.com/install | sh"
exit 1
fi
echo "$VERSION"
fi
DOWNLOAD_URL="https://github.com/$REPO/releases/download/$VERSION/$ARTIFACT"
# ── Download ───────────────────────────────────────────────────────────────────
echo "Downloading gitintel $VERSION for $OS/$ARCH..."
TMP=$(mktemp)
trap 'rm -f "$TMP"' EXIT
if ! curl -fsSL --progress-bar "$DOWNLOAD_URL" -o "$TMP"; then
echo ""
echo "Error: Download failed."
echo "URL: $DOWNLOAD_URL"
echo ""
echo "Possible causes:"
echo " - Release $VERSION does not exist"
echo " - No network connection"
echo ""
echo "Check https://github.com/$REPO/releases"
exit 1
fi
# ── Install ────────────────────────────────────────────────────────────────────
mkdir -p "$INSTALL_DIR"
chmod +x "$TMP"
mv "$TMP" "$INSTALL_DIR/$BIN_NAME"
echo ""
echo " ✓ Installed: $INSTALL_DIR/$BIN_NAME ($VERSION)"
# ── PATH check ─────────────────────────────────────────────────────────────────
case ":${PATH}:" in
*":${INSTALL_DIR}:"*) ;;
*)
SHELL_NAME=$(basename "${SHELL:-sh}")
case "$SHELL_NAME" in
zsh) RC_FILE="$HOME/.zshrc" ;;
fish) RC_FILE="$HOME/.config/fish/config.fish" ;;
*) RC_FILE="$HOME/.bashrc" ;;
esac
echo ""
echo " ! $INSTALL_DIR is not in your PATH."
echo " Add to $RC_FILE:"
echo ""
echo " export PATH=\"\$HOME/.local/bin:\$PATH\""
echo ""
echo " Then reload your shell:"
echo " source $RC_FILE"
;;
esac
# ── Done ───────────────────────────────────────────────────────────────────────
echo ""
echo " Run 'gitintel --version' to verify."
echo " Run 'gitintel init' inside a git repo to get started."
echo " Docs: https://gitintel.com/docs/getting-started"
echo ""