-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
58 lines (46 loc) · 1.68 KB
/
Makefile
File metadata and controls
58 lines (46 loc) · 1.68 KB
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
.PHONY: help test tag-patch tag-minor tag-major buf-dep-update buf-lint buf-generate
help:
@echo "Available targets:"
@echo " test - Run tests with GOEXPERIMENT=jsonv2"
@echo " buf-dep-update - Update buf dependencies"
@echo " buf-lint - Run buf lint"
@echo " buf-generate - Run buf generate"
@echo " tag-patch - Increment patch version (v0.0.X -> v0.0.X+1)"
@echo " tag-minor - Increment minor version (v0.X.0 -> v0.X+1.0)"
@echo " tag-major - Increment major version (vX.0.0 -> vX+1.0.0)"
test:
GOEXPERIMENT=jsonv2 go test ./...
# Get the latest tag (globally) or default to v0.0.0
LATEST_TAG := $(shell git tag -l | sort -V | tail -n 1)
CURRENT_TAG := $(if $(LATEST_TAG),$(LATEST_TAG),v0.0.0)
# Parse current version
MAJOR := $(shell echo $(CURRENT_TAG) | awk -F. '{print $$1}' | sed 's/v//')
MINOR := $(shell echo $(CURRENT_TAG) | awk -F. '{print $$2}')
PATCH := $(shell echo $(CURRENT_TAG) | awk -F. '{print $$3}')
tag-patch:
@echo "Current version: $(CURRENT_TAG)"
@new_patch=$$(($(PATCH) + 1)); \
NEW_TAG="v$(MAJOR).$(MINOR).$$new_patch"; \
echo "New version: $$NEW_TAG"; \
git tag $$NEW_TAG; \
echo "Created tag $$NEW_TAG"
tag-minor:
@echo "Current version: $(CURRENT_TAG)"
@new_minor=$$(($(MINOR) + 1)); \
NEW_TAG="v$(MAJOR).$$new_minor.0"; \
echo "New version: $$NEW_TAG"; \
git tag $$NEW_TAG; \
echo "Created tag $$NEW_TAG"
tag-major:
@echo "Current version: $(CURRENT_TAG)"
@new_major=$$(($(MAJOR) + 1)); \
NEW_TAG="v$$new_major.0.0"; \
echo "New version: $$NEW_TAG"; \
git tag $$NEW_TAG; \
echo "Created tag $$NEW_TAG"
buf-dep-update:
buf dep update
buf-lint:
buf lint
buf-generate:
buf generate