forked from nicolastakashi/cole
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
44 lines (33 loc) · 1.17 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
RELEASE_VERSION ?=$(shell cat VERSION)
RELEASE=1
REVISION ?= $(shell git rev-parse HEAD)
BRANCH ?= $(shell git rev-parse --abbrev-ref HEAD)
BINARY_FOLDER=bin
BINARY_NAME=cole
ARTIFACT_NAME=ntakashi/$(BINARY_NAME)
GOCMD=go
GOMAIN=main.go
GOBUILD=$(GOCMD) build
ENVVARS=GOOS=linux CGO_ENABLED=0
LDFLAGS=-w -extldflags "-static" \
-X github.com/prometheus/common/version.Version=$(RELEASE_VERSION) \
-X github.com/prometheus/common/version.Revision=$(REVISION) \
-X github.com/prometheus/common/version.Branch=$(BRANCH) \
-X github.com/prometheus/common/version.BuildUser=$(shell whoami) \
-X "github.com/prometheus/common/version.BuildDate=$(shell date -u)"
docker-build:
@DOCKER_BUILDKIT=1 docker build -t ${ARTIFACT_NAME}:${RELEASE_VERSION} -f ./build/package/Dockerfile --progress=plain .
docker-push:
@DOCKER_BUILDKIT=1 docker push $(ARTIFACT_NAME):${RELEASE_VERSION}
build:
$(ENVVARS) $(GOCMD) build -ldflags '$(LDFLAGS)' -o $(BINARY_FOLDER)/$(BINARY_NAME) -v $(GOMAIN)
deps:
$(ENVVARS) $(GOCMD) mod download
fmt:
$(ENVVARS) $(GOCMD) fmt -x ./...
vet:
$(ENVVARS) $(GOCMD) vet ./...
tests:
$(ENVVARS) $(GOCMD) test ./...
all: fmt vet tests deps build
.PHONY: build