From 9c035715552afb56fe58e5a16f76b9311305ae90 Mon Sep 17 00:00:00 2001 From: cclohmar Date: Sun, 14 Jun 2026 15:34:27 +0000 Subject: [PATCH] build: installer supports download of pre-built binary, no Go required for end users --- VERSION | 2 +- install.sh | 67 ++++++++++++++++++++++++++++++++++++++---------------- 2 files changed, 48 insertions(+), 21 deletions(-) diff --git a/VERSION b/VERSION index 76447f6..cbe2641 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2026.6.0001 +2026.6.0002 diff --git a/install.sh b/install.sh index 2ce3ed9..15dc198 100755 --- a/install.sh +++ b/install.sh @@ -177,30 +177,57 @@ ENVEOF [ "$MODE" = "install" ] && gather_inputs # ============================================================ -# BUILD +# GET BINARY (build from source or download release) # ============================================================ -header "── Building ──" -if ! command -v go &>/dev/null; then - error "Go 1.22+ required" +header "── Getting Binary ──" +VERSION=$(cat "$REPO_DIR/VERSION" 2>/dev/null || echo "dev") +RELEASE_URL="https://git.lohmar.co.uk/lexton-it/NextWks/releases/download/v${VERSION}" +BINARY_TARGET="$REPO_DIR/app/core" + +if command -v go &>/dev/null; then + # --- Dev mode: compile from source --- + info "Go detected — building from source" + + cd "$REPO_DIR/src" + BUILD_TIME=$(date -u +"%Y-%m-%dT%H:%M:%SZ") + COMMIT_SHA=$(git rev-parse --short HEAD 2>/dev/null || echo "unknown") + + info "Running tests..." + go test -count=1 ./... 2>&1 | tail -2 || warn "Some tests failed — continuing" + + info "Compiling (${VERSION})..." + go build -ldflags="-s -w \ + -X git.lohmar.co.uk/lexton-it/NextWks/core/version.Version=${VERSION} \ + -X git.lohmar.co.uk/lexton-it/NextWks/core/version.BuildTime=${BUILD_TIME} \ + -X git.lohmar.co.uk/lexton-it/NextWks/core/version.CommitSHA=${COMMIT_SHA}" \ + -o "$BINARY_TARGET" . + success "Built: app/core (${VERSION})" + +elif command -v wget &>/dev/null || command -v curl &>/dev/null; then + # --- User mode: download pre-built binary --- + info "No Go — downloading pre-built binary" + info "Release: ${RELEASE_URL}/core" + + if command -v curl &>/dev/null; then + HTTP_CODE=$(curl -sL --max-time 30 -w "%{http_code}" -o "$BINARY_TARGET" "${RELEASE_URL}/core") + else + HTTP_CODE=$(wget -q --timeout=30 -O "$BINARY_TARGET" "${RELEASE_URL}/core" 2>&1; echo $?) + fi + + if [ "${HTTP_CODE:-0}" = "200" ] || [ -s "$BINARY_TARGET" ]; then + chmod +x "$BINARY_TARGET" 2>/dev/null || true + success "Downloaded: ${VERSION}" + else + rm -f "$BINARY_TARGET" + error "Binary not found at ${RELEASE_URL}/core" + error "Build from source: clone repo and run with Go installed" + exit 1 + fi +else + error "Need Go (to build) or wget/curl (to download). Install one." exit 1 fi -cd "$REPO_DIR/src" -VERSION=$(cat "$REPO_DIR/VERSION" 2>/dev/null || echo "dev") -BUILD_TIME=$(date -u +"%Y-%m-%dT%H:%M:%SZ") -COMMIT_SHA=$(git rev-parse --short HEAD 2>/dev/null || echo "unknown") - -info "Running tests..." -go test -count=1 ./... 2>&1 | tail -2 || warn "Some tests failed — continuing" - -info "Compiling (${VERSION})..." -go build -ldflags="-s -w \ - -X git.lohmar.co.uk/lexton-it/NextWks/core/version.Version=${VERSION} \ - -X git.lohmar.co.uk/lexton-it/NextWks/core/version.BuildTime=${BUILD_TIME} \ - -X git.lohmar.co.uk/lexton-it/NextWks/core/version.CommitSHA=${COMMIT_SHA}" \ - -o "$REPO_DIR/app/core" . -success "Binary built: app/core (${VERSION})" - # ============================================================ # INSTALL # ============================================================