1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- #/bin/bash
- set -euo pipefail
- function build() {
- export GOOS=$1
- export GOARCH=$2
- export CGO_ENABLED=1
- local artifact=dump2sql-$GOOS-$GOARCH
- if [ $GOOS == windows ]
- then artifact=$artifact.exe
- fi
- echo "Building $artifact..."
- go build \
- -o $artifact \
- -buildmode pie \
- -ldflags "\
- -w -s \
- -X main.Version=$(git describe --tags | head -1) \
- -X main.Build=$(date -u --iso-8601=seconds)"
- 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 $@
|