File tree Expand file tree Collapse file tree 3 files changed +9
-19
lines changed Expand file tree Collapse file tree 3 files changed +9
-19
lines changed Original file line number Diff line number Diff line change @@ -3,10 +3,17 @@ SHELL = bash
33BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
44# Current git commit hash
55GIT_COMMIT_HASH := $(shell git show --no-patch --no-notes --pretty='% h' HEAD)
6+ # Current git tag
7+ GIT_TAG := $(shell git describe --tags --exact-match || "")
8+ ifeq ($(GIT_TAG ) ,)
69VERSION := $(BRANCH ) .$(GIT_COMMIT_HASH )
10+ else
11+ VERSION := $(GIT_TAG )
12+ endif
713ifeq ($(shell git status --porcelain) ,)
814DIRTY :=
915else
16+ VERSION := $(BRANCH ) .$(GIT_COMMIT_HASH )
1017DIRTY := "dev"
1118endif
1219LDFLAGS =--ldflags "-s -X github.com/SwissDataScienceCenter/renku-dev-utils/pkg/version.Version=$(VERSION ) -X github.com/SwissDataScienceCenter/renku-dev-utils/pkg/version.VersionSuffix=$(DIRTY ) "
@@ -19,6 +26,7 @@ vars: ## Show the Makefile vars
1926 @echo SHELL=" '$( SHELL) '"
2027 @echo BRANCH=" '$( BRANCH) '"
2128 @echo GIT_COMMIT_HASH=" '$( GIT_COMMIT_HASH) '"
29+ @echo GIT_TAG=" '$( GIT_TAG) '"
2230 @echo VERSION=" '$( VERSION) '"
2331 @echo DIRTY=" '$( DIRTY) '"
2432
Original file line number Diff line number Diff line change @@ -14,6 +14,5 @@ var versionCmd = &cobra.Command{
1414}
1515
1616func runVersion (cmd * cobra.Command , args []string ) {
17- // fmt.Printf("renku-dev-utils %s\n", version.Version)
18- fmt .Printf ("renku-dev-utils %s\n " , version .BB ())
17+ fmt .Printf ("renku-dev-utils %s\n " , version .Version )
1918}
Original file line number Diff line number Diff line change 11package version
22
3- import (
4- "fmt"
5- "runtime/debug"
6- )
7-
83// Version of renku-dev-utils
94var Version string = "DEV"
105
@@ -16,15 +11,3 @@ func init() {
1611 Version = Version + "-" + VersionSuffix
1712 }
1813}
19-
20- func BB () (version string ) {
21- bi , ok := debug .ReadBuildInfo ()
22- if ! ok {
23- return "unknown"
24- }
25- version = bi .Main .Version
26- for _ , setting := range bi .Settings {
27- fmt .Printf ("%s: %s\n " , setting .Key , setting .Value )
28- }
29- return version
30- }
You can’t perform that action at this time.
0 commit comments