mirror of
https://github.com/ribbybibby/ssl_exporter.git
synced 2024-11-30 08:36:46 +02:00
8ef058ebfb
- Don't use promu and upstream Prometheus Makefiles. I don't have a clear process for keeping them in sync with the upstream and I don't think they add much value. - Use the same ldflags in goreleaser and the Makefile - Run goreleaser from the Makefile so custom env vars can be injected - Update to go 1.14
66 lines
2.0 KiB
Makefile
66 lines
2.0 KiB
Makefile
GOPATH := $(shell go env GOPATH)
|
|
|
|
BIN_DIR ?= $(shell pwd)/bin
|
|
BIN_NAME ?= ssl_exporter
|
|
DOCKER_IMAGE_NAME ?= ssl-exporter
|
|
DOCKER_IMAGE_TAG ?= $(subst /,-,$(shell git rev-parse --abbrev-ref HEAD))
|
|
|
|
# Race detector is only supported on amd64.
|
|
RACE := $(shell test $$(go env GOARCH) != "amd64" || (echo "-race"))
|
|
|
|
export APP_HOST ?= $(shell hostname)
|
|
export APP_BRANCH ?= $(shell git describe --all --contains --dirty HEAD)
|
|
export APP_VERSION := $(shell cat VERSION)
|
|
export APP_REVISION := $(shell git rev-parse HEAD)
|
|
export APP_USER := $(shell id -u --name)
|
|
export APP_BUILD_DATE := $(shell date '+%Y%m%d-%H:%M:%S')
|
|
|
|
all: clean format vet build test
|
|
|
|
style:
|
|
@echo ">> checking code style"
|
|
@! gofmt -s -d $(shell find . -path ./vendor -prune -o -name '*.go' -print) | grep '^'
|
|
|
|
test:
|
|
@echo ">> running tests"
|
|
go test -short -v $(RACE) ./...
|
|
|
|
format:
|
|
@echo ">> formatting code"
|
|
@go fmt ./...
|
|
|
|
vet:
|
|
@echo ">> vetting code"
|
|
@go vet $(pkgs)
|
|
|
|
build:
|
|
@echo ">> building binary"
|
|
@CGO_ENABLED=0 go build -v \
|
|
-ldflags "-X github.com/prometheus/common/version.Version=$(APP_VERSION) \
|
|
-X github.com/prometheus/common/version.Revision=$(APP_REVISION) \
|
|
-X github.com/prometheus/common/version.Branch=$(APP_BRANCH) \
|
|
-X github.com/prometheus/common/version.BuildUser=$(APP_USER)@$(APP_HOST) \
|
|
-X github.com/prometheus/common/version.BuildDate=$(APP_BUILD_DATE)\
|
|
" \
|
|
-o $(BIN_NAME) .
|
|
|
|
docker:
|
|
@echo ">> building docker image"
|
|
@docker build -t "$(DOCKER_IMAGE_NAME):$(DOCKER_IMAGE_TAG)" .
|
|
|
|
$(GOPATH)/bin/goreleaser:
|
|
@curl -sfL https://install.goreleaser.com/github.com/goreleaser/goreleaser.sh | BINDIR=$(GOPATH)/bin sh
|
|
|
|
snapshot: $(GOPATH)/bin/goreleaser
|
|
@echo ">> building snapshot"
|
|
@$(GOPATH)/bin/goreleaser --snapshot --skip-sign --skip-validate --skip-publish --rm-dist
|
|
|
|
release: $(GOPATH)/bin/goreleaser
|
|
@$(GOPATH)/bin/goreleaser release
|
|
|
|
clean:
|
|
@echo ">> removing build artifacts"
|
|
@rm -Rf $(BIN_DIR)
|
|
@rm -Rf $(BIN_NAME)
|
|
|
|
.PHONY: all style test format vet build docker snapshot release clean |