generated from xmidt-org/.go-template
/
Makefile
59 lines (40 loc) · 1.84 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
.PHONY: default build test style docker binaries clean
DOCKER ?= docker
GO ?= go
GOFMT ?= $(GO)fmt
APP := ears
DOCKER_ORG := xmidt
VERSION ?= $(shell git describe --tag --always --dirty)
#PROGVER ?= $(shell git describe --tags `git rev-list --tags --max-count=1` | tail -1 | sed 's/v\(.*\)/\1/')
#BUILDTIME = $(shell date -u '+%c')
#GITCOMMIT = $(shell git rev-parse --short HEAD)
#GOBUILDFLAGS = -a -ldflags "-w -s -X 'main.BuildTime=$(BUILDTIME)' -X main.GitCommit=$(GITCOMMIT) -X github.com/xmidt-org/ears/pkg/app.Version=$(VERSION)" -o $(APP)
GOBUILDFLAGS = -a -ldflags "-w -s -X github.com/xmidt-org/ears/pkg/app.Version=$(VERSION)" -o $(APP)
BUILD_DIR = ./cmd/ears
default: build
generate:
$(GO) generate ./...
$(GO) install ./...
test:
$(GO) test -v -race -coverprofile=coverage.txt ./...
$(GO) test -v -race -json ./... > report.json
style:
! $(GOFMT) -d $$(find . -path ./vendor -prune -o -name '*.go' -print) | grep '^'
check:
golangci-lint run -n | tee errors.txt
build:
CGO_ENABLED=0 $(GO) build $(GOBUILDFLAGS) $(BUILD_DIR)
release: build
upx $(APP)
docker:
-$(DOCKER) rmi "$(APP):$(VERSION)"
-$(DOCKER) rmi "$(APP):latest"
$(DOCKER) build -t "$(APP):$(VERSION)" -t "$(APP):latest" .
binaries: generate
mkdir -p ./.ignore
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 $(GO) build -o ./.ignore/$(APP)-$(PROGVER).darwin-amd64 -ldflags "-X 'main.BuildTime=$(BUILDTIME)' -X main.GitCommit=$(GITCOMMIT) -X main.Version=$(VERSION)" $(BUILD_DIR)
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 $(GO) build -o ./.ignore/$(APP)-$(PROGVER).linux-amd64 -ldflags "-X 'main.BuildTime=$(BUILDTIME)' -X main.GitCommit=$(GITCOMMIT) -X main.Version=$(VERSION)" $(BUILD_DIR)
upx ./.ignore/$(APP)-$(PROGVER).darwin-amd64
upx ./.ignore/$(APP)-$(PROGVER).linux-amd64
clean:
-rm -r .ignore/ $(APP) errors.txt report.json coverage.txt