Skip to content

Commit 1917a8a

Browse files
authored
Merge pull request #9 from silenceper/dev
add goreleaser
2 parents 99e0144 + 23f4de2 commit 1917a8a

File tree

6 files changed

+168
-3
lines changed

6 files changed

+168
-3
lines changed

.github/workflows/release.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
8+
permissions:
9+
contents: write
10+
packages: write
11+
12+
jobs:
13+
goreleaser:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v3
18+
with:
19+
fetch-depth: 0
20+
21+
- name: Set up Go
22+
uses: actions/setup-go@v4
23+
with:
24+
go-version: "1.24"
25+
check-latest: true
26+
27+
- name: Set up QEMU
28+
uses: docker/setup-qemu-action@v2
29+
30+
- name: Set up Docker Buildx
31+
uses: docker/setup-buildx-action@v2
32+
33+
- name: Login to GitHub Container Registry
34+
uses: docker/login-action@v2
35+
with:
36+
registry: ghcr.io
37+
username: ${{ github.actor }}
38+
password: ${{ secrets.GITHUB_TOKEN }}
39+
40+
- name: Run GoReleaser
41+
uses: goreleaser/goreleaser-action@v4
42+
with:
43+
distribution: goreleaser
44+
version: latest
45+
args: release --clean
46+
env:
47+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
48+
GITHUB_REPOSITORY_OWNER: ${{ github.repository_owner }}

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,5 @@ go.work.sum
2424
# env file
2525
.env
2626
/bin
27-
/.cursor
27+
/.cursor
28+
/dist

.goreleaser.yml

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
version: 2
2+
project_name: mcp-k8s
3+
4+
before:
5+
hooks:
6+
- go mod tidy
7+
8+
builds:
9+
- id: mcp-k8s
10+
main: ./cmd/server
11+
binary: mcp-k8s
12+
env:
13+
- CGO_ENABLED=0
14+
goos:
15+
- linux
16+
- darwin
17+
- windows
18+
goarch:
19+
- amd64
20+
- arm64
21+
ignore:
22+
- goos: windows
23+
goarch: arm64
24+
25+
archives:
26+
- id: default
27+
format: binary
28+
name_template: >-
29+
{{ .ProjectName }}_
30+
{{- title .Os }}_
31+
{{- if eq .Arch "amd64" }}x86_64
32+
{{- else if eq .Arch "386" }}i386
33+
{{- else }}{{ .Arch }}{{ end }}
34+
builds:
35+
- mcp-k8s
36+
files:
37+
- LICENSE
38+
- README.md
39+
format_overrides:
40+
- goos: linux
41+
format: tar.gz
42+
- goos: darwin
43+
format: tar.gz
44+
- goos: windows
45+
format: zip
46+
47+
dockers:
48+
- image_templates:
49+
- "ghcr.io/silenceper/{{ .ProjectName }}:{{ .Version }}-amd64"
50+
dockerfile: Dockerfile.goreleaser
51+
use: buildx
52+
build_flag_templates:
53+
- "--platform=linux/amd64"
54+
- "--label=org.opencontainers.image.created={{.Date}}"
55+
- "--label=org.opencontainers.image.title={{.ProjectName}}"
56+
- "--label=org.opencontainers.image.revision={{.FullCommit}}"
57+
- "--label=org.opencontainers.image.version={{.Version}}"
58+
goarch: amd64
59+
skip_push: false
60+
- image_templates:
61+
- "ghcr.io/silenceper/{{ .ProjectName }}:{{ .Version }}-arm64"
62+
dockerfile: Dockerfile.goreleaser
63+
use: buildx
64+
build_flag_templates:
65+
- "--platform=linux/arm64"
66+
- "--label=org.opencontainers.image.created={{.Date}}"
67+
- "--label=org.opencontainers.image.title={{.ProjectName}}"
68+
- "--label=org.opencontainers.image.revision={{.FullCommit}}"
69+
- "--label=org.opencontainers.image.version={{.Version}}"
70+
goarch: arm64
71+
skip_push: false
72+
73+
docker_manifests:
74+
- name_template: ghcr.io/silenceper/{{ .ProjectName }}:{{ .Version }}
75+
image_templates:
76+
- ghcr.io/silenceper/{{ .ProjectName }}:{{ .Version }}-amd64
77+
- ghcr.io/silenceper/{{ .ProjectName }}:{{ .Version }}-arm64
78+
- name_template: ghcr.io/silenceper/{{ .ProjectName }}:latest
79+
image_templates:
80+
- ghcr.io/silenceper/{{ .ProjectName }}:{{ .Version }}-amd64
81+
- ghcr.io/silenceper/{{ .ProjectName }}:{{ .Version }}-arm64
82+
83+
release:
84+
github:
85+
owner: silenceper
86+
name: "{{ .ProjectName }}"
87+
prerelease: auto
88+
draft: false
89+
name_template: "{{ .Tag }}"
90+
91+
changelog:
92+
sort: asc
93+
filters:
94+
exclude:
95+
- "^docs:"
96+
- "^test:"
97+
- "^ci:"
98+
- "^chore:"

Dockerfile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ ARG LDFLAGS=""
66
FROM golang:${GOVERSION} as builder
77
# Copy in the go src
88
WORKDIR /go/src/github.com/silenceper/mcp-k8s
9-
COPY . .
9+
COPY internal internal/
10+
COPY cmd cmd/
11+
COPY go.mod go.mod
12+
COPY go.sum go.sum
1013
ARG LDFLAGS
1114
ARG TARGETOS
1215
ARG TARGETARCH

Dockerfile.goreleaser

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
FROM alpine:3.18.4
2+
3+
WORKDIR /root
4+
RUN apk add --no-cache gcompat
5+
COPY mcp-k8s /usr/local/bin/mcp-k8s
6+
ENTRYPOINT ["/usr/local/bin/mcp-k8s"]

Makefile

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ all: build
22

33
# Version and application information
44
VERSION := 1.0.0
5+
REPO := ghcr.io/silenceper/mcp-k8s
56
APPNAME := mcp-k8s
67
BUILDDIR := ./bin
78

@@ -52,4 +53,12 @@ build-linux-arm64: init
5253
.PHONY: build-all
5354
build-all: build-windows-amd64 build-darwin-amd64 build-darwin-arm64 build-linux-amd64 build-linux-arm64
5455
@echo "All platforms built successfully"
55-
@ls -la $(BUILDDIR)
56+
@ls -la $(BUILDDIR)
57+
58+
.PHONY: docker-build
59+
docker-build:
60+
docker build -t $(REPO):$(VERSION) -f Dockerfile .
61+
62+
.PHONY: docker-push
63+
docker-push:
64+
docker push $(REPO):$(VERSION)

0 commit comments

Comments
 (0)