From 7a590755cfaec14a0499b401a10a7a073af388b2 Mon Sep 17 00:00:00 2001 From: mappu Date: Sat, 2 Apr 2016 14:17:56 +1300 Subject: [PATCH] nmdc-log-service: buildscript --- src/nmdc-log-service/build.sh | 49 +++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 src/nmdc-log-service/build.sh diff --git a/src/nmdc-log-service/build.sh b/src/nmdc-log-service/build.sh new file mode 100644 index 0000000..97e0c43 --- /dev/null +++ b/src/nmdc-log-service/build.sh @@ -0,0 +1,49 @@ +#!/bin/bash + +set -eu + +export GOPATH=$( + cd ../../ + cygpath -w "$(pwd)" +) + +main() { + + local version="" + read -p "Enter version string (blank for timestamp)> " version + if [[ $version == "" ]] ; then + version=$(date +%s) + fi + echo "Using '${version}' as the version." + + if [[ -f nmdc-log-service.exe ]] ; then + rm ./nmdc-log-service.exe + fi + if [[ -f nmdc-log-service ]] ; then + rm ./nmdc-log-service + fi + + echo "Building win64..." + GOARCH=amd64 GOOS=windows go build -ldflags -s -o nmdc-log-service.exe + 7z a -mx9 nmdc-log-service-${version}-win64.7z nmdc-log-service.exe >/dev/null + rm ./nmdc-log-service.exe + + echo "Building win32..." + GOARCH=386 GOOS=windows go build -ldflags -s -o nmdc-log-service.exe + 7z a -mx9 nmdc-log-service-${version}-win32.7z nmdc-log-service.exe >/dev/null + rm ./nmdc-log-service.exe + + echo "Building linux64..." + GOARCH=amd64 GOOS=linux go build -ldflags -s -o nmdc-log-service + XZ_OPT=-9 tar caf nmdc-log-service-${version}-linux64.tar.xz nmdc-log-service --owner=0 --group=0 + rm ./nmdc-log-service + + echo "Building linux32..." + GOARCH=386 GOOS=linux go build -ldflags -s -o nmdc-log-service + XZ_OPT=-9 tar caf nmdc-log-service-${version}-linux32.tar.xz nmdc-log-service --owner=0 --group=0 + rm ./nmdc-log-service + + echo "Build complete." +} + +main "$@"