diff --git a/.gitea/workflows/build.yml b/.gitea/workflows/build.yml index d24c126..877e6a7 100644 --- a/.gitea/workflows/build.yml +++ b/.gitea/workflows/build.yml @@ -63,7 +63,7 @@ jobs: # --- newest upstream semver tag (3 attempts x 120s cap: github hiccups) --- VER="" for i in 1 2 3; do - VER="$(GIT_TERMINAL_PROMPT=0 timeout 120 git ls-remote --tags "$UP" 2>/dev/null \ + VER="$(GIT_TERMINAL_PROMPT=0 timeout 180 git ls-remote --tags "$UP" 2>/dev/null \ | awk '{print $2}' | grep -oE 'v[0-9]+\.[0-9]+\.[0-9]+' | sort -uV | tail -1 || true)" [ -n "$VER" ] && break echo "upstream tag scan attempt $i failed; retrying in 60s" @@ -79,7 +79,7 @@ jobs: # --- idempotency: already published here? (2 attempts: gitea stalls observed) --- PUBLISHED="" for i in 1 2; do - PUBLISHED="$(authgit 90 ls-remote --tags "$API/$REPO.git" 2>/dev/null \ + PUBLISHED="$(authgit 120 ls-remote --tags "$API/$REPO.git" 2>/dev/null \ | grep -E "refs/tags/${VER}\$" || true)" [ -n "$PUBLISHED" ] && break echo "gitea tag check attempt $i inconclusive; retrying in 45s" @@ -91,7 +91,7 @@ jobs: exit 0 fi # a second inconclusive gitea check is NOT proof of absence: fail loudly - if ! authgit 90 ls-remote --tags "$API/$REPO.git" >/dev/null 2>&1; then + if ! authgit 120 ls-remote --tags "$API/$REPO.git" >/dev/null 2>&1; then echo "could not verify existing tags after retries; refusing to rebuild (gitea unreachable/stalled)" echo "failed" > /tmp/agentbuilds-status exit 1 @@ -102,16 +102,30 @@ jobs: GIT_TERMINAL_PROMPT=0 timeout 300 git clone --quiet --depth 1 --branch "$VER" "$UP" "$W/src" ( cd "$W/src" - for t in linux/amd64 linux/arm64 linux/arm linux/386 \ - darwin/amd64 darwin/arm64 windows/amd64 windows/386; do - GOOS="${t%%/*}"; GOARCH="${t##*/}" + b() { + t="$1"; GOOS="${t%%/*}"; GOARCH="${t##*/}" EXE=""; [ "$GOOS" = "windows" ] && EXE=".exe" echo "=== go build $GOOS/$GOARCH ===" CGO_ENABLED=0 GOOS="$GOOS" GOARCH="$GOARCH" \ timeout 900 go build -ldflags "-s -w" \ - -o "$W/dist/tacticalagent-$VER-$GOOS-$GOARCH$EXE" . - done + -o "$W/dist/tacticalagent-$VER-$GOOS-$GOARCH$EXE" . || { + echo "BUILD FAILED $GOOS/$GOARCH" >&2; exit 1; } + } + # 4 waves of 2 (proven pattern; much faster than serial on the runner) + ( b linux/amd64; b linux/arm64 ) & + ( b linux/arm; b linux/386 ) & + wait + ( b darwin/amd64; b darwin/arm64 ) & + ( b windows/amd64; b windows/386 ) & + wait ) + # hard guard: all 8 targets must exist before publish (POSIX sh `wait` + # does not propagate child failures, so verify the artifacts) + n="$(ls "$W/dist" | grep -c '^tacticalagent-' || true)" + if [ "$n" != "8" ]; then + echo "expected 8 built binaries, found $n" >&2 + exit 1 + fi ( cd "$W/dist" && sha256sum tacticalagent-* > SHA256SUMS ) # --- publish into this repo (public; agents fetch the raw URLs) --- @@ -142,7 +156,7 @@ jobs: # busybox curl has no -w: use -f (exit 22 on HTTP >=400) as the pass/fail signal for f in "$W/dist"/tacticalagent-*; do n="$(basename "$f")" - if curl -sf -m 30 -o /dev/null "$API/$REPO/raw/branch/$VER/dist/$VER/$n"; then + if curl -sf -m 60 -o /dev/null "$API/$REPO/raw/branch/$VER/dist/$VER/$n"; then echo "raw 200: $n" else rc=$? @@ -162,7 +176,7 @@ jobs: curl -s -m 5 "http://10.2.1.10/izebra" \ -H "X-Title: agent-builds: $VER published" \ -H 'X-Priority: 3' -H 'X-Tag: rocket' \ - --data "Published TacticalRMM agent $VER (8 targets) to git.izebra.net/izebra_projects/agent-builds. RMM2 LATEST_AGENT_VER is 2.12.0; bump it to $VER when the rollout is ready." || true + --data "Published TacticalRMM agent $VER (8 targets) to git.izebra.net/izebra_projects/agent-builds. RMM2's LATEST_AGENT_VER gate (tacticalrmm settings) controls rollout; bump it to $VER when ready." || true fi - name: Alert