diff --git a/Makefile b/Makefile index 7fc9574..3c3ece4 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,6 @@ GITHUB_ORG = QubitProducts GITHUB_REPO = exporter_exporter +VERSION = 0.3.0 DOCKER_REGISTRY = qubitproducts DOCKER_NAME = exporter_exporter @@ -12,11 +13,10 @@ FIRST_GOPATH := $(firstword $(subst :, ,$(GOPATH))) FILES = $(shell find . -name '*.go' | grep -v vendor) PREFIX ?= $(shell pwd) BIN_DIR ?= $(shell pwd) -VERSION ?= $(shell cat VERSION) PACKAGE_TARGET = deb PACKAGE_NAME = expexp -PACKAGE_VERSION = $(shell cat VERSION) +PACKAGE_VERSION = $(VERSION) PACKAGE_REVISION = 3 PACKAGE_ARCH = amd64 PACKAGE_MAINTAINER = tristan@qubit.com @@ -52,50 +52,8 @@ vet: echo ">> vetting code" $(GO) vet $(pkgs) -vendor: go.mod go.sum - go mod vendor - -.PHONY: build -build: vendor promu - echo ">> building binaries" - ./promu build --prefix $(PREFIX) - -.PHONY: tarball -tarball: promu - echo ">> building release tarball" - ./promu tarball --prefix $(PREFIX) $(BIN_DIR) - -.PHONY: promu -promu: - echo ">> fetching promu" - GOOS=$(shell uname -s | tr A-Z a-z) \ - GOARCH=$(subst x86_64,amd64,$(patsubst i%86,386,$(shell uname -m))) \ - $(GO) build -o promu github.com/prometheus/promu - -.PHONY: github-release -github-release: - echo ">> fetching github-release" - GOOS=$(shell uname -s | tr A-Z a-z) \ - GOARCH=$(subst x86_64,amd64,$(patsubst i%86,386,$(shell uname -m))) \ - $(GO) build -o github-release github.com/aktau/github-release - -.PHONY: release -release: promu github-release package - echo ">> crossbuilding binaries" - ./promu crossbuild - echo ">> crossbuilding tarballs" - ./promu crossbuild tarballs - echo ">> creating github release" - ./github-release release -u $(GITHUB_ORG) -r $(GITHUB_REPO) --tag v$(VERSION) --name v$(VERSION) - echo ">> uploading artifacts" - ./promu release .tarballs - echo ">> uploading deb" - ./github-release upload -u $(GITHUB_ORG) -r $(GITHUB_REPO) --tag v$(VERSION) --name $(PACKAGE_FILE) --file $(PACKAGE_FILE) - .PHONY: prepare-package clean-package package -prepare-package: clean-package - echo ">> crossbuilding binaries" - ./promu crossbuild -p linux/amd64 +prepare-package: clean-package build/exporter_exporter-$(VERSION).linux-amd64/exporter_exporter mkdir -p dist/usr/local/bin mkdir -p dist/etc/init mkdir -p dist/etc/default @@ -135,3 +93,55 @@ release-docker: build-docker docker push $(DOCKER_IMAGE) docker tag $(DOCKER_IMAGE) $(DOCKER_IMAGE_LATEST) docker push $(DOCKER_IMAGE_LATEST) + +LDFLAGS = -X main.Version=$(VERSION) \ + -X main.Branch=$(BRANCH) \ + -X main.Revision=$(REVISION) \ + -X main.BuildUser=$(BUILDUSER) \ + -X main.BuildDate=$(BUILDDATE) + +build/expoter_exporter-$(VERSION).windows-amd64/exporter_exporter.exe: $(SRCS) version.go + GOOS=$* GOARCH=amd64 $(GO) go build \ + -ldflags "$(LDFLAGS)" \ + -o $@ \ + . + +build/exporter_exporter-$(VERSION).%-amd64/exporter_exporter: $(SRCS) version.go + GOOS=$* GOARCH=amd64 $(GO) build \ + -ldflags "$(LDFLAGS)" \ + -o $@ \ + . + +build/exporter_exporter-$(VERSION).windows-amd64.tar.gz: build/exporter_exporter-$(VERSION).windows-amd64/exporter_exporter.exe + cd build && \ + tar cfzv exporter_exporter-$(VERSION).windows-amd64.tar.gz exporter_exporter-$(VERSION).windows-amd64 + +build/exporter_exporter-$(VERSION).%-amd64.tar.gz: build/exporter_exporter-$(VERSION).%-amd64/exporter_exporter + cd build && \ + tar cfzv exporter_exporter-$(VERSION).$*-amd64.tar.gz exporter_exporter-$(VERSION).$*-amd64 + +package-release: build/exporter_exporter-$(VERSION).%-amd64.tar.gz $(PACKAGE_FILE) + go run github.com/aktau/github-release upload \ + -u $(GITHUB_ORG) \ + -r $(GITHUB_REPO) \ + --tag v$(VERSION) \ + --name $(PACKAGE_FILE) \ + --file $(PACKAGE_FILE) + +release-%: build/exporter_exporter-$(VERSION).%-amd64.tar.gz $(PACKAGE_FILE) + go run github.com/aktau/github-release upload \ + -u $(GITHUB_USER) \ + -r $(GITHUB_REPO) \ + --tag v$(VERSION) \ + --name exporter_exporter-$(VERSION).$*-amd64.tar.gz \ + -f ./build/exporter_exporter-$(VERSION).$*-amd64.tar.gz + +release: + git tag v$(VERSION) + git push origin v$(VERSION) + go run github.com/aktau/github-release release \ + -u $(GITHUB_USER) \ + -r $(GITHUB_REPO) \ + --tag v$(VERSION) \ + --name v$(VERSION) + make release-darwin release-linux release-windows package-release diff --git a/VERSION b/VERSION deleted file mode 100644 index 1866a36..0000000 --- a/VERSION +++ /dev/null @@ -1 +0,0 @@ -0.2.9 diff --git a/go.mod b/go.mod index 1e949f3..b8f192b 100644 --- a/go.mod +++ b/go.mod @@ -5,19 +5,21 @@ require ( github.com/dustin/go-humanize v1.0.0 // indirect github.com/golang/protobuf v1.3.1 // indirect github.com/konsorten/go-windows-terminal-sequences v1.0.2 // indirect + github.com/kr/pretty v0.1.0 // indirect github.com/pkg/errors v0.8.1 github.com/prometheus/client_golang v0.9.2 github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90 github.com/prometheus/common v0.2.0 github.com/prometheus/procfs v0.0.0-20190322151404-55ae3d9d5573 // indirect - github.com/prometheus/promu v0.3.0 github.com/sirupsen/logrus v1.4.0 // indirect + github.com/stretchr/testify v1.3.0 // indirect github.com/tomnomnom/linkheader v0.0.0-20180905144013-02ca5825eb80 // indirect github.com/voxelbrain/goptions v0.0.0-20180630082107-58cddc247ea2 // indirect golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c // indirect golang.org/x/net v0.0.0-20190327214358-63eda1eb0650 golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6 golang.org/x/sys v0.0.0-20190322080309-f49334f85ddc // indirect + gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 // indirect gopkg.in/yaml.v2 v2.2.2 ) diff --git a/go.sum b/go.sum index eba0c9f..bb49ff8 100644 --- a/go.sum +++ b/go.sum @@ -47,11 +47,8 @@ github.com/prometheus/common v0.2.0 h1:kUZDBDTdBVBYBj5Tmh2NZLlF60mfjA27rM34b+cVw github.com/prometheus/common v0.2.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.0-20181204211112-1dc9a6cbc91a/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= -github.com/prometheus/procfs v0.0.0-20190209105433-f8d8b3f739bd/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= github.com/prometheus/procfs v0.0.0-20190322151404-55ae3d9d5573 h1:gAuD3LIrjkoOOPLlhGlZWZXztrQII9a9kT6HS5jFtSY= github.com/prometheus/procfs v0.0.0-20190322151404-55ae3d9d5573/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= -github.com/prometheus/promu v0.3.0 h1:ecIZ1FIjQ+PAneA6g0KpUa7FDimozQtDjzI2rW0Pmh0= -github.com/prometheus/promu v0.3.0/go.mod h1:+NXvSS3J95z3ZmFZP0DXUt+g/I6zyK1CQoBJKkjzX4k= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= github.com/sirupsen/logrus v1.4.0 h1:yKenngtzGh+cUSSh6GWbxW2abRqhYUSR/t/6+2QqNvE= github.com/sirupsen/logrus v1.4.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= diff --git a/tools.go b/tools.go index 4917b92..29a59be 100644 --- a/tools.go +++ b/tools.go @@ -4,5 +4,4 @@ package tools import ( _ "github.com/aktau/github-release" - _ "github.com/prometheus/promu" )