-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
40 lines (31 loc) · 1.02 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
LDFLAGS ?=-s -w -X main.appVersion=dev-$(shell git rev-parse --short HEAD)-$(shell date +%y-%m-%d)
OUT ?= ./build
PROJECT ?=$(shell basename $(PWD))
SRC ?= ./cmd/$(PROJECT)
BINARY ?= $(OUT)/$(PROJECT)
export BUNDLE_TAG ?= latest
export PREFIX ?= manual
all: build lint test
build:
mkdir -p $(OUT)
CGO_ENABLED=0 go build -ldflags "$(LDFLAGS)" -trimpath -o $(BINARY) $(SRC)
$(BINARY): build
run:
CGO_ENABLED=0 go run -ldflags "$(LDFLAGS)" -trimpath $(SRC)
lint:
golangci-lint run
test:
go test ./...
update-usage: build
head -n $(shell grep -nE '^## Usage' README.md | tr ':' ' ' | awk '{print $$1}') README.md > README.md.temp
tail -n +$(shell grep -nE '^## Contributing' README.md | tr ':' ' ' | awk '{print $$1}') README.md > README.md.tail
echo >> README.md.temp
echo '```' >> README.md.temp
$(BINARY) --help >> README.md.temp || true
echo '```' >> README.md.temp
mv -f README.md.temp README.md
echo >> README.md
cat README.md.tail >> README.md
rm README.md.tail
.PHONY: all build run lint test update-usage
$(V).SILENT: