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