12345678910111213141516171819202122232425262728293031323334353637383940 |
- #!/bin/bash
- PROJECT="$1"
- if [[ -z "$PROJECT" ]]; then
- echo "usage: $0 <package-name>"
- exit 1
- fi
- VERSION="$2"
- if [[ -z "$VERSION" ]]; then
- echo "usage: $0 <version-name>"
- exit 1
- fi
- GOLDFLAGS="$3"
- if [[ -z "$GOLDFLAGS" ]]; then
- GOLDFLAGS='-w -s -extldflags "-static"'
- fi
- PLATFORMS=("darwin/amd64")
- for platform in "${PLATFORMS[@]}"
- do
- platform_split=(${platform//\// })
- GOOS=${platform_split[0]}
- GOARCH=${platform_split[1]}
- output_name='cli-'$VERSION'-'$GOOS'-'$GOARCH
- echo "== Building $output_name"
- echo "== FLAGS: $GOLDFLAGS"
- CGO_ENABLED=1 GOOS=$GOOS GOARCH=$GOARCH go build -a -ldflags="$GOLDFLAGS" -gcflags=all="-l -B" -installsuffix cgo -o bin/$output_name $PROJECT/app
- if [ $? -ne 0 ]; then
- echo 'An error has occurred! Aborting the script execution...'
- exit 1
- fi
- done
- echo "== DONE"
|