diff --git a/Makefile b/Makefile index 9f4d4f9b..d0a3e482 100644 --- a/Makefile +++ b/Makefile @@ -17,14 +17,8 @@ ifndef GITHUB_TAG GITHUB_TAG = $(shell git describe --tag --abbrev=0) endif -# check if a go version is already set -ifndef GOLANG_VERSION - # capture the current go version we build the application from - GOLANG_VERSION = $(shell go version | awk '{ print $$3 }') -endif - # create a list of linker flags for building the golang application -LD_FLAGS = -X github.com/go-vela/worker/version.Commit=${GITHUB_SHA} -X github.com/go-vela/worker/version.Date=${BUILD_DATE} -X github.com/go-vela/worker/version.Go=${GOLANG_VERSION} -X github.com/go-vela/worker/version.Tag=${GITHUB_TAG} +LD_FLAGS = -X github.com/go-vela/worker/version.Commit=${GITHUB_SHA} -X github.com/go-vela/worker/version.Date=${BUILD_DATE} -X github.com/go-vela/worker/version.Tag=${GITHUB_TAG} # The `clean` target is intended to clean the workspace # and prepare the local changes for submission. diff --git a/version/version.go b/version/version.go index 2e84520c..d62ce117 100644 --- a/version/version.go +++ b/version/version.go @@ -9,8 +9,8 @@ import ( "runtime" "github.com/Masterminds/semver/v3" - "github.com/go-vela/types/version" + "github.com/sirupsen/logrus" ) var ( @@ -23,7 +23,7 @@ var ( // Date represents the build date information for the package. Date string // Go represents the golang version information for the package. - Go string + Go = runtime.Version() // OS represents the operating system information for the package. OS = runtime.GOOS // Tag represents the git tag information for the package. @@ -32,6 +32,14 @@ var ( // New creates a new version object for Vela that is used throughout the application. func New() *version.Version { + // check if a semantic tag was provided + if len(Tag) == 0 { + logrus.Warningf("no semantic tag provided - defaulting to v0.0.0") + + // set a fallback default for the tag + Tag = "v0.0.0" + } + v, err := semver.NewVersion(Tag) if err != nil { fmt.Println(fmt.Errorf("unable to parse semantic version for %s: %v", Tag, err))