add build script with versioning
This commit is contained in:
parent
702edbc7a4
commit
1cbf1c542e
12
build.sh
Normal file → Executable file
12
build.sh
Normal file → Executable 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"
|
||||
|
@ -6,7 +6,7 @@ import (
|
||||
"os"
|
||||
)
|
||||
|
||||
var version float32
|
||||
var version string
|
||||
|
||||
func showVersion(){
|
||||
fmt.Println(version)
|
||||
|
Loading…
Reference in New Issue
Block a user