From d20903e2605672a34a3003aa0468e38fe97af613 Mon Sep 17 00:00:00 2001 From: Shlomi Noach Date: Sun, 27 May 2018 20:29:09 +0300 Subject: [PATCH] Package builds --- build.sh | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/build.sh b/build.sh index 4f38512..7f44a8a 100755 --- a/build.sh +++ b/build.sh @@ -2,7 +2,7 @@ # # -RELEASE_VERSION=$(cat RELEASE_VERSION) +RELEASE_VERSION= function build { osname=$1 @@ -28,14 +28,26 @@ function build { (cd $buildpath && tar cfz ./gh-ost-binary-${osshort}-${timestamp}.tar.gz $target) } -buildpath=/tmp/gh-ost -target=gh-ost -timestamp=$(date "+%Y%m%d%H%M%S") -ldflags="-X main.AppVersion=${RELEASE_VERSION}" +main() { + if [ -z "${RELEASE_VERSION}" ] ; then + RELEASE_VERSION=$(git describe --abbrev=0 --tags | tr -d 'v') + fi + if [ -z "${RELEASE_VERSION}" ] ; then + RELEASE_VERSION=$(cat RELEASE_VERSION) + fi -mkdir -p ${buildpath} -build macOS osx darwin amd64 -build GNU/Linux linux linux amd64 -echo "Binaries found in:" -ls -1 $buildpath/gh-ost-binary*${timestamp}.tar.gz + buildpath=/tmp/gh-ost + target=gh-ost + timestamp=$(date "+%Y%m%d%H%M%S") + ldflags="-X main.AppVersion=${RELEASE_VERSION}" + + mkdir -p ${buildpath} + build macOS osx darwin amd64 + build GNU/Linux linux linux amd64 + + echo "Binaries found in:" + ls -1 $buildpath/gh-ost-binary*${timestamp}.tar.gz +} + +main "$@"