Skip to content

Commit 5d9fa05

Browse files
authored
Merge pull request goadapp#161 from cwaltken-edrans/151-set-cli-version-when-using-travis-to-build-a-tagged-release
Use git tag when building goad with travis
2 parents ca4825c + ccce98b commit 5d9fa05

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ BUILD := `git rev-parse HEAD`
1717
TIMESTAMP := `git log -1 --date=format:%Y%m%d%H%M --pretty=format:%cd`
1818

1919
# Use linker flags to provide version/build settings to the target
20-
LDFLAGS = -ldflags "-X=github.com/goadapp/goad/version.version=$(VERSION) -X=github.com/goadapp/goad/version.build=$(BUILD)"
20+
LDFLAGS = -ldflags "-X=github.com/goadapp/goad/version.version=$(VERSION) -X=github.com/goadapp/goad/version.build=$(BUILD) -X=github.com/goadapp/goad/version.travisTag=$(TRAVIS_TAG)"
2121

2222
# go source files, ignore vendor directory
2323
SRC = $(shell find . -type f -name '*.go' -not -path "./vendor/*")

version/version.go

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ import "strings"
44

55
// Version describes the Goad version.
66
var (
7-
version string
8-
build string
7+
version string
8+
build string
9+
travisTag string
910
)
1011

1112
// Version returns the version
@@ -21,9 +22,16 @@ func Build() string {
2122
return build
2223
}
2324

25+
func ReleaseVersion() string {
26+
return travisTag
27+
}
28+
2429
// String returns a composed string of version and build number
2530
func String() string {
26-
return Version() + "-" + Build()
31+
if ReleaseVersion() == "" {
32+
return Version() + "-" + Build()
33+
}
34+
return ReleaseVersion()
2735
}
2836

2937
// LambdaVersion returns a version string that can be used as a Lambda function

0 commit comments

Comments
 (0)