From d117a2368ea1709c9e06eacdc02ce9dde653dc21 Mon Sep 17 00:00:00 2001 From: Jacob Bednarz Date: Mon, 4 May 2020 11:16:10 +1000 Subject: [PATCH 1/2] Add Rev build version for CLI output --- script/build | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/script/build b/script/build index 633cb19..75aba38 100755 --- a/script/build +++ b/script/build @@ -7,6 +7,9 @@ if [[ -z "$version" ]]; then exit 1 fi +git_sha=`git rev-parse --short HEAD` +version_with_sha="${version}+${git_sha}" + if [ -d build ]; then rm -rf build fi @@ -27,9 +30,9 @@ do if [ $GOOS = "windows" ]; then - env GOOS=$GOOS GOARCH=$GOARCH go build -o "build/${output_name}.exe" . + env GOOS=$GOOS GOARCH=$GOARCH go build -o "build/${output_name}.exe" -ldflags "-X main.Rev=${version_with_sha}" . else - env GOOS=$GOOS GOARCH=$GOARCH go build -o "build/${output_name}" . + env GOOS=$GOOS GOARCH=$GOARCH go build -o "build/${output_name}" -ldflags "-X main.Rev=${version_with_sha}" . fi if [ $? -ne 0 ]; then echo "Building the binary has failed!" From e3522e82413b11b09878f8464745fe5c5ba97723 Mon Sep 17 00:00:00 2001 From: Jacob Bednarz Date: Mon, 4 May 2020 11:16:30 +1000 Subject: [PATCH 2/2] Don't worry about tarballing the structure --- script/build | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/script/build b/script/build index 75aba38..0784841 100755 --- a/script/build +++ b/script/build @@ -41,9 +41,9 @@ do printf "==> Tarballing %s\t%s\n" "$platform" "build/${output_name}.tar.gz" | expand -t 30 if [ $GOOS = "windows" ]; then - tar -czf "build/${output_name}.tar.gz" "build/${output_name}.exe" + tar -czf "build/${output_name}.tar.gz" -C "build" "${output_name}.exe" else - tar -czf "build/${output_name}.tar.gz" "build/${output_name}" + tar -czf "build/${output_name}.tar.gz" -C "build" "${output_name}" fi if [ $? -ne 0 ]; then