12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- #/bin/bash
- set -euo pipefail
- NAME=watchlogs
- function build() {
- local -r name=${1:-main}
- export GOOS=$2
- export GOARCH=$3
- local artifact=$name-$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 -u -Iseconds)"
- shasum -a 256 ./$artifact > $artifact.sha256sum
- }
- function main() {
- local -r name=watchlogs
- local -r targets="linux amd64
- linux arm64
- darwin amd64
- darwin arm64
- windows amd64"
- local -a target
- while read line
- do
- read -a target <<< $line
- echo "Building ${target[@]}..." >&2
- build $NAME ${target[0]} ${target[1]}
- done < <(echo "$targets")
- }
- main $@
|