-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
49 lines (37 loc) · 1.13 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
GO := go
GOOS := linux
GO_ENVS := CGO_ENABLED=0 GOOS=${GOOS} GOPROXY=direct GOSUMDB=off
GO_TOOL_ENVS := GO111MODULE=off CGO_ENABLED=0 GOPROXY=direct GOSUMDB=off
BUILD_TIME = $(shell date -u +%Y-%m-%dT%H:%M:%SZ)
GIT_SHA := $(shell git rev-parse HEAD 2>/dev/null)
VERSION := $(shell cat VERSION | tr -d '\n')
ENV := dev
GO_LD_FLAGS = \
-X main.BuildTime=${BUILD_TIME} \
-X main.GitSHA=${GIT_SHA} \
-X main.Version=${VERSION} \
-X main.Env=${ENV}
GO_BUILD_FLAGS = -v -ldflags='${GO_LD_FLAGS}'
BINARIES = inspector
VERSION_NAME = ${BINARIES}-${VERSION}
DIST := dist/${VERSION_NAME}
TAR = ${VERSION_NAME}.tar.gz
PKGS = $(shell ${GO} list ./... | tr '\n' ',')
EXEC := ${DIST}/${BINARIES}
.PHONY: all dep build clean pkg
all: clean pkg
build: dep
env "PATH=${PATH}:$(shell go env GOPATH)/bin" ${GO_TOOL_ENVS} ${GO} generate ./...
env ${GO_ENVS} ${GO} build ${GO_BUILD_FLAGS} -o ${EXEC} .
test -f config/config.yaml
mkdir -p ${DIST}/config/
cp -f config/config.yaml ${DIST}/config/config.yaml
clean:
rm -rf ${TAR}
rm -rf dist
pkg: build
chmod a+x ${EXEC}
tar -zcf ${TAR} -C dist ${VERSION_NAME}
@echo "Build successfully"
fmt:
goimports -w .