From 1b11b210be3cc2b794575bdf51caca7ea23a1edb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ken-H=C3=A5vard=20Lieng?= Date: Wed, 20 Jan 2016 00:32:33 +0100 Subject: [PATCH] Add release script --- .gitignore | 3 ++- release.sh | 42 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 1 deletion(-) create mode 100755 release.sh diff --git a/.gitignore b/.gitignore index d1063d19..814f6e35 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ build +release client/dist client/node_modules -ca-certificates.crt \ No newline at end of file +ca-certificates.crt diff --git a/release.sh b/release.sh new file mode 100755 index 00000000..a3f79760 --- /dev/null +++ b/release.sh @@ -0,0 +1,42 @@ +#!/usr/bin/env bash +set -e +set -o pipefail +shopt -s nullglob + +Package=github.com/khlieng/dispatch +BuildDir=$GOPATH/src/$Package/build +ReleaseDir=$GOPATH/src/$Package/release +BinaryName=dispatch + +mkdir -p $BuildDir +cd $BuildDir +rm -f dispatch* +gox -ldflags -w $Package + +mkdir -p $ReleaseDir +cd $ReleaseDir +rm -f dispatch* +for f in $BuildDir/* +do + zipname=$(basename ${f%".exe"}) + if [[ $f == *"linux"* ]] || [[ $f == *"bsd"* ]]; then + zipname=${zipname}.tar.gz + else + zipname=${zipname}.zip + fi + + binbase=$BinaryName + if [[ $f == *.exe ]]; then + binbase=$binbase.exe + fi + bin=$BuildDir/$binbase + mv $f $bin + + if [[ $zipname == *.zip ]]; then + zip -j $zipname $bin + else + tar -cvzf $zipname -C $BuildDir $binbase + fi + + mv $bin $f +done