-
Notifications
You must be signed in to change notification settings - Fork 49
Add install.sh for easy installation and recommend in README.md #384
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -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(.*)(?=")') | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bug: A portable alternative:
Suggested change
Or using |
||||||
| 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" | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The script downloads and extracts into the user's current working directory. This can pollute the CWD with the zip and extracted binary, and will fail if the CWD is read-only. Consider using a temp directory: TMP=$(mktemp -d)
trap 'rm -rf "$TMP"' EXIT
curl -sSfL "$URL" -o "$TMP/$ASSET"
unzip -o "$TMP/$ASSET" -d "$TMP"
chmod +x "$TMP/$BIN"
sudo mv "$TMP/$BIN" /usr/local/bin/Also, |
||||||
|
|
||||||
| 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}" | ||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug:
VERSION=1.2.3 curl ... | bashsetsVERSIONas an environment variable only for thecurlprocess, not for thebashprocess on the right side of the pipe. The script will never seeVERSION.Should be:
Or: