-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathMakefile
More file actions
57 lines (47 loc) · 1.83 KB
/
Makefile
File metadata and controls
57 lines (47 loc) · 1.83 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
.PHONY: update-version increment-major increment-minor increment-patch test build clean fmt lint vet
VERSION_FILE := VERSION
VERSION_GO_FILE := version.go
update-version:
@echo "$(VERSION)" > $(VERSION_FILE)
@perl -pi -e 's|const Version string = "[.\-\d\w]+"|const Version string = "$(VERSION)"|' $(VERSION_GO_FILE)
@gofmt -w $(VERSION_GO_FILE)
@echo "Updated version to $(VERSION)"
increment-major:
$(eval CURRENT := $(shell cat $(VERSION_FILE)))
$(eval MAJOR := $(shell echo $(CURRENT) | cut -d. -f1))
$(eval NEW_VERSION := $(shell echo $$(($(MAJOR) + 1)).0.0))
@$(MAKE) update-version VERSION=$(NEW_VERSION)
@echo "Version bumped from $(CURRENT) to $(NEW_VERSION)"
increment-minor:
$(eval CURRENT := $(shell cat $(VERSION_FILE)))
$(eval MAJOR := $(shell echo $(CURRENT) | cut -d. -f1))
$(eval MINOR := $(shell echo $(CURRENT) | cut -d. -f2))
$(eval NEW_VERSION := $(MAJOR).$(shell echo $$(($(MINOR) + 1))).0)
@$(MAKE) update-version VERSION=$(NEW_VERSION)
@echo "Version bumped from $(CURRENT) to $(NEW_VERSION)"
increment-patch:
$(eval CURRENT := $(shell cat $(VERSION_FILE)))
$(eval MAJOR := $(shell echo $(CURRENT) | cut -d. -f1))
$(eval MINOR := $(shell echo $(CURRENT) | cut -d. -f2))
$(eval PATCH := $(shell echo $(CURRENT) | cut -d. -f3))
$(eval NEW_VERSION := $(MAJOR).$(MINOR).$(shell echo $$(($(PATCH) + 1))))
@$(MAKE) update-version VERSION=$(NEW_VERSION)
@echo "Version bumped from $(CURRENT) to $(NEW_VERSION)"
format:
@echo "Formatting code..."
@gofmt -w .
test:
@echo "Running tests..."
@go test ./... -v
test-coverage:
@echo "Running tests with coverage..."
@go test ./... -coverprofile=coverage.out
@go tool cover -html=coverage.out -o coverage.html
@echo "Coverage report generated: coverage.html"
build:
@echo "Building..."
@go build ./...
clean:
@echo "Cleaning..."
@go clean
@rm -f coverage.out coverage.html