-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
37 lines (26 loc) · 1.32 KB
/
Makefile
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
BINARY = webhook-docker
GOARCH = amd64
VERSION?=$(shell git describe --tags --always --dirty --match=* 2> /dev/null || \
cat $(CURDIR)/.version 2> /dev/null || echo v0)
SHORT_VERSION?=$(shell git describe --tags --always --dirty --match=* | cut -d'-' -f1 2> /dev/null || \
cat $(CURDIR)/.version 2> /dev/null || echo v0)
MAIN_BUILD_PATH=./cmd/webhook-docker
COMMIT=$(shell git rev-parse HEAD)
BRANCH=$(shell git rev-parse --abbrev-ref HEAD)
DATE ?= $(shell date +%FT%T%z)
# Setup the -ldflags option for go build here, interpolate the variable values
LDFLAGS = -ldflags '-w -s -X main.version=${VERSION} -X main.commit=${COMMIT} -X main.branch=${BRANCH} -X main.buildDate=${DATE} -X main.shortVersion=${SHORT_VERSION} -X container.buildDate=${DATE} -X container.shortVersion=${SHORT_VERSION} -X main.build="production"'
.PHONY: build
build:
@echo "Start: GOOS=linux GOARCH=${GOARCH} go build ${LDFLAGS} -o ${BINARY}-linux-${GOARCH} $(MAIN_BUILD_PATH)"; \
GO111MODULE=on GOOS=linux GOARCH=${GOARCH} go build ${LDFLAGS} -o ${BINARY}-linux-${GOARCH} $(MAIN_BUILD_PATH) ; \
echo "End build"
.PHONY: docker_install
docker_install: build
@cp -f ${BINARY}-linux-${GOARCH} ${GOPATH}/bin/${BINARY}
.PHONY: version
version:
@echo "Current dir: $(CURDIR)"
@echo "Version: $(VERSION)"
@echo "Commit: $(COMMIT)"
@echo "Date: $(DATE)"