build: simplify — always build from source, self-hosted deployment
This commit is contained in:
parent
9c03571555
commit
1255fc39ea
2 changed files with 22 additions and 47 deletions
2
VERSION
2
VERSION
|
|
@ -1 +1 @@
|
|||
2026.6.0002
|
||||
2026.6.0003
|
||||
|
|
|
|||
67
install.sh
67
install.sh
|
|
@ -177,57 +177,32 @@ ENVEOF
|
|||
[ "$MODE" = "install" ] && gather_inputs
|
||||
|
||||
# ============================================================
|
||||
# GET BINARY (build from source or download release)
|
||||
# BUILD (always from source — this is a self-hosted deployment)
|
||||
# ============================================================
|
||||
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"
|
||||
header "── Building from Source ──"
|
||||
|
||||
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."
|
||||
if ! command -v go &>/dev/null; then
|
||||
error "Go 1.22+ is required. Run: apt install golang"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
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 "Version: ${VERSION}"
|
||||
info "Running tests..."
|
||||
go test -count=1 ./... 2>&1 | tail -2 || warn "Some tests failed — continuing"
|
||||
|
||||
info "Compiling..."
|
||||
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})"
|
||||
BINARY_TARGET="$REPO_DIR/app/core"
|
||||
|
||||
# ============================================================
|
||||
# INSTALL
|
||||
# ============================================================
|
||||
|
|
|
|||
Loading…
Reference in a new issue