36 lines
1.3 KiB
Bash
36 lines
1.3 KiB
Bash
#!/usr/bin/env sh
|
|||
|
|
# Baut die Release-Artefakte von talk für alle Zielplattformen — reproduzierbar
|
||
|
|
# mit nichts als dem Go-Toolchain (kein GoReleaser nötig; so läuft derselbe
|
||
|
|
# Schritt lokal, in Gitea Actions und in nix identisch).
|
||
|
|
#
|
||
|
|
# Asset-Vertrag (agent-lib-Muster, Fleet-Rollout pinnt darauf):
|
||
|
|
# dist/talk_<os>_<arch>[.exe] statisches Binary, CGO_ENABLED=0
|
||
|
|
# dist/checksums.txt sha256 je Asset (sha256sum-Format)
|
||
|
|
#
|
||
|
|
# Aufruf: scripts/release.sh [VERSION] (Default: git describe, sonst "dev")
|
||
|
|
# Env: TARGETS="linux/amd64 …" überschreibt die 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"
|