-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
73 lines (58 loc) · 1.81 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
.DEFAULT_GOAL := all
SHELL := /bin/bash -eu -o pipefail
NAME := aws-sns-push
VERSION := 0.1.0
REVISION := $(shell git rev-parse --short HEAD)
GO_BUILD_FLAGS := -v -ldflags="-s -w -X \"github.com/creasty/aws-sns-push/version.Version=$(VERSION)\" -X \"github.com/creasty/aws-sns-push/version.Revision=$(REVISION)\" -extldflags \"-static\""
GO_TEST_FLAGS := -v
PACKAGE_DIRS := $(shell go list ./... 2> /dev/null | grep -v /vendor/)
SRC_FILES := $(shell find . -name '*.go' -not -path './vendor/*')
# bin
#-----------------------------------------------
bin/$(NAME): $(SRC_FILES)
@GOOS=darwin GOARCH=amd64 go build $(GO_BUILD_FLAGS) -o bin/$(NAME)
# Tasks
#-----------------------------------------------
all: bin/$(NAME)
.PHONY: ci-build
ci-build:
@for os in darwin linux; do \
for arch in amd64 386; do \
echo "==> Build $$os $$arch"; \
GOOS=$$os GOARCH=$$arch go build $(GO_BUILD_FLAGS) \
-o dist/$$os-$$arch/$(NAME); \
done; \
done
.PHONY: clean
clean:
@rm -rf dist/*
.PHONY: lint
lint:
@gofmt -e -d -s $(SRC_FILES) | awk '{ e = 1; print $0 } END { if (e) exit(1) }'
@echo $(SRC_FILES) | xargs -n1 golint -set_exit_status
@go vet $(PACKAGE_DIRS)
.PHONY: test
test: lint
@go test $(GO_TEST_FLAGS) $(PACKAGE_DIRS)
.PHONY: ci-test
ci-test: lint
@echo > coverage.txt
@for d in $(PACKAGE_DIRS); do \
go test -coverprofile=profile.out -covermode=atomic -race -v $$d; \
if [ -f profile.out ]; then \
cat profile.out >> coverage.txt; \
rm profile.out; \
fi; \
done
.PHONY: release
release:
git tag v$(VERSION)
git push origin v$(VERSION)
.PHONY: dist
dist:
@cd dist \
&& find * -type d -exec cp ../LICENSE {} \; \
&& find * -type d -exec cp ../README.md {} \; \
&& find * -type d -exec tar -zcf $(NAME)-{}.tar.gz {} \; \
&& find * -type d -exec zip -r $(NAME)-{}.zip {} \; \
&& cd ..