-
Notifications
You must be signed in to change notification settings - Fork 4
/
Makefile
73 lines (60 loc) · 1.68 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
export GO111MODULE=on
export GOOS=linux
PROJECT = transtracer
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
DOCKER_IMAGE_NAME="transtracer-test"
DOCKER_CONTAINER_NAME="transtracer-test-container"
DOCKER = docker run --rm -v $$(PWD):/go/src/github.com/yuuki/transtracer --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)" ./cmd/ttracerd/
$(DOCKER) go build -ldflags="$(BUILD_LDFLAGS)" ./cmd/ttctl/
go mod tidy
.PHONY: install
install:
go install $(PKG)/cmd/...
.PHONY: test
test:
$(DOCKER) go test -v ./...
go mod tidy
.PHONY: lint
lint:
# golangci-lint run ./... error: failed prerequisites:
$(DOCKER) golint -set_exit_status $$(go list -mod=vendor ./...)
.PHONY: credits
credits: devel-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; \
rm -rf $$tmpdir'
.PHONY: docker-build
docker-build:
docker build -t $(DOCKER_IMAGE_NAME) .