diff --git a/README.md b/README.md index 440c440..804742e 100644 --- a/README.md +++ b/README.md @@ -43,6 +43,8 @@ Freight's 'Conductor/Railcar' architecture ensures that your hooks work identica ### 1. Install - **Homebrew (macOS):** `brew install --cask devbytes-cloud/tap/freight` +- **One-liner Install (Linux/macOS):** `curl -fsSL https://raw.githubusercontent.com/devbytes-cloud/freight/main/curl.sh | bash` + - *Custom `INSTALL_DIR` (optional):* `INSTALL_DIR=~/.local/bin curl -fsSL ... | bash` - **Precompiled Binaries:** [GitHub Releases](https://github.com/devbytes-cloud/freight/releases) ### 2. Setup diff --git a/curl.sh b/curl.sh new file mode 100644 index 0000000..f112abf --- /dev/null +++ b/curl.sh @@ -0,0 +1,116 @@ + +#!/bin/bash +# +# Freight Installer +# Usage: curl -fsSL https://raw.githubusercontent.com/devbytes-cloud/freight/main/curl.sh | bash +# + +set -e + +# Configuration +REPO="devbytes-cloud/freight" +BINARY_NAME="freight" +INSTALL_DIR="${INSTALL_DIR:-/usr/local/bin}" + +# Colors for output +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[1;33m' +NC='\033[0m' # No Color + +info() { + printf "${GREEN}[INFO]${NC} %s\n" "$1" +} + +warn() { + printf "${YELLOW}[WARN]${NC} %s\n" "$1" +} + +error() { + printf "${RED}[ERROR]${NC} %s\n" "$1" + exit 1 +} + +# Detect OS +detect_os() { + case "$(uname -s)" in + Linux*) OS="Linux";; + Darwin*) OS="Darwin";; + MINGW*|MSYS*|CYGWIN*) OS="Windows";; + *) error "Unsupported operating system: $(uname -s)";; + esac +} + +# Detect architecture +detect_arch() { + case "$(uname -m)" in + x86_64|amd64) ARCH="x86_64";; + arm64|aarch64) ARCH="arm64";; + armv6l|armv7l) ARCH="armv6";; + *) error "Unsupported architecture: $(uname -m)";; + esac +} + +# Get latest version from GitHub releases +get_latest_version() { + VERSION=$(curl -fsSL "https://api.github.com/repos/${REPO}/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/') + if [ -z "$VERSION" ]; then + error "Failed to fetch latest version. Check if releases exist at https://github.com/${REPO}/releases" + fi +} + +# Download and install +install() { + detect_os + detect_arch + get_latest_version + + info "Detected: OS=$OS, ARCH=$ARCH" + info "Installing ${BINARY_NAME} ${VERSION}..." + + # Build download URL + ARCHIVE_NAME="freight_${OS}_${ARCH}.tar.gz" + DOWNLOAD_URL="https://github.com/${REPO}/releases/download/${VERSION}/${ARCHIVE_NAME}" + + # Create temp directory + TMP_DIR=$(mktemp -d) + trap "rm -rf ${TMP_DIR}" EXIT + + info "Downloading from ${DOWNLOAD_URL}..." + curl -fsSL "${DOWNLOAD_URL}" -o "${TMP_DIR}/${ARCHIVE_NAME}" || error "Download failed. Archive may not exist for your platform." + + # Extract archive + info "Extracting..." + tar -xzf "${TMP_DIR}/${ARCHIVE_NAME}" -C "${TMP_DIR}" + + # Set binary extension for Windows + EXT="" + if [ "$OS" = "Windows" ]; then + EXT=".exe" + fi + + # Install binary + BINARY_PATH="${TMP_DIR}/${BINARY_NAME}${EXT}" + if [ ! -f "$BINARY_PATH" ]; then + error "Binary not found in archive" + fi + + info "Installing to ${INSTALL_DIR}/${BINARY_NAME}${EXT}..." + + # Check if we need sudo + if [ -w "$INSTALL_DIR" ]; then + mv "$BINARY_PATH" "${INSTALL_DIR}/${BINARY_NAME}${EXT}" + chmod +x "${INSTALL_DIR}/${BINARY_NAME}${EXT}" + else + warn "Elevated permissions required for ${INSTALL_DIR}" + sudo mv "$BINARY_PATH" "${INSTALL_DIR}/${BINARY_NAME}${EXT}" + sudo chmod +x "${INSTALL_DIR}/${BINARY_NAME}${EXT}" + fi + + echo "" + info "✔ Successfully installed ${BINARY_NAME} ${VERSION}" + info "Run '${BINARY_NAME} --help' to get started" +} + +# Run installation +install \ No newline at end of file diff --git a/website/docs/cli/index.md b/website/docs/cli/index.md index 1635643..7fb9234 100644 --- a/website/docs/cli/index.md +++ b/website/docs/cli/index.md @@ -2,6 +2,8 @@ Brief overview of the Freight CLI. Freight is a blazing-fast Git hooks manager designed for speed and simplicity. +For installation instructions, see the [Installation Guide](../installation.md). + ## Available Commands | Command | Description | diff --git a/website/docs/installation.md b/website/docs/installation.md index 09d3094..94237fc 100644 --- a/website/docs/installation.md +++ b/website/docs/installation.md @@ -14,6 +14,24 @@ Install Freight as a Cask: brew install --cask devbytes-cloud/tap/freight ``` +#### One-liner Install (Linux/macOS/WSL) +Install Freight directly with a single command: +```bash +curl -fsSL https://raw.githubusercontent.com/devbytes-cloud/freight/main/curl.sh | bash +``` + +**Custom Install Directory:** By default, Freight installs to `/usr/local/bin`. You can customize this: +```bash +INSTALL_DIR=~/.local/bin curl -fsSL https://raw.githubusercontent.com/devbytes-cloud/freight/main/curl.sh | bash +``` + +The installer script: +- Auto-detects OS (Linux, macOS, Windows/MSYS) +- Auto-detects architecture (x86_64, arm64, armv6) +- Downloads the latest release from GitHub +- Installs to the specified directory (default: `/usr/local/bin`) +- May require `sudo` for system directories + #### GitHub Releases You can also download the pre-compiled binaries directly from the [GitHub Releases](https://github.com/devbytes-cloud/freight/releases) page. diff --git a/website/src/pages/index.module.css b/website/src/pages/index.module.css index 048be31..2fd2b17 100644 --- a/website/src/pages/index.module.css +++ b/website/src/pages/index.module.css @@ -72,3 +72,18 @@ align-items: center; justify-content: center; } + +.quickInstall { + margin-top: 2rem; + display: flex; + justify-content: center; +} + +.quickInstall code { + background-color: var(--ifm-code-background); + padding: 0.75rem 1.5rem; + border-radius: 8px; + font-size: 0.9rem; + border: 1px solid var(--ifm-color-emphasis-200); + color: var(--ifm-color-primary); +} diff --git a/website/src/pages/index.tsx b/website/src/pages/index.tsx index ddc3499..bd5f9ab 100644 --- a/website/src/pages/index.tsx +++ b/website/src/pages/index.tsx @@ -29,6 +29,9 @@ function HomepageHeader() { Get Started +
+ curl -fsSL https://raw.githubusercontent.com/devbytes-cloud/freight/main/curl.sh | bash +
);