-
Notifications
You must be signed in to change notification settings - Fork 20
/
Makefile
58 lines (44 loc) · 1.46 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
58
PROJECT_NAME := $(shell basename $(CURDIR))
GIT_TAG := $(shell git describe --dirty --tags --always)
GIT_COMMIT := $(shell git rev-parse --short HEAD)
LDFLAGS := -X "main.gitTag=$(GIT_TAG)" -X "main.gitCommit=$(GIT_COMMIT)" -extldflags "-static" -s -w
FIRST_GOPATH := $(firstword $(subst :, ,$(shell go env GOPATH)))
GOLANGCI_LINT_BIN := $(FIRST_GOPATH)/bin/golangci-lint
GOSEC_BIN := $(FIRST_GOPATH)/bin/gosec
.PHONY: all
all: build
.PHONY: clean
clean:
git clean -Xfd .
.PHONY: build
build:
GOOS=${GOOS} GOARCH=${GOARCH} CGO_ENABLED=0 go build -a -ldflags '$(LDFLAGS)' -o $(PROJECT_NAME) .
.PHONY: vendor
vendor:
go mod tidy
go mod vendor
go mod verify
.PHONY: image
image: build
docker build -t $(PROJECT_NAME):$(GIT_TAG) .
build-push-development:
docker buildx create --use
docker buildx build -t webdevops/$(PROJECT_NAME):development --platform linux/amd64,linux/arm,linux/arm64 --push .
.PHONY: test
test:
go test ./...
.PHONY: dependencies
dependencies:
go mod vendor
.PHONY: check-release
check-release: vendor lint gosec test
.PHONY: lint
lint: $(GOLANGCI_LINT_BIN)
$(GOLANGCI_LINT_BIN) run -E exportloopref,gofmt --timeout=30m
.PHONY: gosec
gosec: $(GOSEC_BIN)
$(GOSEC_BIN) ./...
$(GOLANGCI_LINT_BIN):
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(FIRST_GOPATH)/bin
$(GOSEC_BIN):
curl -sfL https://raw.githubusercontent.com/securego/gosec/master/install.sh | sh -s -- -b $(FIRST_GOPATH)/bin