Skip to content

Commit d6ff675

Browse files
committed
feat(ci): build for multiple platforms
1 parent 4a1010c commit d6ff675

File tree

2 files changed

+22
-13
lines changed

2 files changed

+22
-13
lines changed

Makefile

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,24 @@
77

88
.DEFAULT_GOAL := help
99

10-
PACKAGE=$(shell go list -m)
11-
GIT_COMMIT_HASH=$(shell git rev-parse HEAD)
12-
GIT_VERSION=$(shell git describe --tags --always --dirty)
13-
BUILD_TIME=$(shell date -u '+%Y-%m-%dT%H:%M:%SZ')
14-
BINARY_NAME=kubernetes-mcp-server
15-
LD_FLAGS=-s -w \
10+
PACKAGE = $(shell go list -m)
11+
GIT_COMMIT_HASH = $(shell git rev-parse HEAD)
12+
GIT_VERSION = $(shell git describe --tags --always --dirty)
13+
BUILD_TIME = $(shell date -u '+%Y-%m-%dT%H:%M:%SZ')
14+
BINARY_NAME = kubernetes-mcp-server
15+
LD_FLAGS = -s -w \
1616
-X '$(PACKAGE)/pkg/version.CommitHash=$(GIT_COMMIT_HASH)' \
1717
-X '$(PACKAGE)/pkg/version.Version=$(GIT_VERSION)' \
1818
-X '$(PACKAGE)/pkg/version.BuildTime=$(BUILD_TIME)' \
1919
-X '$(PACKAGE)/pkg/version.BinaryName=$(BINARY_NAME)'
20-
COMMON_BUILD_ARGS=-ldflags "$(LD_FLAGS)"
21-
CLEAN_TARGETS:=
20+
COMMON_BUILD_ARGS = -ldflags "$(LD_FLAGS)"
21+
22+
OSES = linux darwin windows
23+
ARCHS = amd64 arm64 arm
24+
25+
CLEAN_TARGETS :=
26+
CLEAN_TARGETS += '$(BINARY_NAME)'
27+
CLEAN_TARGETS += $(foreach os,$(OSES),$(foreach arch,$(ARCHS),$(BINARY_NAME)-$(os)-$(arch)))
2228

2329
# The help will print out all targets with their descriptions organized bellow their categories. The categories are represented by `##@` and the target descriptions by `##`.
2430
# The awk commands is responsible to read the entire set of makefiles included in this invocation, looking for lines of the file as xyz: ## something, and then pretty-format the target and help. Then, if there's a line with ##@ something, that gets pretty-printed as a category.
@@ -40,7 +46,12 @@ clean: ## Clean up all build artifacts
4046
build: clean tidy format ## Build the project
4147
go build $(COMMON_BUILD_ARGS) -o $(BINARY_NAME) ./cmd/kubernetes-mcp-server
4248

43-
CLEAN_TARGETS+='$(BINARY_NAME)'
49+
50+
.PHONY: build-all-platforms
51+
build-all-platforms: clean tidy format ## Build the project for all platforms
52+
$(foreach os,$(OSES),$(foreach arch,$(ARCHS), \
53+
GOOS=$(os) GOARCH=$(arch) go build $(COMMON_BUILD_ARGS) -o $(BINARY_NAME)-$(os)-$(arch) ./cmd/kubernetes-mcp-server; \
54+
))
4455

4556
.PHONY: test
4657
test: ## Run the tests

README.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,9 @@
22

33
<p align="center">
44
<a href="https://github.com/manusa/kubernetes-mcp-server/blob/main/LICENSE">
5-
<img alt="GitHub License" src="https://img.shields.io/github/license/manusa/kubernetes-mcp-server">
6-
</a>
5+
<img alt="GitHub License" src="https://img.shields.io/github/license/manusa/kubernetes-mcp-server" /></a>
76
<a href="https://github.com/manusa/kubernetes-mcp-server/actions/workflows/build.yaml">
8-
<img src="https://github.com/manusa/kubernetes-mcp-server/actions/workflows/build.yaml/badge.svg" alt="Build status badge" />
9-
</a>
7+
<img src="https://github.com/manusa/kubernetes-mcp-server/actions/workflows/build.yaml/badge.svg" alt="Build status badge" /></a>
108
</p>
119

1210

0 commit comments

Comments
 (0)