-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
72 lines (61 loc) · 1.77 KB
/
Makefile
File metadata and controls
72 lines (61 loc) · 1.77 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
.PHONY: all build clean install test
# Variables
BINARY=cluster
BUILD_DIR=bin
GO=go
INSTALL_PATH=/usr/local/bin
all: build
# Build cluster CLI
build:
@echo "Building cluster CLI..."
@mkdir -p $(BUILD_DIR)
$(GO) build -o $(BUILD_DIR)/$(BINARY) ./cmd/cluster
@echo "Cluster CLI built: $(BUILD_DIR)/$(BINARY)"
# Install cluster CLI to system
install: build
@echo "Installing cluster CLI to $(INSTALL_PATH)..."
@sudo cp $(BUILD_DIR)/$(BINARY) $(INSTALL_PATH)/
@sudo chmod +x $(INSTALL_PATH)/$(BINARY)
@echo "Cluster CLI installed successfully"
# Clean build artifacts
clean:
@echo "Cleaning build artifacts..."
@rm -rf $(BUILD_DIR)
@echo "Clean complete"
# Run tests
test:
@echo "Running tests..."
$(GO) test -v ./...
# Build for Linux AMD64 (for deployment)
build-linux:
@echo "Building for Linux AMD64..."
@mkdir -p $(BUILD_DIR)
GOOS=linux GOARCH=amd64 $(GO) build -o $(BUILD_DIR)/$(BINARY)-linux-amd64 ./cmd/cluster
@echo "Linux binary built: $(BUILD_DIR)/$(BINARY)-linux-amd64"
# Download dependencies
deps:
@echo "Downloading dependencies..."
$(GO) mod download
$(GO) mod tidy
# Format code
fmt:
@echo "Formatting code..."
$(GO) fmt ./...
# Run linter
lint:
@echo "Running linter..."
@which golangci-lint > /dev/null || (echo "golangci-lint not installed" && exit 1)
golangci-lint run
# Help
help:
@echo "Available targets:"
@echo " all - Build cluster CLI (default)"
@echo " build - Build cluster CLI"
@echo " install - Install cluster CLI to system"
@echo " clean - Remove build artifacts"
@echo " test - Run tests"
@echo " build-linux - Build for Linux AMD64"
@echo " deps - Download dependencies"
@echo " fmt - Format code"
@echo " lint - Run linter"
@echo " help - Show this help"