diff options
author | Steve Durrheimer <s.durrheimer@gmail.com> | 2016-01-24 23:38:06 +0100 |
---|---|---|
committer | Steve Durrheimer <s.durrheimer@gmail.com> | 2016-04-28 22:07:21 +0200 |
commit | 158200fd49f8691b085c5ad17835fe1feb1ef665 (patch) | |
tree | 996be3e1223170b220e3d59e63be74b3a3f155fb /Makefile | |
parent | 7c97b784d63f949253c6b9c3514cf8f7eb2ce760 (diff) | |
download | prometheus_node_collector-158200fd49f8691b085c5ad17835fe1feb1ef665.tar.bz2 prometheus_node_collector-158200fd49f8691b085c5ad17835fe1feb1ef665.tar.xz prometheus_node_collector-158200fd49f8691b085c5ad17835fe1feb1ef665.zip |
New release process using docker, circleci and a centralized
building tool
Diffstat (limited to 'Makefile')
-rw-r--r-- | Makefile | 54 |
1 files changed, 43 insertions, 11 deletions
@@ -11,18 +11,50 @@ | |||
11 | # See the License for the specific language governing permissions and | 11 | # See the License for the specific language governing permissions and |
12 | # limitations under the License. | 12 | # limitations under the License. |
13 | 13 | ||
14 | VERSION := 0.12.0rc3 | 14 | GO := GO15VENDOREXPERIMENT=1 go |
15 | TARGET := node_exporter | 15 | PROMU := $(GOPATH)/bin/promu |
16 | pkgs = $(shell $(GO) list ./... | grep -v /vendor/) | ||
16 | 17 | ||
17 | REVISION := $(shell git rev-parse --short HEAD 2> /dev/null || echo 'unknown') | 18 | PREFIX ?= $(shell pwd) |
18 | BRANCH := $(shell git rev-parse --abbrev-ref HEAD 2> /dev/null || echo 'unknown') | 19 | BIN_DIR ?= $(shell pwd) |
20 | DOCKER_IMAGE_NAME ?= node-exporter | ||
21 | DOCKER_IMAGE_TAG ?= $(subst /,-,$(shell git rev-parse --abbrev-ref HEAD)) | ||
19 | 22 | ||
20 | REPO_PATH := "github.com/prometheus/node_exporter" | ||
21 | LDFLAGS := -X main.Version=$(VERSION) | ||
22 | LDFLAGS += -X $(REPO_PATH)/collector.Version=$(VERSION) | ||
23 | LDFLAGS += -X $(REPO_PATH)/collector.Revision=$(REVISION) | ||
24 | LDFLAGS += -X $(REPO_PATH)/collector.Branch=$(BRANCH) | ||
25 | 23 | ||
26 | GOFLAGS := -ldflags "$(LDFLAGS)" | 24 | all: format build test |
27 | 25 | ||
28 | include Makefile.COMMON | 26 | style: |
27 | @echo ">> checking code style" | ||
28 | @! gofmt -d $(shell find . -path ./vendor -prune -o -name '*.go' -print) | grep '^' | ||
29 | |||
30 | test: | ||
31 | @echo ">> running tests" | ||
32 | @$(GO) test -short $(pkgs) | ||
33 | |||
34 | format: | ||
35 | @echo ">> formatting code" | ||
36 | @$(GO) fmt $(pkgs) | ||
37 | |||
38 | vet: | ||
39 | @echo ">> vetting code" | ||
40 | @$(GO) vet $(pkgs) | ||
41 | |||
42 | build: promu | ||
43 | @echo ">> building binaries" | ||
44 | @$(PROMU) build --prefix $(PREFIX) | ||
45 | |||
46 | tarball: promu | ||
47 | @echo ">> building release tarball" | ||
48 | @$(PROMU) tarball --prefix $(PREFIX) $(BIN_DIR) | ||
49 | |||
50 | docker: | ||
51 | @echo ">> building docker image" | ||
52 | @docker build -t "$(DOCKER_IMAGE_NAME):$(DOCKER_IMAGE_TAG)" . | ||
53 | |||
54 | promu: | ||
55 | @GOOS=$(shell uname -s | tr A-Z a-z) \ | ||
56 | GOARCH=$(subst x86_64,amd64,$(patsubst i%86,386,$(shell uname -m))) \ | ||
57 | $(GO) get -u github.com/prometheus/promu | ||
58 | |||
59 | |||
60 | .PHONY: all style format build test vet tarball docker promu | ||