-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
85 lines (67 loc) · 2 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
GOCMD=go
GOBUILD=$(GOCMD) build
GOINSTALL=$(GOCMD) install
GORUN=$(GOCMD) run
GOCLEAN=$(GOCMD) clean
GOTEST=$(GOCMD) test
GOTOOL=$(GOCMD) tool
GOMOD=$(GOCMD) mod
GOPATH?=$(shell $(GOCMD) env GOPATH)
GOBIN?=$(shell $(GOCMD) env GOBIN)
BINARY=imap
BINARY_LINUX=$(BINARY)_linux
TESTS=./...
COVERAGE_FILE=coverage.out
BUILD=build/
BUILD_DATE=`date`
BUILD_COMMIT=`git rev-parse HEAD`
all: download test build
.PHONY: all download test coverage build build-linux install dovecot nightly generate-install
download:
@echo "[*] $@"
@$(GOMOD) download
test: download
@echo "[*] $@"
$(GOTEST) -v $(TESTS)
coverage:
@echo "[*] $@"
$(GOTEST) -coverprofile=$(COVERAGE_FILE) $(TESTS)
$(GOTOOL) cover -html=$(COVERAGE_FILE)
build: download
@echo "[*] $@"
$(GOBUILD) -o $(BINARY) -v -ldflags "-X 'main.buildCommit=${BUILD_COMMIT}' -X 'main.buildDate=${BUILD_DATE}' -X 'main.buildBy=make'"
build-linux: download
@echo "[*] $@"
GOOS="linux" GOARCH="amd64" $(GOBUILD) -o $(BINARY_LINUX) -v -ldflags "-X 'main.buildCommit=${BUILD_COMMIT}' -X 'main.buildDate=${BUILD_DATE}' -X 'main.buildBy=make'"
install: download
@echo "[*] $@"
$(GOINSTALL) -v -ldflags "-X 'main.buildCommit=${BUILD_COMMIT}' -X 'main.buildDate=${BUILD_DATE}' -X 'main.buildBy=make'"
dovecot:
@echo "[*] $@"
docker run -d --rm -p 143:143 -p 993:993 dovecot/dovecot:latest
$(GOBIN)/eget:
@echo "[*] $@"
go install -v github.com/zyedidia/eget@latest
$(GOBIN)/goreleaser: $(GOBIN)/eget
@echo "[*] $@"
eget goreleaser/goreleaser --to $(GOBIN)
nightly: $(GOBIN)/goreleaser
@echo "[*] $@"
GITLAB_TOKEN= goreleaser --snapshot --skip=publish --clean
generate-install:
@echo "[*] $@"
godownloader .godownloader.yml -r creativeprojects/imap -o install.sh
.PHONY: lint
lint:
@echo "[*] $@"
GOOS=darwin golangci-lint run
GOOS=linux golangci-lint run
GOOS=windows golangci-lint run
.PHONY: fix
fix:
@echo "[*] $@"
$(GOCMD) mod tidy
$(GOCMD) fix ./...
GOOS=darwin golangci-lint run --fix
GOOS=linux golangci-lint run --fix
GOOS=windows golangci-lint run --fix