forked from sysulq/nginx-vts-exporter
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
liqi
committed
Jul 15, 2019
1 parent
45519bb
commit a0efaea
Showing
1 changed file
with
66 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,66 +1,66 @@ | ||
GO := GO15VENDOREXPERIMENT=1 go | ||
PROMU := $(GOPATH)/bin/promu | ||
pkgs = $(shell $(GO) list ./... | grep -v /vendor/) | ||
|
||
PREFIX ?= $(shell pwd) | ||
BIN_DIR ?= $(shell pwd) | ||
DOCKER_IMAGE_NAME ?= nginx-vts-exporter | ||
DOCKER_IMAGE_TAG ?= $(subst /,-,$(shell git rev-parse --abbrev-ref HEAD)) | ||
TAG := $(shell echo `if [ "$(TRAVIS_BRANCH)" = "master" ] || [ "$(TRAVIS_BRANCH)" = "" ] ; then echo "latest"; else echo $(TRAVIS_BRANCH) ; fi`) | ||
|
||
all: format build test | ||
|
||
style: | ||
@echo ">> checking code style" | ||
@! gofmt -d $(shell find . -path ./vendor -prune -o -name '*.go' -print) | grep '^' | ||
|
||
test: | ||
@echo ">> running tests" | ||
@$(GO) test -short $(pkgs) | ||
|
||
format: | ||
@echo ">> formatting code" | ||
@$(GO) fmt $(pkgs) | ||
|
||
vet: | ||
@echo ">> vetting code" | ||
@$(GO) vet $(pkgs) | ||
|
||
build: promu | ||
@echo ">> building binaries" | ||
@$(PROMU) build --prefix $(PREFIX) | ||
|
||
crossbuild: promu | ||
@echo ">> crossbuilding binaries" | ||
@$(PROMU) crossbuild | ||
|
||
tarball: promu | ||
@echo ">> building release tarball" | ||
@$(PROMU) tarball --prefix $(PREFIX) $(BIN_DIR) | ||
|
||
docker: | ||
@echo ">> building docker image" | ||
@docker build -t "$(DOCKER_IMAGE_NAME):$(DOCKER_IMAGE_TAG)" . | ||
|
||
push: | ||
@echo ">> pushing docker image, $(DOCKER_USER),$(DOCKER_IMAGE_NAME),$(TAG)" | ||
@echo $(DOCKER_PASS) | docker login -u "$(DOCKER_USER)" --password-stdin | ||
@docker tag "$(DOCKER_IMAGE_NAME):$(DOCKER_IMAGE_TAG)" "$(DOCKER_USER)/$(DOCKER_IMAGE_NAME):$(TAG)" | ||
@docker push "$(DOCKER_USER)/$(DOCKER_IMAGE_NAME):$(TAG)" | ||
|
||
release: promu github-release | ||
@echo ">> pushing binary to github with ghr" | ||
@$(PROMU) crossbuild tarballs | ||
@$(PROMU) release .tarballs | ||
|
||
promu: | ||
@GOOS=$(shell uname -s | tr A-Z a-z) \ | ||
GOARCH=$(subst x86_64,amd64,$(patsubst i%86,386,$(shell uname -m))) \ | ||
$(GO) get -u github.com/prometheus/promu | ||
|
||
github-release: | ||
@GOOS=$(shell uname -s | tr A-Z a-z) \ | ||
GOARCH=$(subst x86_64,amd64,$(patsubst i%86,386,$(shell uname -m))) \ | ||
$(GO) get -u github.com/aktau/github-release | ||
|
||
.PHONY: all style format build test vet tarball docker promu | ||
GO := GO111MODULE=on go | ||
PROMU := $(GOPATH)/bin/promu | ||
pkgs = $(shell $(GO) list ./... | grep -v /vendor/) | ||
|
||
PREFIX ?= $(shell pwd) | ||
BIN_DIR ?= $(shell pwd) | ||
DOCKER_IMAGE_NAME ?= nginx-vts-exporter | ||
DOCKER_IMAGE_TAG ?= $(subst /,-,$(shell git rev-parse --abbrev-ref HEAD)) | ||
TAG := $(shell echo `if [ "$(TRAVIS_BRANCH)" = "master" ] || [ "$(TRAVIS_BRANCH)" = "" ] ; then echo "latest"; else echo $(TRAVIS_BRANCH) ; fi`) | ||
|
||
all: format build test | ||
|
||
style: | ||
@echo ">> checking code style" | ||
@! gofmt -d $(shell find . -path ./vendor -prune -o -name '*.go' -print) | grep '^' | ||
|
||
test: | ||
@echo ">> running tests" | ||
@$(GO) test -short $(pkgs) | ||
|
||
format: | ||
@echo ">> formatting code" | ||
@$(GO) fmt $(pkgs) | ||
|
||
vet: | ||
@echo ">> vetting code" | ||
@$(GO) vet $(pkgs) | ||
|
||
build: promu | ||
@echo ">> building binaries" | ||
@$(PROMU) build --prefix $(PREFIX) | ||
|
||
crossbuild: promu | ||
@echo ">> crossbuilding binaries" | ||
@$(PROMU) crossbuild | ||
|
||
tarball: promu | ||
@echo ">> building release tarball" | ||
@$(PROMU) tarball --prefix $(PREFIX) $(BIN_DIR) | ||
|
||
docker: | ||
@echo ">> building docker image" | ||
@docker build -t "$(DOCKER_IMAGE_NAME):$(DOCKER_IMAGE_TAG)" . | ||
|
||
push: | ||
@echo ">> pushing docker image, $(DOCKER_USER),$(DOCKER_IMAGE_NAME),$(TAG)" | ||
@echo $(DOCKER_PASS) | docker login -u "$(DOCKER_USER)" --password-stdin | ||
@docker tag "$(DOCKER_IMAGE_NAME):$(DOCKER_IMAGE_TAG)" "$(DOCKER_USER)/$(DOCKER_IMAGE_NAME):$(TAG)" | ||
@docker push "$(DOCKER_USER)/$(DOCKER_IMAGE_NAME):$(TAG)" | ||
|
||
release: promu github-release | ||
@echo ">> pushing binary to github with ghr" | ||
@$(PROMU) crossbuild tarballs | ||
@$(PROMU) release .tarballs | ||
|
||
promu: | ||
@GOOS=$(shell uname -s | tr A-Z a-z) \ | ||
GOARCH=$(subst x86_64,amd64,$(patsubst i%86,386,$(shell uname -m))) \ | ||
$(GO) get -u github.com/prometheus/promu | ||
|
||
github-release: | ||
@GOOS=$(shell uname -s | tr A-Z a-z) \ | ||
GOARCH=$(subst x86_64,amd64,$(patsubst i%86,386,$(shell uname -m))) \ | ||
$(GO) get -u github.com/aktau/github-release | ||
|
||
.PHONY: all style format build test vet tarball docker promu |