-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
112 lines (86 loc) · 2.73 KB
/
Copy pathMakefile
File metadata and controls
112 lines (86 loc) · 2.73 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
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
102
103
104
105
106
107
108
109
110
111
112
# Copyright 2025 The KubeLB Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
BINARY_NAME := kubelb
BUILD_DIR := bin
MAIN_PACKAGE := .
GIT_VERSION := $(shell git describe --tags --always --dirty 2>/dev/null || echo "dev")
GIT_COMMIT := $(shell git rev-parse HEAD 2>/dev/null || echo "unknown")
BUILD_DATE := $(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
LDFLAGS := -ldflags "-X 'k8c.io/kubelb-cli/cmd.gitVersion=$(GIT_VERSION)' \
-X 'k8c.io/kubelb-cli/cmd.gitCommit=$(GIT_COMMIT)' \
-X 'k8c.io/kubelb-cli/cmd.buildDate=$(BUILD_DATE)'"
.PHONY: fmt
fmt: ## Run go fmt against code.
go fmt ./...
.PHONY: vet
vet: ## Run go vet against code.
go vet ./...
lint: ## Run golangci-lint against code.
golangci-lint run -v --timeout=5m
yamllint: ## Run yamllint against code.
yamllint -c .yamllint.conf .
check-dependencies: ## Verify go.mod.
go mod verify
go-mod-tidy:
go mod tidy
.PHONY: all
all: build
.PHONY: build
build:
@echo "Building $(BINARY_NAME)..."
@mkdir -p $(BUILD_DIR)
go build -mod=mod $(LDFLAGS) -o $(BUILD_DIR)/$(BINARY_NAME) $(MAIN_PACKAGE)
.PHONY: clean
clean:
@echo "Cleaning..."
@rm -rf $(BUILD_DIR)
.PHONY: test
test:
@echo "Running tests..."
go test ./...
.PHONY: install
install:
@echo "Installing $(BINARY_NAME)..."
go install $(LDFLAGS) $(MAIN_PACKAGE)
.PHONY: run-version
run-version: build
@echo "Running version command..."
./$(BUILD_DIR)/$(BINARY_NAME) version
update-docs:
@echo "Updating docs..."
./$(BUILD_DIR)/$(BINARY_NAME) docs --hugo --output=./docs/cli
.PHONY: snapshot
snapshot: ## Create a snapshot release with goreleaser
@echo "Creating snapshot release..."
goreleaser release --snapshot --clean
.PHONY: release
release: ## Create a production release with goreleaser
@echo "Creating production release..."
goreleaser release --clean
verify-boilerplate: ## Run verify-boilerplate code.
./hack/verify-boilerplate.sh
verify-imports: ## Run verify-imports code.
./hack/verify-import-order.sh
.PHONY: shfmt
shfmt:
shfmt -w -sr -i 2 hack
.PHONY: verify-shfmt
verify-shfmt: ## Verify shell script formatting
shfmt -l -sr -i 2 -d hack
.PHONY: verify-licenses
verify-licenses: ## Verify license compliance
./hack/verify-licenses.sh
.PHONY: verify-all
verify-all: ## Run all verification checks
./hack/verify-all.sh