-
Notifications
You must be signed in to change notification settings - Fork 13
/
Makefile
101 lines (83 loc) · 3.39 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
92
93
94
95
96
97
98
99
100
101
# Setting SHELL to bash allows bash commands to be executed by recipes.
# Options are set to exit when a recipe line exits non-zero or a piped command fails.
SHELL = /usr/bin/env bash -O globstar -o pipefail
.SHELLFLAGS = -ec
GO ?= go
GO_BUILD ?= $(GO) build --trimpath
GO_TEST = $(GO) test
KUBE_CLIENT ?= kubectl
KUTTL_TEST ?= kuttl test
##@ General
# The help target prints out all targets with their descriptions organized
# beneath their categories. The categories are represented by '##@' and the
# target descriptions by '##'. The awk command is responsible for reading the
# entire set of makefiles included in this invocation, looking for lines of the
# file as 'target: ## some-help-text', and then formatting the target and help.
# Each line beginning with '##@ some-text' is formatted as a category.
.PHONY: help
help: ALIGN=18
help: ## Display this help
@awk ' \
BEGIN { FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n" } \
/^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-$(ALIGN)s\033[0m %s\n", $$1, $$2 } \
/^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } \
' $(MAKEFILE_LIST)
##@ Development
.PHONY: all
all: check build
bin/kubectl-pgo-%: ## Build the binary
bin/kubectl-pgo-%: go.* $(shell ls -1 cmd/**/*.go internal/**/*.go)
GOOS=$(word 1,$(subst -, ,$*)) GOARCH=$(word 2,$(subst -, ,$*)) $(GO_BUILD) -o $@ ./cmd/kubectl-pgo
.PHONY: build
build: ## Build the executable (requires Go)
build: bin/kubectl-pgo-$(subst $(eval) ,-,$(shell $(GO) env GOOS GOARCH))
ln -fs $(notdir $<) ./bin/kubectl-pgo
.PHONY: check
check: ## Run tests
$(GO_TEST) -cover ./...
# Expects operator to be running
.PHONY: check-kuttl
check-kuttl: PATH := $(PWD)/bin/kubectl-pgo:$(PATH)
check-kuttl:
${KUBE_CLIENT} ${KUTTL_TEST} \
--config testing/kuttl/kuttl-test.yaml
.PHONY: clean
clean: ## Remove files generated by other targets
rm -f ./bin/kubectl-pgo ./bin/kubectl-pgo-*-*
.PHONY: cli-docs
cli-docs: ## generate cli documenation
@echo "Generating the docs"
rm -rf docs/content/reference && mkdir docs/content/reference
cd docs/content/reference && $(GO) run -tags docs -exec 'env HOME=$$HOME' ../../../hack/generate-docs.go
@echo "Configuring the _index.md file with the appropriate header"
NL=$$'\n'; sed -e "1,/---/ { /^title:/ { \
a \\$${NL}aliases:\\$${NL}- /reference/pgo\\$${NL}weight: 100$${NL}; \
c \\$${NL}title: Command Reference$${NL}; \
}; }" \
docs/content/reference/pgo.md > \
docs/content/reference/_index.md
rm docs/content/reference/pgo.md
@echo "Break out a separate code block for \`Example output\`"
for filename in $(wildcard docs/content/reference/pgo_*.md); do \
NL=$$'\n'; \
sed -i "s/### Example output/\`\`\`\\$${NL}### Example output\\$${NL}\`\`\`/g" $${filename}; \
done
.PHONY: check-cli-docs
check-cli-docs: cli-docs
git diff --exit-code -- docs/content/reference/
.PHONY: prep-release
prep-release:
@echo "Replace $(OLD_VERSION) with $(NEW_VERSION)"
sed -i "s/$${OLD_VERSION}/$${NEW_VERSION}/" internal/cmd/client_version.go docs/config.toml
touch docs/content/releases/$(NEW_VERSION).md
.PHONY: prep-release-docs
prep-release-docs: prep-release cli-docs
.PHONY: tag
tag:
@echo "Tagging and pushing as v$(NEW_VERSION)"
@echo -n "Are you sure? [y/N] " && read ans && [ $${ans:-N} = y ]
git tag "v$(NEW_VERSION)"
git push origin "v$(NEW_VERSION)"
git tag "d$(NEW_VERSION)"
git push origin "d$(NEW_VERSION)"
@echo "Make release from tag "v$(NEW_VERSION)"