|
|
|
@ -26,10 +26,12 @@ _init() { |
|
|
|
|
SUPPORTED_OSARCH='linux/386 linux/amd64 linux/arm windows/386 windows/amd64 darwin/amd64' |
|
|
|
|
|
|
|
|
|
## System binaries |
|
|
|
|
CP="/bin/cp" |
|
|
|
|
SHASUM="/usr/bin/shasum" |
|
|
|
|
GZIP="/usr/bin/gzip" |
|
|
|
|
ZIP="/usr/bin/zip" |
|
|
|
|
CP=`which cp` |
|
|
|
|
SHASUM=`which shasum` |
|
|
|
|
GZIP=`which gzip` |
|
|
|
|
ZIP=`which zip` |
|
|
|
|
SED=`which sed` |
|
|
|
|
TAR=`which tar` |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
go_build() { |
|
|
|
@ -47,25 +49,36 @@ go_build() { |
|
|
|
|
# Release shasum name |
|
|
|
|
release_shasum="$release_str/$os-$arch/$(basename $package).shasum" |
|
|
|
|
# Release zip file. |
|
|
|
|
release_real_zip="$release_str/$os-$arch/$(basename $package).zip" |
|
|
|
|
release_real_gz="$release_str/$os-$arch/$(basename $package).gz" |
|
|
|
|
release_real_zip="$(basename $package).zip" |
|
|
|
|
release_real_tgz="$(basename $package).tgz" |
|
|
|
|
|
|
|
|
|
# Go build to build the binary. |
|
|
|
|
GOOS=$os GOARCH=$arch go build --ldflags "${LDFLAGS}" -o $release_bin |
|
|
|
|
|
|
|
|
|
# Create copy |
|
|
|
|
if [ $os == "windows" ]; then |
|
|
|
|
$CP -p $release_bin ${release_real_bin}.exe |
|
|
|
|
else |
|
|
|
|
$CP -p $release_bin $release_real_bin |
|
|
|
|
fi |
|
|
|
|
|
|
|
|
|
# Calculate shasum |
|
|
|
|
$SHASUM $release_bin > $release_shasum |
|
|
|
|
shasum_str=$(${SHASUM} ${release_bin}) |
|
|
|
|
echo ${shasum_str} | $SED "s/$release_str\/$os-$arch\///g" > $release_shasum |
|
|
|
|
|
|
|
|
|
# Create a compressed file. |
|
|
|
|
if [ $os == "windows" ]; then |
|
|
|
|
$ZIP -r $release_real_zip $release_real_bin |
|
|
|
|
cd "$release_str/$os-$arch" |
|
|
|
|
$ZIP -r $release_real_zip $(basename $package).exe |
|
|
|
|
cd - |
|
|
|
|
elif [ $os == "darwin" ]; then |
|
|
|
|
$ZIP -r $release_real_zip $release_real_bin |
|
|
|
|
cd "$release_str/$os-$arch" |
|
|
|
|
$ZIP -r $release_real_zip $(basename $package) |
|
|
|
|
cd - |
|
|
|
|
elif [ $os == "linux" ]; then |
|
|
|
|
$GZIP -c $release_real_bin > $release_real_gz |
|
|
|
|
cd "$release_str/$os-$arch" |
|
|
|
|
$TAR -czf $release_real_tgz $(basename $package) |
|
|
|
|
cd - |
|
|
|
|
else |
|
|
|
|
echo "$os operating system is not supported." |
|
|
|
|
exit 1 |
|
|
|
|