-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile
91 lines (71 loc) · 2.55 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
GO=go
GO_MAJOR_VERSION = $(shell $(GO) version | cut -c 14- | cut -d' ' -f1 | cut -d'.' -f1)
GO_MINOR_VERSION = $(shell $(GO) version | cut -c 14- | cut -d' ' -f1 | cut -d'.' -f2)
MINIMUM_SUPPORTED_GO_MAJOR_VERSION = 1
MINIMUM_SUPPORTED_GO_MINOR_VERSION = 20
MAXIMUM_SUPPORTED_GO_MINOR_VERSION = 20
GO_VERSION_VALIDATION_ERR_MSG = Golang version is not supported, please update to least $(MINIMUM_SUPPORTED_GO_MAJOR_VERSION).$(MINIMUM_SUPPORTED_GO_MINOR_VERSION)
.DEFAULT_GOAL := install
GOBIN := $(shell pwd)/bin
PATH := $(GOBIN):$(PATH)
IMAGE_REGISTRY ?= localhost
IMAGE_NAME ?= datactl
IMAGE_TAG ?= latest
export PATH
export GOBIN
validate-go-version: ## Validates the installed version of go against Mattermost's minimum requirement.
@if [ $(GO_MAJOR_VERSION) -gt $(MINIMUM_SUPPORTED_GO_MAJOR_VERSION) ]; then \
exit 0 ;\
elif [ $(GO_MAJOR_VERSION) -lt $(MINIMUM_SUPPORTED_GO_MAJOR_VERSION) ]; then \
echo '$(GO_VERSION_VALIDATION_ERR_MSG)';\
exit 1; \
elif [ $(GO_MINOR_VERSION) -lt $(MINIMUM_SUPPORTED_GO_MINOR_VERSION) ] ; then \
echo '$(GO_VERSION_VALIDATION_ERR_MSG)';\
exit 1; \
elif [ $(GO_MINOR_VERSION) -gt $(MAXIMUM_SUPPORTED_GO_MINOR_VERSION) ] ; then \
echo '$(GO_VERSION_VALIDATION_ERR_MSG)';\
exit 1; \
fi
.PHONY: tag
tag:
git tag $(svu next)
.PHONY: licenses
licenses:
find . -type f -name "*.go" | xargs addlicense -c "IBM Corporation."
.PHONY: mod
mod:
go mod tidy
go mod download
.PHONY: test
test:
ginkgo -r --randomize-all --randomize-suites --fail-on-pending --cover --trace --race --show-node-events
.PHONY: generate
generate: validate-go-version tools
go generate ./...
.PHONY: install
install: goreleaser
goreleaser build --skip-validate --single-target --id datactl --clean
cp $(shell find dist -type f -name datactl | xargs) /usr/local/bin/
.PHONY: test-release
test-release: goreleaser
goreleaser release --skip-publish --skip-announce --skip-validate --clean
.PHONY: release
release: goreleaser
goreleaser release --clean
.PHONY: goreleaser
goreleaser:
go install github.com/goreleaser/[email protected]
tools:
go mod download
go install "k8s.io/code-generator/cmd/[email protected]"
go install "sigs.k8s.io/controller-tools/cmd/[email protected]"
go-licenses:
go install "github.com/google/go-licenses@latest"
licenses-check: go-licenses
go-licenses check --include_tests ./...
licenses-save: go-licenses
go-licenses save --include_tests ./... --save_path=licenses
docker-build:
docker build -t $(IMAGE_REGISTRY)/$(IMAGE_NAME):$(IMAGE_TAG) .
docker-push:
docker push $(IMAGE_REGISTRY)/$(IMAGE_NAME):$(IMAGE_TAG)