Skip to content

Commit 9ad11c3

Browse files
committed
Use git tag in version
1 parent 6df578b commit 9ad11c3

File tree

3 files changed

+9
-19
lines changed

3 files changed

+9
-19
lines changed

Makefile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,17 @@ SHELL = bash
33
BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
44
# Current git commit hash
55
GIT_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),)
69
VERSION := $(BRANCH).$(GIT_COMMIT_HASH)
10+
else
11+
VERSION := $(GIT_TAG)
12+
endif
713
ifeq ($(shell git status --porcelain),)
814
DIRTY :=
915
else
16+
VERSION := $(BRANCH).$(GIT_COMMIT_HASH)
1017
DIRTY := "dev"
1118
endif
1219
LDFLAGS=--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

pkg/cmd/version.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,5 @@ var versionCmd = &cobra.Command{
1414
}
1515

1616
func 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
}

pkg/version/version.go

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
package version
22

3-
import (
4-
"fmt"
5-
"runtime/debug"
6-
)
7-
83
// Version of renku-dev-utils
94
var 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-
}

0 commit comments

Comments
 (0)