* fix(ai): atomically claim cron tasks and isolate job status snapshots * test(ai): verify independent job snapshots, retention and atomic cron claim * fix(build): detect obsolete untracked Go files before compilation * chore(release): mark Landwelle v1.5.74 * chore(release): mark Landwelle v1.5.74 * docs: document v1.5.74 fixes and deferred architecture * docs: add operational release notes for v1.5.74 * ci: prove stale local Go files are rejected before ARM build * fix(build): restore script and correct untracked-source guard * fix(build): use correctly escaped Go-source pattern
51 lines
3.0 KiB
Bash
Executable File
51 lines
3.0 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
mkdir -p "$ROOT_DIR/dist"
|
|
cd "$ROOT_DIR"
|
|
|
|
# Go compiles all .go files in the package directory, including untracked files.
|
|
# A stale local source (e.g. destination_one.go) can break an otherwise green CI.
|
|
# Refuse to build instead of silently deleting potentially valuable local work.
|
|
if git rev-parse --is-inside-work-tree >/dev/null 2>&1; then
|
|
EXTRA_GO="$(git ls-files --others --exclude-standard -- '*.go' | grep -E '^[^/]+\.go$' || true)"
|
|
if [[ -n "$EXTRA_GO" ]]; then
|
|
printf 'Build abgebrochen: nicht versionierte Go-Dateien im Projektverzeichnis:\n%s\n' "$EXTRA_GO" >&2
|
|
echo "Bitte Dateien sichern und aus dem Projektverzeichnis verschieben, bevor du neu baust." >&2
|
|
exit 1
|
|
fi
|
|
fi
|
|
|
|
# Startkritische ServeMux-Routen vor dem Build statisch prüfen.
|
|
# contentPages() registriert seine Slugs später dynamisch als "/"+slug. Deshalb
|
|
# reicht ein grep nach wörtlichen HandleFunc-Aufrufen nicht aus: Ein Slug darf
|
|
# nicht gleichzeitig explizit in main.go registriert sein.
|
|
EXPLICIT_PUBLIC_ROUTES="$(grep -oE 'mux\.HandleFunc\("/[^"]+"' main.go | sed -E 's/.*HandleFunc\("([^"]+)"/\1/' | sort -u)"
|
|
CONTENT_PAGE_SLUGS="$(sed -n '/^func contentPages()/,/^}/p' content.go | sed -nE 's/^[[:space:]]*"([^"]+)"[[:space:]]*:.*/\1/p')"
|
|
while IFS= read -r slug; do
|
|
[[ -z "$slug" ]] && continue
|
|
if grep -Fxq "/$slug" <<<"$EXPLICIT_PUBLIC_ROUTES"; then
|
|
printf 'Build abgebrochen: Route /%s wird sowohl explizit als auch dynamisch über contentPages() registriert.\n' "$slug" >&2
|
|
exit 1
|
|
fi
|
|
done <<<"$CONTENT_PAGE_SLUGS"
|
|
|
|
# Alte Build-Artefakte vor einem neuen Build entfernen. So kann ein fehlgeschlagener
|
|
# Build niemals versehentlich ein altes Portal-Binary für das Update stehen lassen.
|
|
rm -f "$ROOT_DIR/dist/landwelle-portal-linux-arm64" "$ROOT_DIR/dist/landwelle-adminpass-linux-arm64"
|
|
go mod download
|
|
go mod verify
|
|
COMMIT="$(git rev-parse --short=12 HEAD 2>/dev/null || printf unknown)"
|
|
BUILD_TIME="$(date -u +%Y-%m-%dT%H:%M:%SZ)"
|
|
LDFLAGS="-s -w -X main.buildCommit=$COMMIT -X main.buildTime=$BUILD_TIME"
|
|
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -trimpath -ldflags="$LDFLAGS" -o dist/landwelle-portal-linux-arm64 .
|
|
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -trimpath -ldflags="-s -w" -o dist/landwelle-adminpass-linux-arm64 ./cmd/adminpass
|
|
SOURCE_VERSION="$(sed -nE 's/^[[:space:]]*applicationVersion[[:space:]]*=[[:space:]]*"([^"]+)".*/\1/p' main.go | head -n1)"
|
|
BUILT_VERSION="$("$ROOT_DIR/dist/landwelle-portal-linux-arm64" --version 2>/dev/null || true)"
|
|
if [[ -z "$SOURCE_VERSION" || "$BUILT_VERSION" != "Landwelle v$SOURCE_VERSION" ]]; then
|
|
printf 'Build abgebrochen: Binary-Version passt nicht zum Quellstand (Quelle: %s, Binary: %s).\n' "${SOURCE_VERSION:-unbekannt}" "${BUILT_VERSION:-unbekannt}" >&2
|
|
rm -f "$ROOT_DIR/dist/landwelle-portal-linux-arm64"
|
|
exit 1
|
|
fi
|
|
printf '%s\n' "ARM64-Portal erstellt: $ROOT_DIR/dist/landwelle-portal-linux-arm64" "Version: $BUILT_VERSION" "Commit: $COMMIT" "Build-Zeit: $BUILD_TIME"
|