diff --git a/README.md b/README.md index 494ac333..5b8054e4 100644 --- a/README.md +++ b/README.md @@ -12,29 +12,41 @@ Recipes (e.g. `l1`, `opstack`) assemble opinionated components and pre-baked con - Running repeatable CI and e2e scenarios - Experimenting with fork configurations and client combinations -Quick start: +## Installation + +### Install with script (recommended) + +On Linux and macOS, you can install the latest version to `/usr/local/bin` with: ```bash -# L1 environment with mev-boost relay -builder-playground start l1 +curl -sSfL https://raw.githubusercontent.com/flashbots/builder-playground/main/install.sh | bash +``` -# L2 OpStack with external builder support -builder-playground start opstack --external-builder http://localhost:4444 +If you need to install a specific version, you can use the `VERSION` env var in the beginning like: +```bash +VERSION=1.2.3 curl -sSfL https://raw.githubusercontent.com/flashbots/builder-playground/main/install.sh | bash ``` -## Installation +### Install from repository -``` -$ go install github.com/flashbots/builder-playground@latest +Extend the `PATH` variable with `GOPATH/bin` (or `GOBIN` if set), then clone the repository and do: +```bash +go install . ``` -or clone the repository and do: +--- -``` -$ go install . -``` +These commands install to different directories as mentioned above so make sure to verify with `which $(builder-playground)` to avoid confusion! -or do `go build .` and run from the repository like `./builder-playground`. +## Quick Examples + +```bash +# L1 environment with mev-boost relay +builder-playground start l1 + +# L2 OpStack with external builder support +builder-playground start opstack --external-builder http://localhost:4444 +``` ## CI / GitHub Actions diff --git a/install.sh b/install.sh new file mode 100755 index 00000000..dc7a39e1 --- /dev/null +++ b/install.sh @@ -0,0 +1,54 @@ +#!/usr/bin/env bash +set -euo pipefail + +REPO="flashbots/builder-playground" +BIN="builder-playground" +API="https://api.github.com/repos/${REPO}/releases/latest" + +# Detect OS +OS="$(uname | tr '[:upper:]' '[:lower:]')" +case "$OS" in + linux|darwin) ;; + *) echo "Unsupported OS: $OS"; exit 1 ;; +esac + +# Detect ARCH +ARCH="$(uname -m)" +case "$ARCH" in + x86_64) ARCH="amd64" ;; + arm64|aarch64) ARCH="arm64" ;; + *) echo "Unsupported architecture: $ARCH"; exit 1 ;; +esac + +if [ -n "${VERSION:-}" ]; then + # Normalize: ensure tag has a "v" prefix + TAG="${VERSION#v}" + TAG="v${TAG}" + echo "Checking version: $TAG" + if ! curl -sSfL "https://api.github.com/repos/${REPO}/releases/tags/${TAG}" > /dev/null 2>&1; then + echo "Error: version '${TAG}' not found. Check available releases at https://github.com/${REPO}/releases" + exit 1 + fi +else + echo "Fetching latest release..." + TAG=$(curl -sSfL "$API" | grep -oP '"tag_name": "\K(.*)(?=")') + echo "Latest version: $TAG" +fi + +ASSET="${BIN}_${TAG}_${OS}_${ARCH}.zip" +URL="https://github.com/${REPO}/releases/download/${TAG}/${ASSET}" + +echo "Downloading $ASSET..." +curl -sSfL "$URL" -o "$ASSET" + +echo "Extracting..." +unzip -o "$ASSET" + +echo "Installing to /usr/local/bin..." +chmod +x "$BIN" +sudo mv "$BIN" /usr/local/bin/ + +echo "Cleaning up..." +rm -f "$ASSET" + +echo "✅ Installed $BIN $TAG for ${OS}-${ARCH}"