New release process using docker, circleci and a centralized

building tool
This commit is contained in:
Steve Durrheimer 2016-01-24 23:38:06 +01:00
commit 158200fd49
No known key found for this signature in database
GPG key ID: 5435BD02508176B7
9 changed files with 158 additions and 26 deletions

View file

@ -11,18 +11,50 @@
# See the License for the specific language governing permissions and
# limitations under the License.
VERSION := 0.12.0rc3
TARGET := node_exporter
GO := GO15VENDOREXPERIMENT=1 go
PROMU := $(GOPATH)/bin/promu
pkgs = $(shell $(GO) list ./... | grep -v /vendor/)
REVISION := $(shell git rev-parse --short HEAD 2> /dev/null || echo 'unknown')
BRANCH := $(shell git rev-parse --abbrev-ref HEAD 2> /dev/null || echo 'unknown')
PREFIX ?= $(shell pwd)
BIN_DIR ?= $(shell pwd)
DOCKER_IMAGE_NAME ?= node-exporter
DOCKER_IMAGE_TAG ?= $(subst /,-,$(shell git rev-parse --abbrev-ref HEAD))
REPO_PATH := "github.com/prometheus/node_exporter"
LDFLAGS := -X main.Version=$(VERSION)
LDFLAGS += -X $(REPO_PATH)/collector.Version=$(VERSION)
LDFLAGS += -X $(REPO_PATH)/collector.Revision=$(REVISION)
LDFLAGS += -X $(REPO_PATH)/collector.Branch=$(BRANCH)
GOFLAGS := -ldflags "$(LDFLAGS)"
all: format build test
include Makefile.COMMON
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)
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)" .
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
.PHONY: all style format build test vet tarball docker promu