local cross-build with accurate version metadata

This commit is contained in:
Kenneth Bingham 2025-05-06 14:43:09 -04:00
parent d2c92651ef
commit 97ca59a750
No known key found for this signature in database
GPG Key ID: 31709281860130B6

View File

@ -40,11 +40,26 @@ fi
done done
) )
for ARCH in "${JOBS[@]}"; do # Get version information
goreleaser build \ VERSION=$(git describe --tags --abbrev=0 2>/dev/null || echo "v1.0.x")
--clean \ STEPS=$(git rev-list --count ${VERSION}..HEAD 2>/dev/null || echo "0")
--snapshot \ if [ "$STEPS" -gt "0" ]; then
--output "./dist/" \ VERSION="${VERSION}-${STEPS}"
--config "./.goreleaser-linux-$(resolveArch "${ARCH}").yml" fi
done
# Check if working copy is dirty
if [ -z "$(git status --porcelain)" ]; then
# Clean working directory
HASH=$(git rev-parse --short HEAD)
else
# Dirty working directory
HASH="developer build"
fi
for ARCH in "${JOBS[@]}"; do
LDFLAGS="-s -w -X 'github.com/openziti/zrok/build.Version=${VERSION}' -X 'github.com/openziti/zrok/build.Hash=${HASH}'"
GOOS=linux GOARCH=$(resolveArch "${ARCH}") \
go build -o "./dist/$(resolveArch "${ARCH}")/linux/zrok" \
-ldflags "${LDFLAGS}" \
./cmd/zrok
done