Skip to content

Commit ef8dd9f

Browse files
authored
Merge pull request #42 from jacobbednarz/add-version-to-binary
Update build script to ignore structure
2 parents e3f9bda + e3522e8 commit ef8dd9f

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

script/build

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ if [[ -z "$version" ]]; then
77
exit 1
88
fi
99

10+
git_sha=`git rev-parse --short HEAD`
11+
version_with_sha="${version}+${git_sha}"
12+
1013
if [ -d build ]; then
1114
rm -rf build
1215
fi
@@ -27,9 +30,9 @@ do
2730

2831

2932
if [ $GOOS = "windows" ]; then
30-
env GOOS=$GOOS GOARCH=$GOARCH go build -o "build/${output_name}.exe" .
33+
env GOOS=$GOOS GOARCH=$GOARCH go build -o "build/${output_name}.exe" -ldflags "-X main.Rev=${version_with_sha}" .
3134
else
32-
env GOOS=$GOOS GOARCH=$GOARCH go build -o "build/${output_name}" .
35+
env GOOS=$GOOS GOARCH=$GOARCH go build -o "build/${output_name}" -ldflags "-X main.Rev=${version_with_sha}" .
3336
fi
3437
if [ $? -ne 0 ]; then
3538
echo "Building the binary has failed!"
@@ -38,9 +41,9 @@ do
3841

3942
printf "==> Tarballing %s\t%s\n" "$platform" "build/${output_name}.tar.gz" | expand -t 30
4043
if [ $GOOS = "windows" ]; then
41-
tar -czf "build/${output_name}.tar.gz" "build/${output_name}.exe"
44+
tar -czf "build/${output_name}.tar.gz" -C "build" "${output_name}.exe"
4245
else
43-
tar -czf "build/${output_name}.tar.gz" "build/${output_name}"
46+
tar -czf "build/${output_name}.tar.gz" -C "build" "${output_name}"
4447
fi
4548

4649
if [ $? -ne 0 ]; then

0 commit comments

Comments
 (0)