-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
82 lines (66 loc) · 1.57 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
SOURCE_FILES?=./...
export PATH := ./bin:$(PATH)
export GOPATH := $(shell go env GOPATH)
export GO111MODULE := on
export GOPROXY := https://goproxy.io,direct
export GOPRIVATE := github.com/jinmukeji/*
export GOVERSION := $(shell go version | awk '{print $$3}')
# GORELEASER is the path to the goreleaser binary.
export GORELEASER := $(shell which goreleaser)
# all is the default target
all: release
.PHONY: all
# Install all the tools and dependencies"
setup:
[ -x "$(GORELEASER)" ] || ( brew update && brew install goreleaser/tap/goreleaser )
# golangci-lint
brew install golangci-lint
.PHONY: setup
# Update go packages
go-mod-update:
@echo "Checking updated go packages..."
@go list -u -m all
@echo "Updating go packages..."
@go get -u -t ./...
@$(MAKE) go-mod-tidy
.PHONY: go-update
# Clean go.mod
go-mod-tidy:
@go mod tidy -v
# git --no-pager diff HEAD
# git --no-pager diff-index --quiet HEAD
.PHONY: go-mod-tidy
# Reset go.mod
go-mod-reset:
@rm -f go.sum
@sed -i '' -e '/^require/,/^)/d' go.mod
@go mod tidy -v
.PHONY: go-mod-tidy
generate:
@go generate ./...
.PHONY: generate
# Format go files
format:
@goimports -w ./
.PHONY: format
# Run all the linters
lint:
@golangci-lint run
.PHONY: lint
# Go build all
build:
@go build ./... > /dev/null
.PHONY: build
# Go test all
test:
@go test ./...
.PHONY: test
# Run all code checks
ci: generate format lint build test
.PHONY: ci
# Release wia goreleaser
release:
@[ -x "$(GORELEASER)" ] || ( echo "goreleaser not installed"; exit 1)
@goreleaser --snapshot --skip-publish --rm-dist
.PHONY: release
.DEFAULT_GOAL := all