Skip to content
Snippets Groups Projects
Commit 82eca81e3dcd authored by steeve.chailloux's avatar steeve.chailloux
Browse files

improved version command

parent dc69dd959c5b
No related branches found
No related tags found
No related merge requests found
Pipeline #36722 passed
......@@ -10,7 +10,6 @@
version: '3'
vars:
VERSION: 2.0.0
EXE: beaver{{exeExt}}
OUTPUT: "build/{{.EXE}}"
GOLANGCI_LINT_VERSION: v1.44.0
......@@ -29,7 +28,7 @@
- mkdir -p build
- |
go build \
-ldflags "-X orus.io/orus-io/beaver/lib.version={{ .VERSION }}" \
-ldflags "-X 'orus.io/orus-io/beaver/lib.version=${CI_COMMIT_TAG}' -X 'orus.io/orus-io/beaver/lib.commitSha=$(hg id -i --debug)' -X 'orus.io/orus-io/beaver/lib.buildDate=$(date)'" \
-o {{.OUTPUT}} \
main.go
generates:
......
......@@ -12,7 +12,9 @@
)
var (
Version = beaver.GetVersion()
Version = beaver.GetVersion()
CommitSha = beaver.GetCommitSha()
BuildDate = beaver.GetBuildDate()
)
var (
......
......@@ -9,7 +9,7 @@
// Execute the 'version' commands
func (cmd *VersionCmd) Execute([]string) error {
fmt.Printf("Beaver %q\n", Version)
fmt.Printf("Beaver %s \nBuild Date: %s\nCommit SHA: %s\n", Version, BuildDate, CommitSha)
return nil
}
......
package beaver
var version = ""
var (
version = ""
commitSha = ""
buildDate = ""
)
func GetVersion() string {
return version
}
......@@ -4,4 +8,12 @@
func GetVersion() string {
return version
}
func GetCommitSha() string {
return commitSha
}
func GetBuildDate() string {
return buildDate
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment