-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·64 lines (57 loc) · 1.62 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·64 lines (57 loc) · 1.62 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
#!/bin/bash
set -euo pipefail
REPO="rickcrawford/markdowninthemiddle"
INSTALL_DIR="${1:-.}"
# Detect OS
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
if [ "$OS" = "darwin" ]; then
OS="darwin"
elif [ "$OS" = "linux" ]; then
OS="linux"
elif [ "$OS" = "mingw64_nt" ] || [ "$OS" = "msys_nt" ]; then
OS="windows"
else
echo "Unsupported OS: $OS" >&2
exit 1
fi
# Detect architecture
ARCH=$(uname -m)
case "$ARCH" in
x86_64 | amd64)
ARCH="amd64"
;;
aarch64 | arm64)
ARCH="arm64"
;;
*)
echo "Unsupported architecture: $ARCH" >&2
exit 1
;;
esac
# Get latest release tag
echo "Fetching latest release from $REPO..."
LATEST=$(curl -fsSL "https://api.github.com/repos/$REPO/releases/latest" | grep '"tag_name"' | head -1 | cut -d'"' -f4)
if [ -z "$LATEST" ]; then
echo "Failed to fetch latest release" >&2
exit 1
fi
echo "Latest version: $LATEST"
# Download and extract
if [ "$OS" = "windows" ]; then
ARCHIVE="markdowninthemiddle-windows-amd64.zip"
URL="https://github.com/$REPO/releases/download/$LATEST/$ARCHIVE"
echo "Downloading $ARCHIVE from $URL..."
curl -fsSL "$URL" -o "$ARCHIVE"
unzip -o "$ARCHIVE" -d "$INSTALL_DIR"
rm "$ARCHIVE"
BINARY="$INSTALL_DIR/markdowninthemiddle/markdowninthemiddle.exe"
else
ARCHIVE="markdowninthemiddle-$OS-$ARCH.tar.gz"
URL="https://github.com/$REPO/releases/download/$LATEST/$ARCHIVE"
echo "Downloading $ARCHIVE from $URL..."
curl -fsSL "$URL" | tar -xz -C "$INSTALL_DIR" --strip-components=0
BINARY="$INSTALL_DIR/markdowninthemiddle/markdowninthemiddle"
chmod +x "$BINARY"
fi
echo "✓ Installed markdowninthemiddle to $BINARY"
echo "Run: $BINARY --help"