Files

36 lines
1.3 KiB
Bash
Raw Permalink Normal View History

#!/usr/bin/env sh
# Builds the talk release artifacts for all target platforms, reproducibly
# with nothing but the Go toolchain (no GoReleaser needed; this way the same
# step runs identically locally, in Gitea Actions and in nix).
#
# Asset contract (agent-lib pattern, the fleet rollout pins to it):
# dist/talk_<os>_<arch>[.exe] static binary, CGO_ENABLED=0
# dist/checksums.txt sha256 per asset (sha256sum format)
#
# Usage: scripts/release.sh [VERSION] (default: git describe, else "dev")
# Env: TARGETS="linux/amd64 ..." overrides the matrix.
set -eu
cd "$(dirname "$0")/.."
VERSION="${1:-$(git describe --tags --always --dirty 2>/dev/null || echo dev)}"
VERSION="${VERSION#v}"
COMMIT="$(git rev-parse --short HEAD 2>/dev/null || echo unknown)"
TARGETS="${TARGETS:-linux/amd64 linux/arm64 darwin/amd64 darwin/arm64 windows/amd64 windows/arm64}"
DIST=dist
rm -rf "$DIST"
mkdir -p "$DIST"
for target in $TARGETS; do
os="${target%/*}"
arch="${target#*/}"
out="$DIST/talk_${os}_${arch}"
[ "$os" = windows ] && out="$out.exe"
echo "build $out"
CGO_ENABLED=0 GOOS="$os" GOARCH="$arch" go build -trimpath \
-ldflags "-s -w -X main.version=$VERSION -X main.commit=$COMMIT" \
-o "$out" ./cmd/talk
done
(cd "$DIST" && sha256sum talk_* > checksums.txt)
echo
echo "Version $VERSION ($COMMIT):"
cat "$DIST/checksums.txt"