-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile.version
39 lines (34 loc) · 1.41 KB
/
Makefile.version
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# version information
DATE = $(shell date -u --iso-8601=seconds)
VERSION ?=
GIT_TREE_STATE = ""
GIT_TAG = ""
GIT_TAG_LAST = ""
RELEASE_STATUS = ""
NO_GIT = $(shell git version > /dev/null 2>&1 || echo true)
ifeq (,$(NO_GIT))
# get last commit ID
COMMIT = $(shell git rev-parse --verify HEAD)
# Tree state is "dirty" if there are uncommitted changes, untracked files are ignored
GIT_TREE_STATE = $(shell test -n "`git status --porcelain --untracked-files=no`" && echo "dirty" || echo "clean")
# Empty string if we are not building a tag
GIT_TAG = $(shell git describe --tags --abbrev=0 --exact-match 2>/dev/null || true)
# Find most recent tag
GIT_TAG_LAST = $(shell git describe --tags --abbrev=0 2>/dev/null || true)
endif
# VERSION override mechanism if needed
ifneq (,$(VERSION))
RELEASE_STATUS = ",released"
endif
ifneq (,$(GIT_TAG))
RELEASE_STATUS = ",released"
endif
ifeq (,$(VERSION))
VERSION = $(GIT_TAG_LAST)
endif
# Add version/commit/date to linker flags
VERSION_LDFLAGS = "-X github.com/Mellanox/maintenance-operator/internal/version.version=${VERSION} \
-X github.com/Mellanox/maintenance-operator/internal/version.commit=${COMMIT} \
-X github.com/Mellanox/maintenance-operator/internal/version.gitTreeState=${GIT_TREE_STATE} \
-X github.com/Mellanox/maintenance-operator/internal/version.releaseStatus=${RELEASE_STATUS} \
-X github.com/Mellanox/maintenance-operator/internal/version.date=${DATE}"