-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
44 lines (35 loc) · 804 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
VERSION_FILE=VERSION
SRC_PKGS=$(shell go list ./... | grep -v vendor)
ifeq ($(strip $(NO_REV)),)
REV=$(shell git rev-parse --short HEAD)
endif
ifeq ($(BUILD_VERSION),)
VERSION=$(shell cat $(VERSION_FILE))
ifeq ($(strip $(REV)),)
BUILD_VERSION=$(VERSION)
else
BUILD_VERSION=$(VERSION)-$(REV)
endif
endif
IMAGE_REPO=dakr/csense
ifeq ($(IMAGE_NAME),)
IMAGE_NAME=$(IMAGE_REPO):$(BUILD_VERSION)
endif
.PHONY: clean image test
all: compile
clean:
go clean ./...
rm dist
compile:
go build -ldflags "-X main.appVersion=$(BUILD_VERSION)" .
dist:
GOOS=linux go build -ldflags "-X main.appVersion=$(BUILD_VERSION)" -o dist .
image:
docker build -t $(IMAGE_NAME) .
docker tag $(IMAGE_NAME) $(IMAGE_REPO):latest
test:
set -e;
for pkg in $(SRC_PKGS); \
do \
go test -v $$pkg; \
done