Add git commit to the version output. (#900)

Now the output would be:
```
 ./coredns -version
CoreDNS-010
linux/amd64, go1.8, 241e3db
```
In case the local file has been modified, then the output would be (with --dirty):
```
 ./coredns -version
CoreDNS-010
linux/amd64, go1.8, 241e3db-dirty
```

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
This commit is contained in:
Yong Tang
2017-08-11 09:47:37 -07:00
committed by Miek Gieben
parent ebcbe66bbd
commit a09f208c51
3 changed files with 8 additions and 5 deletions

View File

@@ -38,6 +38,7 @@ ARCH:=$(shell uname -m)
GITHUB:=coredns
DOCKER:=coredns
DOCKER_IMAGE_NAME:=$(DOCKER)/$(NAME)
GITCOMMIT:=$(shell git describe --dirty --always)
all:
@echo Use the 'release' target to start a release
@@ -66,17 +67,17 @@ build: build-arm build-darwin build-linux
.PHONY: build-linux
build-linux:
@echo Building: linux $(VERSION)
mkdir -p build/Linux && CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w" -o build/Linux/$(NAME)
mkdir -p build/Linux && CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w -X github.com/coredns/coredns/coremain.gitCommit=$(GITCOMMIT)" -o build/Linux/$(NAME)
.PHONY: build-darwin
build-darwin:
@echo Building: darwin $(VERSION)
mkdir -p build/Darwin && CGO_ENABLED=0 GOOS=darwin go build -ldflags="-s -w" -o build/Darwin/$(NAME)
mkdir -p build/Darwin && CGO_ENABLED=0 GOOS=darwin go build -ldflags="-s -w -X github.com/coredns/coredns/coremain.gitCommit=$(GITCOMMIT)" -o build/Darwin/$(NAME)
.PHONY: build-arm
build-arm:
@echo Building: arm $(VERSION)
mkdir -p build/Linux/Arm && CGO_ENABLED=0 GOOS=linux GOARCH=arm go build -ldflags="-s -w" -o build/Linux/Arm/$(NAME)
mkdir -p build/Linux/Arm && CGO_ENABLED=0 GOOS=linux GOARCH=arm go build -ldflags="-s -w -X github.com/coredns/coredns/coremain.gitCommit=$(GITCOMMIT)" -o build/Linux/Arm/$(NAME)
.PHONY: tar