feat(dist): ship via GitHub Release binaries + install.sh (drop npm as primary)
Distribute the prebuilt binary through GitHub Releases instead of the npm registry — zero auth for the publisher (CI's GITHUB_TOKEN) and zero auth for consumers (no npm token / 2FA / OTP, no GitHub Packages .npmrc). - install.sh: detects OS/arch (incl. linux musl), downloads the matching agent-browser-<platform>.tar.gz from the GitHub Release, verifies .sha256, installs `agent-browser` + `abs` to /usr/local/bin or ~/.local/bin. Override via AGENT_BROWSER_VERSION / AGENT_BROWSER_BIN_DIR. - .github/workflows/release-binaries.yml: on tag push (v*), build all 7 platform variants (reusing the zigbuild cross-compile matrix), package each as .tar.gz + .sha256, attach to the tag's GitHub Release. No npm, no token. - remove .github/workflows/release.yml: it published to npm (--provenance) and built the (removed) dashboard, so it broke on every main push. - README install now leads with `curl … install.sh | sh`; npm demoted to a legacy alternative. - skill stub self-heals: if `agent-browser` is missing, run install.sh (don't fall back to other browser tools).
This commit is contained in:
Executable
+100
@@ -0,0 +1,100 @@
|
||||
#!/bin/sh
|
||||
# agent-browser-stealth installer — downloads the prebuilt binary from the
|
||||
# GitHub Release (no npm, no auth for you or your users).
|
||||
#
|
||||
# curl -fsSL https://raw.githubusercontent.com/leeguooooo/agent-browser-stealth/main/install.sh | sh
|
||||
#
|
||||
# Env overrides:
|
||||
# AGENT_BROWSER_VERSION=v0.27.0-fork.11 pin a specific release tag
|
||||
# AGENT_BROWSER_BIN_DIR=/usr/local/bin install location (auto-detected otherwise)
|
||||
set -eu
|
||||
|
||||
REPO="leeguooooo/agent-browser-stealth"
|
||||
BIN_NAME="agent-browser"
|
||||
|
||||
err() { printf '\033[31merror:\033[0m %s\n' "$1" >&2; exit 1; }
|
||||
info() { printf '\033[36m==>\033[0m %s\n' "$1" >&2; }
|
||||
|
||||
command -v curl >/dev/null 2>&1 || err "curl is required"
|
||||
command -v tar >/dev/null 2>&1 || err "tar is required"
|
||||
|
||||
# --- detect platform -> release asset name -------------------------------
|
||||
os=$(uname -s)
|
||||
arch=$(uname -m)
|
||||
case "$os" in
|
||||
Darwin) plat="darwin" ;;
|
||||
Linux) plat="linux" ;;
|
||||
*) err "unsupported OS: $os (use the Windows .exe asset from the Releases page)" ;;
|
||||
esac
|
||||
case "$arch" in
|
||||
x86_64|amd64) cpu="x64" ;;
|
||||
arm64|aarch64) cpu="arm64" ;;
|
||||
*) err "unsupported architecture: $arch" ;;
|
||||
esac
|
||||
|
||||
# musl (Alpine etc.) gets the statically-linked Linux build
|
||||
libc=""
|
||||
if [ "$plat" = "linux" ] && ! ldd /bin/sh 2>/dev/null | grep -qi 'gnu\|glibc'; then
|
||||
if [ -e /lib/ld-musl-x86_64.so.1 ] || [ -e /lib/ld-musl-aarch64.so.1 ]; then
|
||||
libc="-musl"
|
||||
fi
|
||||
fi
|
||||
asset="agent-browser-${plat}${libc}-${cpu}"
|
||||
|
||||
# --- resolve release tag --------------------------------------------------
|
||||
tag="${AGENT_BROWSER_VERSION:-}"
|
||||
if [ -z "$tag" ]; then
|
||||
info "resolving latest release..."
|
||||
tag=$(curl -fsSL "https://api.github.com/repos/${REPO}/releases/latest" \
|
||||
| grep '"tag_name"' | head -1 | sed -E 's/.*"tag_name": *"([^"]+)".*/\1/')
|
||||
[ -n "$tag" ] || err "could not resolve latest release tag (set AGENT_BROWSER_VERSION=vX.Y.Z)"
|
||||
fi
|
||||
|
||||
base="https://github.com/${REPO}/releases/download/${tag}"
|
||||
tgz_url="${base}/${asset}.tar.gz"
|
||||
sha_url="${tgz_url}.sha256"
|
||||
|
||||
# --- download + verify ----------------------------------------------------
|
||||
tmp=$(mktemp -d)
|
||||
trap 'rm -rf "$tmp"' EXIT
|
||||
info "downloading ${asset} (${tag})..."
|
||||
curl -fsSL "$tgz_url" -o "$tmp/pkg.tar.gz" \
|
||||
|| err "download failed: $tgz_url (is asset '${asset}.tar.gz' attached to release ${tag}?)"
|
||||
|
||||
if curl -fsSL "$sha_url" -o "$tmp/pkg.sha256" 2>/dev/null; then
|
||||
info "verifying checksum..."
|
||||
expected=$(awk '{print $1}' "$tmp/pkg.sha256")
|
||||
if command -v shasum >/dev/null 2>&1; then
|
||||
actual=$(shasum -a 256 "$tmp/pkg.tar.gz" | awk '{print $1}')
|
||||
elif command -v sha256sum >/dev/null 2>&1; then
|
||||
actual=$(sha256sum "$tmp/pkg.tar.gz" | awk '{print $1}')
|
||||
else
|
||||
actual=""; info "no sha256 tool found, skipping verification"
|
||||
fi
|
||||
[ -z "$actual" ] || [ "$expected" = "$actual" ] || err "checksum mismatch (expected $expected, got $actual)"
|
||||
else
|
||||
info "no .sha256 published, skipping verification"
|
||||
fi
|
||||
|
||||
tar -xzf "$tmp/pkg.tar.gz" -C "$tmp"
|
||||
[ -f "$tmp/${BIN_NAME}" ] || err "archive did not contain ${BIN_NAME}"
|
||||
chmod +x "$tmp/${BIN_NAME}"
|
||||
|
||||
# --- choose install dir ---------------------------------------------------
|
||||
bindir="${AGENT_BROWSER_BIN_DIR:-}"
|
||||
if [ -z "$bindir" ]; then
|
||||
if [ -w /usr/local/bin ] 2>/dev/null; then bindir="/usr/local/bin"; else bindir="$HOME/.local/bin"; fi
|
||||
fi
|
||||
mkdir -p "$bindir"
|
||||
|
||||
mv "$tmp/${BIN_NAME}" "$bindir/${BIN_NAME}"
|
||||
# convenience aliases: `abs` (short) -> agent-browser
|
||||
ln -sf "$bindir/${BIN_NAME}" "$bindir/abs" 2>/dev/null || true
|
||||
|
||||
info "installed ${BIN_NAME} -> ${bindir}/${BIN_NAME}"
|
||||
"$bindir/${BIN_NAME}" --version 2>/dev/null || true
|
||||
|
||||
case ":$PATH:" in
|
||||
*":$bindir:"*) : ;;
|
||||
*) printf '\033[33mnote:\033[0m %s is not on your PATH. Add:\n export PATH="%s:$PATH"\n' "$bindir" "$bindir" >&2 ;;
|
||||
esac
|
||||
Reference in New Issue
Block a user