Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
12 changes: 10 additions & 2 deletions version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (
"runtime"

"github.com/Masterminds/semver/v3"

"github.com/go-vela/types/version"
"github.com/sirupsen/logrus"
)

var (
Expand All @@ -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.
Expand All @@ -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))
Expand Down