-
Notifications
You must be signed in to change notification settings - Fork 28
Expand file tree
/
Copy pathMakefile
More file actions
69 lines (56 loc) · 2.01 KB
/
Copy pathMakefile
File metadata and controls
69 lines (56 loc) · 2.01 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
all: build
# Version and application information
VERSION := $(shell cat VERSION)
COMMIT := $(shell git rev-parse --short HEAD 2>/dev/null || echo unknown)
DATE := $(shell date -u +%Y-%m-%dT%H:%M:%SZ)
REPO := ghcr.io/silenceper/mcp-k8s
APPNAME := mcp-k8s
BUILDDIR := ./bin
# Build flags
LDFLAGS := -X 'main.version=$(VERSION)' -X 'main.commit=$(COMMIT)' -X 'main.date=$(DATE)'
.PHONY: build
build:
go build -ldflags "$(LDFLAGS)" -o ./bin/mcp-k8s cmd/mcp-k8s/main.go
# Clean the project
.PHONY: clean
clean:
rm -rf $(BUILDDIR)
# Format the code
.PHONY: fmt
fmt:
go fmt ./...
# Create output directory
.PHONY: init
init:
mkdir -p $(BUILDDIR)
# Cross-platform build - Windows
.PHONY: build-windows-amd64
build-windows-amd64: init
GOOS=windows GOARCH=amd64 go build -ldflags "$(LDFLAGS)" -o $(BUILDDIR)/$(APPNAME)_windows_amd64.exe cmd/mcp-k8s/main.go
# Cross-platform build - macOS (Intel)
.PHONY: build-darwin-amd64
build-darwin-amd64: init
GOOS=darwin GOARCH=amd64 go build -ldflags "$(LDFLAGS)" -o $(BUILDDIR)/$(APPNAME)_darwin_amd64 cmd/mcp-k8s/main.go
# Cross-platform build - macOS (Apple Silicon)
.PHONY: build-darwin-arm64
build-darwin-arm64: init
GOOS=darwin GOARCH=arm64 go build -ldflags "$(LDFLAGS)" -o $(BUILDDIR)/$(APPNAME)_darwin_arm64 cmd/mcp-k8s/main.go
# Cross-platform build - Linux
.PHONY: build-linux-amd64
build-linux-amd64: init
GOOS=linux GOARCH=amd64 go build -ldflags "$(LDFLAGS)" -o $(BUILDDIR)/$(APPNAME)_linux_amd64 cmd/mcp-k8s/main.go
# Cross-platform build - Linux
.PHONY: build-linux-arm64
build-linux-arm64: init
GOOS=linux GOARCH=arm64 go build -ldflags "$(LDFLAGS)" -o $(BUILDDIR)/$(APPNAME)_linux_arm64 cmd/mcp-k8s/main.go
# Cross-platform build - All platforms
.PHONY: build-all
build-all: build-windows-amd64 build-darwin-amd64 build-darwin-arm64 build-linux-amd64 build-linux-arm64
@echo "All platforms built successfully"
@ls -la $(BUILDDIR)
.PHONY: docker-build
docker-build:
docker build -t $(REPO):$(VERSION) -f Dockerfile .
.PHONY: docker-push
docker-push:
docker push $(REPO):$(VERSION)