Add release script

This commit is contained in:
Ken-Håvard Lieng 2016-01-20 00:32:33 +01:00
parent 4cfdce2db7
commit 1b11b210be
2 changed files with 44 additions and 1 deletions

3
.gitignore vendored
View File

@ -1,4 +1,5 @@
build build
release
client/dist client/dist
client/node_modules client/node_modules
ca-certificates.crt ca-certificates.crt

42
release.sh Executable file
View File

@ -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