-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathMakefile
36 lines (28 loc) · 881 Bytes
/
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
_GIT_VERSION := $(shell git describe --tags --dirty)
_GIT_COMMIT := $(shell git rev-parse --short HEAD)
_GO_BUILD_FLAGS = -ldflags "-X main.Version=$(_GIT_VERSION)"
GO_BIN ?= go
DOCKER_BIN ?= docker
DOCKER_TAG ?= tmpl:$(_GIT_COMMIT)
DOCKER_NAME ?= tmpl
DIST ?= dist/tmpl
$(DIST):
$(GO_BIN) build $(GO_BUILD_FLAGS) $(_GO_BUILD_FLAGS) -o $(DIST) cmd/main.go
.PHONY: clean
clean:
if [ -f $(DIST) ]; then rm -f $(DIST); fi
.PHONY: build
build: clean $(DIST)
.PHONY: test
test:
$(GO_BIN) test -v $$($(GO_BIN) list ./... | grep -v /example) && echo && echo "ALL TESTS OK"
.PHONY: docker-build
docker-build:
$(DOCKER_BIN) build -t $(DOCKER_TAG) .
.PHONY: docker-run
docker-run:
@echo Execute:
@echo $(DOCKER_BIN) run $(DOCKER_TAG)
@echo " for example:"
@echo " $(DOCKER_BIN) run --rm --name $(DOCKER_NAME) $(DOCKER_TAG) --help"
@echo " $(DOCKER_BIN) run $(DOCKER_TAG) "