Skip to content

Commit fb2330b

Browse files
authored
feat: use git tag for version (#14)
1 parent ef11dba commit fb2330b

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
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

0 commit comments

Comments
 (0)