-
Notifications
You must be signed in to change notification settings - Fork 4
/
Makefile
89 lines (72 loc) · 1.87 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
86
87
88
89
export GO111MODULE=on
export GOOS=linux
PROJECT = shawk
PKG = github.com/yuuki/$(PROJECT)
COMMIT = $$(git describe --tags --always)
DATE = $$(date -u '+%Y-%m-%d_%H:%M:%S')
BUILD_LDFLAGS = -X $(PKG)/version.commit=$(COMMIT) -X $(PKG)/version.date=$(DATE)
CREDITS = ./assets/CREDITS
GOLINT = $$(go env GOPATH)/bin/golint -set_exit_status $$(go list -mod=vendor ./...)
GOTEST = go test -v ./...
DOCKER_IMAGE_NAME="shawk-test"
DOCKER_CONTAINER_NAME="shawk-test-container"
DOCKER = docker run --rm -v $$(PWD):/go/src/github.com/yuuki/shawk --name $(DOCKER_CONTAINER_NAME) $(DOCKER_IMAGE_NAME)
container = docker ps -a -q -f "name=$(DOCKER_CONTAINER_NAME)"
all: init build
.PHONY: clean
clean:
@if [ "$(container || true)" != "" ] ; then \
docker rm -f $(DOCKER_CONTAINER_NAME) 2>/dev/null; \
fi
.PHONY: build
build: clean
go generate ./...
$(DOCKER) go build -ldflags="$(BUILD_LDFLAGS)"
go mod tidy
.PHONY: install
install:
go install $(PKG)/cmd/...
.PHONY: test
test:
$(DOCKER) $(GOTEST)
go mod tidy
.PHONY: ci-test
ci-test:
$(GOTEST)
.PHONY: lint
lint:
# golangci-lint run ./... error: failed prerequisites:
$(DOCKER) $(GOLINT)
.PHONY: ci-lint
ci-lint:
$(GOLINT)
.PHONY: credits
credits: deps
gocredits > $(CREDITS)
ifneq (,$(git status -s $(CREDITS)))
go generate -x ./...
endif
.PHONY: release
release: credits
_tools/release
init: deps docker-build
.PHONY: deps
deps:
sh -c '\
tmpdir=$$(mktemp -d); \
cd $$tmpdir; \
go get -u \
github.com/rakyll/statik \
golang.org/x/lint/golint \
github.com/x-motemen/gobump/cmd/gobump \
github.com/Songmu/ghch/cmd/ghch \
github.com/Songmu/gocredits/cmd/gocredits \
github.com/goware/modvendor; \
rm -rf $$tmpdir'
.PHONY: docker-build
docker-build:
docker build -t $(DOCKER_IMAGE_NAME) .
# Run to copy .c and .h files after receiving PR by Renovate.
.PHONY: modvendor
modvendor:
modvendor -copy="**/*.c **/*.h" -v