Skip to content

Commit

Permalink
Merge pull request #42 from jacobbednarz/add-version-to-binary
Browse files Browse the repository at this point in the history
Update build script to ignore structure
  • Loading branch information
jacobbednarz authored May 4, 2020
2 parents e3f9bda + e3522e8 commit ef8dd9f
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions script/build
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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!"
Expand All @@ -38,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
Expand Down

0 comments on commit ef8dd9f

Please sign in to comment.