-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
53 lines (45 loc) · 1.48 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
45
46
47
48
49
50
51
52
53
# Project config
PROJECT_NAME=semantic-version
PROJECT_URL=https://github.com/indece-official/semantic-version
BUILD_DATE=$(shell date +%Y%m%d.%H%M%S)
BUILD_VERSION ?= SNAPSHOT
# Go parameters
GOCMD=go
GOPATH=$(shell $(GOCMD) env GOPATH))
GOBUILD=$(GOCMD) build
GOGENERATE=$(GOCMD) generate
GOCLEAN=$(GOCMD) clean
GOTEST=$(GOCMD) test
GOGET=$(GOCMD) get
DIR_SOURCE=./src
DIR_DIST=./dist
BINARY_NAME_LINUX64=$(PROJECT_NAME)-$(BUILD_VERSION)-linux-amd64
SHA256_NAME_LINUX64=$(PROJECT_NAME)-$(BUILD_VERSION)-linux-amd64.sha256
LDFLAGS :=
LDFLAGS := $(LDFLAGS) -X main.ProjectName=$(PROJECT_NAME)
LDFLAGS := $(LDFLAGS) -X main.ProjectURL=$(PROJECT_URL)
LDFLAGS := $(LDFLAGS) -X main.BuildDate=$(BUILD_DATE)
LDFLAGS := $(LDFLAGS) -X main.BuildVersion=$(BUILD_VERSION)
all: test build test_integration
build:
mkdir -p $(DIR_DIST)/bin
CGO_ENABLED=0 $(GOBUILD) -ldflags "$(LDFLAGS)" -o $(DIR_DIST)/bin/$(BINARY_NAME_LINUX64) -tags=prod -v $(DIR_SOURCE)/main
(cd $(DIR_DIST)/bin && sha256sum $(BINARY_NAME_LINUX64) > $(SHA256_NAME_LINUX64))
test:
mkdir -p $(DIR_DIST)
ifeq ($(OUTPUT),json)
$(GOTEST) -v ./... -cover -coverprofile $(DIR_DIST)/cover.out -json > $(DIR_DIST)/test.json
else
$(GOTEST) -v ./... -cover
endif
clean:
#$(GOCLEAN)
rm -rf $(DIR_OUT)
run:
$(GOBUILD) -o $(BINARY_NAME) -v ./...
./$(BINARY_NAME)
deps:
echo test
#$(GOGET) -d -v ./...
test_integration:
(cd ./test/ && PROGRAM=../dist/bin/$(BINARY_NAME_LINUX64) ./integration.sh)