add build script with versioning

This commit is contained in:
Greg Gauthier 2021-03-18 22:24:46 +00:00
parent 702edbc7a4
commit 1cbf1c542e
2 changed files with 10 additions and 4 deletions

12
build.sh Normal file → Executable file
View File

@ -1,10 +1,16 @@
#!/usr/bin/env sh
# shellcheck disable=SC2155
export GIT_COMMIT=$(git rev-list -1 HEAD)
GOPATH=$GOPATH:$(pwd)
export GOPATH
GIT_COMMIT=$(git rev-list -1 HEAD)
export GIT_COMMIT
CANONICAL_VERSION=$(cat ./VERSION)
VERSION_STRING="$CANONICAL_VERSION ($GIT_COMMIT)"
export CANONICAL_VERSION
VERSION_STRING="$CANONICAL_VERSION-$GIT_COMMIT"
export VERSION_STRING
go mod vendor
go mod tidy
go build -o build/gostations -ldflags "-X main.version=$VERSION_STRING"

View File

@ -6,7 +6,7 @@ import (
"os"
)
var version float32
var version string
func showVersion(){
fmt.Println(version)