forked from opencurve/curve-csi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
46 lines (36 loc) · 1.16 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
CSI_IMAGE_NAME?=curvecsi/curve-csi
# VERSION is the git tag
VERSION?=$(shell git describe --tags --match "v*")
GO_PROJECT=github.com/opencurve/curve-csi
GIT_COMMIT=$(shell git rev-parse --short HEAD)
BUILD_TIME=$(shell date '+%Y%m%d.%H%M%S.%Z')
# go build flags
LDFLAGS ?=
LDFLAGS += -X $(GO_PROJECT)/pkg/util.Version=$(VERSION)
LDFLAGS += -X $(GO_PROJECT)/pkg/util.GitCommit=$(GIT_COMMIT)
LDFLAGS += -X $(GO_PROJECT)/pkg/util.BuildTime=$(BUILD_TIME)
# test args
TESTARGS_DEFAULT := "-v"
export TESTARGS ?= $(TESTARGS_DEFAULT)
.PHONY: all
all: build
.PHONY: test
test:
go test -tags=unit $(shell go list ./...) $(TESTARGS)
.PHONY: build
build:
if [ ! -d ./vendor ]; then (go mod tidy && go mod vendor); fi
CGO_ENABLED=0 GOOS=linux go build -mod vendor -a -ldflags "$(LDFLAGS) -extldflags '-static'" -o _output/curve-csi ./cmd/curve-csi.go
.PHONY: release-image
release-image:
docker build --network host -f ./build/curve-csi/Dockerfile \
--build-arg VERSION="$(VERSION)" \
-t $(CSI_IMAGE_NAME):$(VERSION) .
.PHONY: push-image
push-image:
docker push $(CSI_IMAGE_NAME):$(VERSION)
.PHONY: clean
clean:
go clean -r -x
rm -f _output/curve-csi
rm -f images/curve-csi