#/bin/bash set -euo pipefail function build() { export GOOS=$1 export GOARCH=$2 local artifact=dump2sql-$GOOS-$GOARCH if [ $GOOS == windows ] then artifact=$artifact.exe fi go build \ -o $artifact \ -buildmode pie \ -ldflags "\ -w -s \ -X main.Version=$(git describe --tags | head -1) \ -X main.Build=$(date --utc --iso-8601=s)" sha256sum ./$artifact > $artifact.sha256sum } function main() { local -r targets="linux amd64 linux arm64 darwin amd64 darwin arm64 windows amd64" local -a target while read line do read -a target <<< $line build ${target[0]} ${target[1]} done < <(echo "$targets") } main $@