-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
122 lines (94 loc) · 3.38 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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# Copyright (C) 2017-2018 Nicolas Lamirault <nicolas.lamirault@gmail.com>
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
APP = picsou
VERSION=$(shell \
grep "const Version" version/version.go \
|awk -F'=' '{print $$2}' \
|sed -e "s/[^0-9.]//g" \
|sed -e "s/ //g")
SHELL = /bin/bash
DIR = $(shell pwd)
DOCKER = docker
GO = go
# Set any default go build tags
BUILDTAGS :=
GOX = gox -os="linux darwin windows freebsd openbsd netbsd"
GOX_ARGS = "-output={{.Dir}}-$(VERSION)_{{.OS}}_{{.Arch}}"
BINTRAY_URI = https://api.bintray.com
BINTRAY_USERNAME = nlamirault
BINTRAY_ORG = nlamirault
BINTRAY_REPOSITORY= oss
NO_COLOR=\033[0m
OK_COLOR=\033[32;01m
ERROR_COLOR=\033[31;01m
WARN_COLOR=\033[33;01m
MAKE_COLOR=\033[33;01m%-20s\033[0m
MAIN = github.com/nlamirault/picsou
SRCS = $(shell git ls-files '*.go' | grep -v '^vendor/')
EXE = $(shell ls picsou-*_*)
PACKAGE=$(APP)-$(VERSION)
ARCHIVE=$(PACKAGE).tar
.DEFAULT_GOAL := help
.PHONY: help
help:
@echo -e "$(OK_COLOR)==== $(APP) [$(VERSION)] ====$(NO_COLOR)"
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "$(MAKE_COLOR) : %s\n", $$1, $$2}'
clean: ## Cleanup
@echo -e "$(OK_COLOR)[$(APP)] Cleanup$(NO_COLOR)"
@rm -fr $(APP) $(EXE) $(APP)-*.tar.gz
.PHONY: init
init: ## Install requirements
@echo -e "$(OK_COLOR)[$(APP)] Install requirements$(NO_COLOR)"
@go get -u github.com/golang/lint/golint
@go get -u github.com/kisielk/errcheck
@go get -u github.com/mitchellh/gox
.PHONY: deps
deps: ## Install dependencies
@echo -e "$(OK_COLOR)[$(APP)] Update dependencies$(NO_COLOR)"
@dep ensure -update
.PHONY: build
build: ## Make binary
@echo -e "$(OK_COLOR)[$(APP)] Build $(NO_COLOR)"
@CGO_ENABLED=0 go build -tags "$(BUILDTAGS) static_build" .
.PHONY: test
test: ## Launch unit tests
@echo -e "$(OK_COLOR)[$(APP)] Launch unit tests $(NO_COLOR)"
@go test -v -tags "$(BUILDTAGS) cgo" $(shell go list ./... | grep -v vendor)
.PHONY: coverage
coverage: ## Launch code coverage
@go test -cover -v -tags "$(BUILDTAGS) cgo" $(shell $(GO) list ./... | grep -v vendor)
.PHONY: lint
lint: ## Launch golint
@golint $(shell $(GO) list ./... | grep -v vendor)
.PHONY: vet
vet: ## Launch go vet
@go vet $(shell go list ./... | grep -v vendor)
.PHONY: errcheck
errcheck: ## Launch go errcheck
@echo -e "$(OK_COLOR)[$(APP)] Go Errcheck $(NO_COLOR)"
@errcheck $(shell go list ./... | grep -v vendor)
gox: ## Make all binaries
@echo -e "$(OK_COLOR)[$(APP)] Create binaries $(NO_COLOR)"
$(GOX) $(GOX_ARGS) github.com/nlamirault/picsou
.PHONY: binaries
binaries: ## Upload all binaries
@echo -e "$(OK_COLOR)[$(APP)] Upload binaries to Bintray $(NO_COLOR)"
for i in $(EXE); do \
curl -T $$i \
-u$(BINTRAY_USERNAME):$(BINTRAY_APIKEY) \
"$(BINTRAY_URI)/content/$(BINTRAY_ORG)/$(BINTRAY_REPOSITORY)/$(APP)/${VERSION}/$$i;publish=1"; \
done
# for goprojectile
.PHONY: gopath
gopath:
@echo `pwd`:`pwd`/vendor