forked from anz-bank/sysl
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVersionReport.mk
More file actions
35 lines (26 loc) · 1.01 KB
/
VersionReport.mk
File metadata and controls
35 lines (26 loc) · 1.01 KB
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
######## Build information report
originalVersion=$(shell git describe --tags)
ifeq (-, $(findstring -, $(originalVersion))) #it is in branch
tagName= $(firstword $(subst -, ,$(originalVersion)))
diffLogs = $(foreach item, $(shell git log --pretty=format:"%h" $(tagName)..HEAD),$(item))
ifeq (true, $(words $(diffLogs)) = 0 || $(shell git status -s) = ) # no changes
Version=$(tagName)
else
ifeq (, $(shell git status -s)) # it doesn't have uncommitted or untracked changes
Version=$(FullCommit) (from $(tagName))
else
Version=DIRTY-$(FullCommit) (from $(tagName))
endif
endif
else
# it is in tag
ifeq (,$(shell git status -s)) # no changes
Version=$(originalVersion)
else
Version=DIRTY-$(originalVersion)
endif
endif
FullCommit=$(shell git log --pretty=format:"%H" -1)
GoVersion=$(strip $(subst go version, ,$(shell go version)))
BuildDate=$(shell date -u +'%Y-%m-%dT%H:%M:%SZ')
LDFLAGS='-X "main.Version=$(Version)" -X "main.GitFullCommit=$(FullCommit)" -X "main.BuildDate=$(BuildDate)" -X "main.GoVersion=$(GoVersion)"'