feat(install): add support for pre-release and custom version installation
Add GORDON_PRERELEASE flag to install latest pre-release: curl -fsSL https://gordon.bnema.dev/install | GORDON_PRERELEASE=1 bash Add GORDON_VERSION flag for specific version: curl -fsSL https://gordon.bnema.dev/install | GORDON_VERSION=v1.2.3 bash Installer now queries GitHub API to find the latest release (including pre-releases) when flags are set, providing more flexibility for testing development builds.
- commit
- 7ff919f5fc4b10c6f3d63d814782e32fc048a5f0
- author
- bnema · · 2026-01-31 22:22 UTC
- parent
- ab1f824
- signature
- unsigned
1 file · +27 -2
M install.sh +27 -2
| @@ -3,9 +3,11 @@ set -e | |||
| 3 | 3 | ||
| 4 | 4 | # Gordon installer script | |
| 5 | 5 | # Usage: curl -fsSL https://gordon.bnema.dev/install | bash | |
| 6 | + | # Usage with pre-release: curl -fsSL https://gordon.bnema.dev/install | GORDON_PRERELEASE=1 bash | |
| 6 | 7 | ||
| 7 | 8 | REPO="bnema/gordon" | |
| 8 | 9 | INSTALL_DIR="/usr/local/bin" | |
| 10 | + | VERSION="${GORDON_VERSION:-latest}" | |
| 9 | 11 | ||
| 10 | 12 | echo "Installing Gordon..." | |
| 11 | 13 | ||
| @@ -43,14 +45,37 @@ echo "Detected: ${OS}/${ARCH}" | |||
| 43 | 45 | ||
| 44 | 46 | # Construct download URL | |
| 45 | 47 | TARBALL="gordon_${OS}_${ARCH}.tar.gz" | |
| 46 | - | DOWNLOAD_URL="https://github.com/${REPO}/releases/latest/download/${TARBALL}" | |
| 48 | + | ||
| 49 | + | # Determine version to download | |
| 50 | + | if [ "$VERSION" = "latest" ] && [ -n "$GORDON_PRERELEASE" ]; then | |
| 51 | + | echo "Finding latest pre-release..." | |
| 52 | + | # Get latest release (including pre-releases) from GitHub API | |
| 53 | + | RELEASE_DATA=$(curl -fsSL "https://api.github.com/repos/${REPO}/releases?per_page=1" 2>/dev/null || echo "") | |
| 54 | + | if [ -z "$RELEASE_DATA" ]; then | |
| 55 | + | echo "Error: Failed to fetch release information from GitHub API" | |
| 56 | + | exit 1 | |
| 57 | + | fi | |
| 58 | + | VERSION=$(echo "$RELEASE_DATA" | grep -m1 '"tag_name"' | sed -E 's/.*"tag_name":\s*"([^"]+)".*/\1/') | |
| 59 | + | if [ -z "$VERSION" ]; then | |
| 60 | + | echo "Error: Could not determine latest pre-release version" | |
| 61 | + | exit 1 | |
| 62 | + | fi | |
| 63 | + | echo "Using pre-release version: ${VERSION}" | |
| 64 | + | elif [ "$VERSION" = "latest" ]; then | |
| 65 | + | VERSION="latest" | |
| 66 | + | echo "Using latest stable release" | |
| 67 | + | else | |
| 68 | + | echo "Using version: ${VERSION}" | |
| 69 | + | fi | |
| 70 | + | ||
| 71 | + | DOWNLOAD_URL="https://github.com/${REPO}/releases/download/${VERSION}/${TARBALL}" | |
| 47 | 72 | ||
| 48 | 73 | # Create temporary directory | |
| 49 | 74 | TMP_DIR=$(mktemp -d) | |
| 50 | 75 | trap 'rm -rf "$TMP_DIR"' EXIT | |
| 51 | 76 | ||
| 52 | 77 | # Download checksums file | |
| 53 | - | CHECKSUMS_URL="https://github.com/${REPO}/releases/latest/download/checksums.txt" | |
| 78 | + | CHECKSUMS_URL="https://github.com/${REPO}/releases/download/${VERSION}/checksums.txt" | |
| 54 | 79 | echo "Downloading checksums..." | |
| 55 | 80 | if ! curl -fsSL "$CHECKSUMS_URL" -o "$TMP_DIR/checksums.txt"; then | |
| 56 | 81 | echo "Error: Failed to download checksums file" | |
| @@ -3,9 +3,11 @@ set -e | |||||
| 3 | 3 | ||||
| 4 | # Gordon installer script | 4 | # Gordon installer script | ||
| 5 | # Usage: curl -fsSL https://gordon.bnema.dev/install | bash | 5 | # Usage: curl -fsSL https://gordon.bnema.dev/install | bash | ||
| 6 | + | # Usage with pre-release: curl -fsSL https://gordon.bnema.dev/install | GORDON_PRERELEASE=1 bash | |||
| 6 | 7 | ||||
| 7 | REPO="bnema/gordon" | 8 | REPO="bnema/gordon" | ||
| 8 | INSTALL_DIR="/usr/local/bin" | 9 | INSTALL_DIR="/usr/local/bin" | ||
| 10 | + | VERSION="${GORDON_VERSION:-latest}" | |||
| 9 | 11 | ||||
| 10 | echo "Installing Gordon..." | 12 | echo "Installing Gordon..." | ||
| 11 | 13 | ||||
| @@ -43,14 +45,37 @@ echo "Detected: ${OS}/${ARCH}" | |||||
| 43 | 45 | ||||
| 44 | # Construct download URL | 46 | # Construct download URL | ||
| 45 | TARBALL="gordon_${OS}_${ARCH}.tar.gz" | 47 | TARBALL="gordon_${OS}_${ARCH}.tar.gz" | ||
| 46 | - | DOWNLOAD_URL="https://github.com/${REPO}/releases/latest/download/${TARBALL}" | 48 | + | |
| 49 | + | # Determine version to download | |||
| 50 | + | if [ "$VERSION" = "latest" ] && [ -n "$GORDON_PRERELEASE" ]; then | |||
| 51 | + | echo "Finding latest pre-release..." | |||
| 52 | + | # Get latest release (including pre-releases) from GitHub API | |||
| 53 | + | RELEASE_DATA=$(curl -fsSL "https://api.github.com/repos/${REPO}/releases?per_page=1" 2>/dev/null || echo "") | |||
| 54 | + | if [ -z "$RELEASE_DATA" ]; then | |||
| 55 | + | echo "Error: Failed to fetch release information from GitHub API" | |||
| 56 | + | exit 1 | |||
| 57 | + | fi | |||
| 58 | + | VERSION=$(echo "$RELEASE_DATA" | grep -m1 '"tag_name"' | sed -E 's/.*"tag_name":\s*"([^"]+)".*/\1/') | |||
| 59 | + | if [ -z "$VERSION" ]; then | |||
| 60 | + | echo "Error: Could not determine latest pre-release version" | |||
| 61 | + | exit 1 | |||
| 62 | + | fi | |||
| 63 | + | echo "Using pre-release version: ${VERSION}" | |||
| 64 | + | elif [ "$VERSION" = "latest" ]; then | |||
| 65 | + | VERSION="latest" | |||
| 66 | + | echo "Using latest stable release" | |||
| 67 | + | else | |||
| 68 | + | echo "Using version: ${VERSION}" | |||
| 69 | + | fi | |||
| 70 | + | ||||
| 71 | + | DOWNLOAD_URL="https://github.com/${REPO}/releases/download/${VERSION}/${TARBALL}" | |||
| 47 | 72 | ||||
| 48 | # Create temporary directory | 73 | # Create temporary directory | ||
| 49 | TMP_DIR=$(mktemp -d) | 74 | TMP_DIR=$(mktemp -d) | ||
| 50 | trap 'rm -rf "$TMP_DIR"' EXIT | 75 | trap 'rm -rf "$TMP_DIR"' EXIT | ||
| 51 | 76 | ||||
| 52 | # Download checksums file | 77 | # Download checksums file | ||
| 53 | - | CHECKSUMS_URL="https://github.com/${REPO}/releases/latest/download/checksums.txt" | 78 | + | CHECKSUMS_URL="https://github.com/${REPO}/releases/download/${VERSION}/checksums.txt" |
| 54 | echo "Downloading checksums..." | 79 | echo "Downloading checksums..." | ||
| 55 | if ! curl -fsSL "$CHECKSUMS_URL" -o "$TMP_DIR/checksums.txt"; then | 80 | if ! curl -fsSL "$CHECKSUMS_URL" -o "$TMP_DIR/checksums.txt"; then | ||
| 56 | echo "Error: Failed to download checksums file" | 81 | echo "Error: Failed to download checksums file" | ||