Skip to content

Commit 0e0c248

Browse files
committed
Add install script with one-liner for Linux, macOS, FreeBSD, OpenBSD, Windows
1 parent aead79d commit 0e0c248

File tree

2 files changed

+48
-1
lines changed

2 files changed

+48
-1
lines changed

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@ file signing and encryption. SSH signing uses FIDO2 ed25519-sk keys
1010

1111
## Install
1212

13-
Download a binary from [Releases](../../releases), or build from source:
13+
```
14+
curl -fsSL https://raw.githubusercontent.com/8ff/sear/main/install.sh | sudo sh
15+
```
16+
17+
Or download a binary from [Releases](../../releases), or build from source:
1418

1519
```
1620
go build -o sear .

install.sh

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/bin/sh
2+
set -eu
3+
4+
REPO="8ff/sear"
5+
INSTALL_DIR="${INSTALL_DIR:-/usr/local/bin}"
6+
7+
OS="$(uname -s | tr '[:upper:]' '[:lower:]')"
8+
ARCH="$(uname -m)"
9+
10+
case "$ARCH" in
11+
x86_64|amd64) ARCH="amd64" ;;
12+
aarch64|arm64) ARCH="arm64" ;;
13+
i386|i686) ARCH="386" ;;
14+
*) printf "Unsupported architecture: %s\n" "$ARCH" >&2; exit 1 ;;
15+
esac
16+
17+
case "$OS" in
18+
linux|darwin|freebsd|openbsd) ;;
19+
mingw*|msys*|cygwin*) OS="windows" ;;
20+
*) printf "Unsupported OS: %s\n" "$OS" >&2; exit 1 ;;
21+
esac
22+
23+
EXT=""
24+
if [ "$OS" = "windows" ]; then EXT=".exe"; fi
25+
BINARY="sear-${OS}-${ARCH}${EXT}"
26+
27+
VERSION="$(curl -fsSL "https://api.github.com/repos/${REPO}/releases/latest" | grep '"tag_name"' | cut -d'"' -f4)"
28+
if [ -z "$VERSION" ]; then
29+
printf "Failed to fetch latest version\n" >&2
30+
exit 1
31+
fi
32+
33+
URL="https://github.com/${REPO}/releases/download/${VERSION}/${BINARY}"
34+
printf "Installing sear %s (%s/%s) to %s\n" "$VERSION" "$OS" "$ARCH" "$INSTALL_DIR"
35+
36+
TMP="$(mktemp)"
37+
trap 'rm -f "$TMP"' EXIT
38+
39+
curl -fsSL -o "$TMP" "$URL"
40+
chmod +x "$TMP"
41+
mv "$TMP" "${INSTALL_DIR}/sear${EXT}"
42+
43+
printf "Done: sear %s\n" "$("${INSTALL_DIR}/sear${EXT}" version 2>/dev/null || echo "$VERSION")"

0 commit comments

Comments
 (0)