-
Notifications
You must be signed in to change notification settings - Fork 40
/
Makefile
45 lines (32 loc) · 900 Bytes
/
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
45
PKG := github.com/profefe/profefe
GO ?= go
LDFLAGS :=
GOFLAGS :=
TESTFLAGS :=
DOCKER ?= docker
BUILDTIME := $(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
GITSHA := $(shell git rev-parse --short HEAD 2>/dev/null)
ifndef VERSION
VERSION := git-$(GITSHA)
endif
LDFLAGS += -X $(PKG)/version.Version=$(VERSION)
LDFLAGS += -X $(PKG)/version.Commit=$(GITSHA)
LDFLAGS += -X $(PKG)/version.BuildTime=$(BUILDTIME)
DOCKER_IMAGE := profefe/profefe
DOCKER_IMAGE_TAG := $(VERSION)
BUILDDIR := BUILD
BUILD.go = $(GO) build $(GOFLAGS)
TEST.go = $(GO) test $(TESTFLAGS)
.PHONY: all
all: build-profefe
build-%:
$(BUILD.go) -ldflags "$(LDFLAGS)" -o $(BUILDDIR)/$(*) ./cmd/$(*)
.PHONY: deploy
deploy:
.PHONY: test
test:
$(TEST.go) -ldflags "$(LDFLAGS)" ./...
.PHONY: docker-image
docker-image:
GITSHA=$(GITSHA) VERSION=$(VERSION) \
./scripts/ci_build_image.sh $(DOCKER_IMAGE) $(DOCKER_IMAGE_TAG)