Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
116 changes: 116 additions & 0 deletions curl.sh
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions website/docs/cli/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand Down
18 changes: 18 additions & 0 deletions website/docs/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
15 changes: 15 additions & 0 deletions website/src/pages/index.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
3 changes: 3 additions & 0 deletions website/src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ function HomepageHeader() {
Get Started
</Link>
</div>
<div className={styles.quickInstall}>
<code>curl -fsSL https://raw.githubusercontent.com/devbytes-cloud/freight/main/curl.sh | bash</code>
</div>
</div>
</header>
);
Expand Down