-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
78 lines (63 loc) · 2.78 KB
/
install.sh
File metadata and controls
78 lines (63 loc) · 2.78 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
#!/usr/bin/env bash
# install.sh — download and install the latest github-issue-ops binary.
#
# Usage:
# curl -fsSL https://raw.githubusercontent.com/fulll/github-issue-ops/main/install.sh | bash
#
# Environment variables:
# INSTALL_DIR destination directory (default: /usr/local/bin)
# VERSION specific version tag to install (default: latest)
set -euo pipefail
REPO="fulll/github-issue-ops"
BINARY_NAME="github-issue-ops"
INSTALL_DIR="${INSTALL_DIR:-/usr/local/bin}"
GITHUB_API="https://api.github.com"
# ─── Detect OS ────────────────────────────────────────────────────────────────
case "$(uname -s)" in
Linux*) OS="linux" ;;
Darwin*) OS="macos" ;;
MINGW*|MSYS*|CYGWIN*) OS="windows" ;;
*)
echo "error: unsupported OS: $(uname -s)" >&2
exit 1
;;
esac
# ─── Detect architecture ──────────────────────────────────────────────────────
MACHINE="$(uname -m)"
case "$MACHINE" in
x86_64|amd64) ARCH="x64" ;;
arm64|aarch64) ARCH="arm64" ;;
*)
echo "error: unsupported architecture: $MACHINE" >&2
exit 1
;;
esac
ARTIFACT="${BINARY_NAME}-${OS}-${ARCH}"
[ "$OS" = "windows" ] && ARTIFACT="${ARTIFACT}.exe"
# ─── Resolve version ──────────────────────────────────────────────────────────
if [ -n "${VERSION:-}" ]; then
TAG="$VERSION"
else
echo "Detecting latest release…"
TAG=$(curl -fsSL "${GITHUB_API}/repos/${REPO}/releases/latest" \
| grep '"tag_name"' \
| sed -E 's/.*"tag_name": *"([^"]+)".*/\1/')
fi
echo "Installing ${BINARY_NAME} ${TAG} (${OS}/${ARCH})…"
# ─── Download ─────────────────────────────────────────────────────────────────
DOWNLOAD_URL="https://github.com/${REPO}/releases/download/${TAG}/${ARTIFACT}"
TMP="$(mktemp)"
curl -fsSL --progress-bar -o "$TMP" "$DOWNLOAD_URL"
chmod +x "$TMP"
# ─── Install ──────────────────────────────────────────────────────────────────
DEST="${INSTALL_DIR}/${BINARY_NAME}"
if [ -w "$INSTALL_DIR" ]; then
mv "$TMP" "$DEST"
else
echo " (sudo required for ${INSTALL_DIR})"
sudo mv "$TMP" "$DEST"
fi
echo "✓ ${BINARY_NAME} ${TAG} installed at ${DEST}"
echo ""
echo " Remember to export your GitHub token:"
echo " export GITHUB_TOKEN=ghp_xxxxxxxxxxxxxxxxxxxx"