gh-ost/build.sh

42 lines
881 B
Bash
Raw Normal View History

2016-03-23 11:39:24 +00:00
#!/bin/bash
#
#
2016-08-12 11:04:17 +00:00
2016-10-27 11:53:51 +00:00
RELEASE_VERSION=$(cat RELEASE_VERSION)
2016-03-23 11:39:24 +00:00
2016-08-12 11:04:17 +00:00
function build {
osname=$1
osshort=$2
GOOS=$3
GOARCH=$4
2018-05-07 09:34:42 +00:00
if ! go version | egrep -q 'go(1[.]9|1[.]1[0-9])' ; then
2017-11-23 10:13:25 +00:00
echo "go version is too low. Must use 1.9 or above"
exit 1
fi
2016-08-12 11:04:17 +00:00
echo "Building ${osname} binary"
export GOOS
export GOARCH
go build -ldflags "$ldflags" -o $buildpath/$target go/cmd/gh-ost/main.go
if [ $? -ne 0 ]; then
echo "Build failed for ${osname}"
exit 1
fi
(cd $buildpath && tar cfz ./gh-ost-binary-${osshort}-${timestamp}.tar.gz $target)
}
2016-05-16 09:09:17 +00:00
buildpath=/tmp/gh-ost
target=gh-ost
2016-03-23 11:39:24 +00:00
timestamp=$(date "+%Y%m%d%H%M%S")
2016-05-17 09:51:21 +00:00
ldflags="-X main.AppVersion=${RELEASE_VERSION}"
2016-03-23 11:39:24 +00:00
2016-08-12 11:04:17 +00:00
mkdir -p ${buildpath}
build macOS osx darwin amd64
build GNU/Linux linux linux amd64
2016-03-23 11:39:24 +00:00
echo "Binaries found in:"
2016-05-16 09:09:17 +00:00
ls -1 $buildpath/gh-ost-binary*${timestamp}.tar.gz