-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·38 lines (30 loc) · 1.13 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·38 lines (30 loc) · 1.13 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
#!/usr/bin/env bash
# Install apple-docs CLI from the latest GitHub release.
# Usage: curl -fsSL https://raw.githubusercontent.com/ethan-huo/apple-docs/main/install.sh | bash
set -euo pipefail
REPO="ethan-huo/apple-docs"
INSTALL_DIR="${APPLE_DOCS_INSTALL_DIR:-$HOME/.local/bin}"
# Resolve version — accept explicit arg or fetch latest tag.
if [ "${1:-}" != "" ]; then
tag="v${1#v}"
else
tag=$(curl -fsSL "https://api.github.com/repos/$REPO/releases/latest" \
| grep '"tag_name"' | head -1 | cut -d '"' -f 4)
fi
if [ -z "$tag" ]; then
echo "error: failed to resolve release tag" >&2
exit 1
fi
url="https://github.com/$REPO/releases/download/$tag/apple-docs.tar.gz"
echo "Installing apple-docs $tag to $INSTALL_DIR ..."
mkdir -p "$INSTALL_DIR"
curl -fsSL "$url" | tar -xz -C "$INSTALL_DIR"
if ! command -v bun >/dev/null 2>&1; then
echo "bun runtime not found — installing ..."
curl -fsSL https://bun.sh/install | bash
fi
case ":$PATH:" in
*":$INSTALL_DIR:"*) ;;
*) echo "hint: add $INSTALL_DIR to your PATH if it is not already" ;;
esac
echo "done: $(command -v apple-docs 2>/dev/null || echo "$INSTALL_DIR/apple-docs")"