1#!/usr/bin/env sh
 2
 3# SPDX-FileCopyrightText: Amolith <amolith@secluded.site>
 4#
 5# SPDX-License-Identifier: CC0-1.0
 6
 7export CGO_ENABLED=0
 8
 9if ! git describe --tags --exact-match HEAD; then
10    echo "Not a tagged commit, refusing to build for all platforms."
11    exit 0
12fi
13
14TAG=$(git describe --tags --exact-match HEAD)
15NAME=$(basename "$(pwd)")
16
17mkdir -p "out/$TAG"
18
19while read -r LOOP_OS LOOP_ARCH; do
20    echo "Building $NAME-$LOOP_OS-$LOOP_ARCH"
21    GOOS="$LOOP_OS" GOARCH="$LOOP_ARCH" go build -ldflags="-s -w" -o "out/$TAG/$NAME-$LOOP_OS-$LOOP_ARCH" ./cmd
22done <<EOF
23darwin amd64
24freebsd 386
25freebsd amd64
26freebsd arm
27freebsd arm64
28linux 386
29linux amd64
30linux arm
31linux arm64
32linux ppc64le
33linux riscv64
34netbsd amd64
35openbsd amd64
36openbsd arm64
37windows amd64
38EOF