-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
108 lines (82 loc) · 2.47 KB
/
Makefile
File metadata and controls
108 lines (82 loc) · 2.47 KB
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# Makefile based on https://github.com/Masterminds/glide/blob/master/Makefile
GO ?= go
DIST_DIRS := find * -type d -exec
VERSION ?= $(shell git describe --tags)
# Last project tag (used in `make changelog`)
RELEASE ?= $(shell git describe --tags --abbrev=0 --always)
SOURCES ?= *.go */*.go
# ------------------------------------------------------------------------------
.PHONY: build install clean bootstrap-dist build-all dist
##
## Available make targets
##
# default: show target list
all: help
# ------------------------------------------------------------------------------
## Sources
## Format go sources
fmt:
$(GO) fmt ./...
## Run vet
vet:
$(GO) vet ./...
## Run linters
lint:
golint ./...
golangci-lint run ./...
## Run tests and fill coverage.out
cov: coverage.out
# internal target
coverage.out: $(SOURCES)
GIN_MODE=release $(GO) test -test.v -coverprofile=$@ -covermode=atomic -tags test ./...
## Open coverage report in browser
cov-html: cov
$(GO) tool cover -html=coverage.out
## Clean coverage report
cov-clean:
rm -f coverage.*
build:
${GO} build -o apisite -ldflags "-X main.version=${VERSION}"
install: build
install -d ${DESTDIR}/usr/local/bin/
install -m 755 ./apisite ${DESTDIR}/usr/local/bin/apisite
clean:
rm -f ./apisite
rm -rf ./dist
#test:
# go test -c -coverpkg=. -tags test
## Changes from last tag
changelog:
@echo Changes since $(RELEASE)
@echo
@git log $(RELEASE)..@ --pretty=format:"* %s"
# ------------------------------------------------------------------------------
## Deploy
## Install gox
bootstrap-dist:
${GO} get -u github.com/Masterminds/gox
## Build dist binaries
build-all:
gox -verbose \
-ldflags "-X main.version=${VERSION}" \
-os="linux darwin windows" \
-arch="amd64 386" \
-osarch="!darwin/arm64" \
-output="dist/{{.OS}}-{{.Arch}}/{{.Dir}}" .
## Make all distributives
dist: build-all
cd dist && \
$(DIST_DIRS) cp ../LICENSE {} \; && \
$(DIST_DIRS) cp ../README.md {} \; && \
$(DIST_DIRS) tar -zcf apisite-${VERSION}-{}.tar.gz {} \; && \
$(DIST_DIRS) zip -r apisite-${VERSION}-{}.zip {} \; && \
cd ..
# ------------------------------------------------------------------------------
## Misc
## Count lines of code (including tests) and update LOC.md
cloc: LOC.md
LOC.md: $(SOURCES)
cloc --by-file --md $(SOURCES) > $@
## List Makefile targets
help: Makefile
@grep -A1 "^##" $< | grep -vE '^--$$' | sed -E '/^##/{N;s/^## (.+)\n(.+):(.*)/\t\2:\1/}' | column -t -s ':'