-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
79 lines (67 loc) · 1.88 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
VERSION := "unknown"
BIN := $(shell pwd)/bin
NODE_BIN := $(shell pwd)/tests/node_modules/.bin
export PATH := $(BIN):$(NODE_BIN):$(PATH)
.PHONY: bins
bins:
@echo "Building binaries..."
@go build -o $(BIN) ./cmd/...
@echo "Binaries built."
.PHONY: tools
tools:
@echo "Installing tools..."
@./tests/tools/tools.sh
@cd tests && pnpm install
@echo "Tools installed."
.PHONY: generate
generate: tools bins
@echo "Generating code..."
@go generate ./...
@cd tests && go generate ./...
@echo "Code generated."
.PHONY: test test.unit test.generation test.integration
test: test.unit test.generation
test.unit:
@echo "Running unit tests..."
@go test -v ./...
@echo "Unit tests passed."
test.generation: generate
@echo "Running tests..."
@cd tests && go test -v ./...
@echo "Tests passed."
test.integration: generate
@echo "Running integration tests..."
@cd tests && pnpm install && ./integration_test.sh
@echo "Integration tests passed."
.PHONY: check_version write_version
check_version:
@if [ "$(VERSION)" = "unknown" ]; then \
echo "Version not set. Please set the VERSION environment variable."; \
exit 1; \
fi
write_version: check_version
@echo $(VERSION) > ./pkg/version/VERSION
.PHONY: tag
tag: write_version
@echo "Tagging version..."
@echo "Version: $(VERSION)"
@git checkout -b release/$(VERSION)
@echo $(VERSION) > ./pkg/version/VERSION
@$(MAKE) test
@git add .
@git commit -m "Bump version to $(VERSION)"
@git push origin release/$(VERSION)
# the release command for ci
# do not execute this command locally
# use `make tag` , then create a PR and merge it
# the ci will release the version
.PHONY: release
release:
@echo "Releasing version..."
@echo "Version: $(VERSION)"
@echo "Release go modules"
@git tag -a $(VERSION) -m "Version $(VERSION)"
@git push origin $(VERSION)
@echo "Release buf modules"
@buf push --git-metadata
@echo "Version $(VERSION) released."