-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile
96 lines (79 loc) · 2.69 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
90
91
92
93
94
95
96
.DEFAULT_GOAL := help
SHELL := /bin/sh
## help: show this help
.PHONY: help
help: Makefile
@printf "\nChoose a command run in $(shell basename ${PWD}):\n"
@sed -n 's/^##//p' $< | column -t -s ":" | sed -e 's/^/ /'
@echo
## require: errors on uninstalled commands.
require-%:
$(if $(shell command -v $* 2> /dev/null), , $(error Please install `$*` ***))
.PHONY: license-check license-add fmt fumpt imports gci
license-check:
@addlicense -c "SIGHUP s.r.l" -y 2017-present -v -l bsd -check \
-ignore "vendor/**/*" \
-ignore "*.gen.go" \
-ignore ".idea/*" \
-ignore ".vscode/*" \
-ignore "*.js" \
-ignore "test/data/**/*" \
.
license-add:
@addlicense -c "SIGHUP s.r.l" -y 2017-present -v -l bsd \
-ignore "vendor/**/*" \
-ignore "*.gen.go" \
-ignore ".idea/*" \
-ignore ".vscode/*" \
-ignore "*.js" \
-ignore "test/data/**/*" \
.
fmt:
@find . -name "*.go" -type f -not -path '*/vendor/*' \
| sed 's/^\.\///g' \
| xargs -I {} sh -c 'echo "formatting {}.." && gofmt -w -s {}'
fumpt:
@find . -name "*.go" -type f -not -path '*/vendor/*' \
| sed 's/^\.\///g' \
| xargs -I {} sh -c 'echo "formatting {}.." && gofumpt -w -extra {}'
imports:
@find . -name *.go -type f -not -path '*/vendor/*' \
| sed 's/^\.\///g' \
| xargs -I {} sh -c 'echo "formatting imports for {}.." && goimports --local "github.com/sighupio" -v -w {}'
gci:
@find . -name "*.go" -type f -not -path '*/vendor/*' \
| sed 's/^\.\///g' \
| xargs -I {} sh -c 'echo "formatting imports for {}.." && \
gci write --skip-generated -s standard -s default -s "prefix(github.com/sighupio)" {}'
.PHONY: lint lint-go
lint: lint-go
lint-go:
@golangci-lint -v run --color=always --config=.rules/.golangci.yml ./...
## build: generate binaries for osx and linux
.PHONY: build
build:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -ldflags '-extldflags "-static"' -o bin/linux/furyagent .
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -a -ldflags '-extldflags "-static"' -o bin/darwin/furyagent .
## upload-to-s3: push to wasabisys
.PHONY: upload-to-s3
upload-to-s3:
@aws s3 sync bin s3://sighup-releases \
--endpoint-url=https://s3.wasabisys.com \
--exclude '*' \
--include 'linux/furyagent' \
--include 'darwin/furyagent'
## test: run tests
.PHONY: test
test:
go test -v ./...
## bumpversion-test: Check code syntax
.PHONY: bumpversion-test
bumpversion-test: TARGET ?= minor
bumpversion-test: require-bumpversion
@bumpversion ${TARGET} --verbose --dry-run --allow-dirty
## bumpversion-major: bump to the next major (i.e: 0.0.1 => 1.0.0)
## bumpversion-minor: bump to the next minor (i.e: 1.0.0 => 1.1.0)
## bumpversion-patch: bump to the next patch (i.e: 1.1.0 => 1.1.1)
bumpversion-%:
@TARGET=$* ${MAKE} bumpversion-test
@bumpversion $*