1
- name : Release mcp-k8s to npm
1
+ name : Release mcp-k8s
2
2
3
3
on :
4
4
workflow_dispatch :
5
5
push :
6
6
tags :
7
7
- ' *'
8
8
9
+ permissions :
10
+ contents : write
11
+
9
12
jobs :
10
13
call-run-tests :
11
14
uses : strowk/mcp-k8s-go/.github/workflows/test.yaml@main
12
15
release :
13
16
needs : call-run-tests
17
+ services :
18
+ registry :
19
+ image : registry:2
20
+ ports :
21
+ - 5000:5000
14
22
runs-on : ubuntu-latest
15
23
steps :
16
24
- name : Checkout
17
- uses : actions/checkout@v2
25
+ uses : actions/checkout@v4
26
+ with :
27
+ fetch-depth : 0
18
28
19
29
- name : Set up Go
20
30
uses : actions/setup-go@v5
@@ -23,12 +33,77 @@ jobs:
23
33
24
34
- name : Install goreleaser
25
35
run : |
26
- go install github.com/goreleaser/goreleaser/v2@latest
36
+ go install github.com/goreleaser/goreleaser/v2@v2.8.1
27
37
which goreleaser
28
38
29
39
- name : Run goreleaser build
30
40
run : |
31
- goreleaser build --clean
41
+ goreleaser release --clean
42
+ env :
43
+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
44
+
45
+ - name : Set up Docker Buildx
46
+ uses : docker/setup-buildx-action@v3
47
+ with :
48
+ driver-opts : network=host
49
+
50
+ - name : Login to Docker Hub
51
+ uses : docker/login-action@v3
52
+ with :
53
+ username : mcpk8s
54
+ password : ${{ secrets.DOCKERHUB_TOKEN }}
55
+
56
+ # This bit is a workaround because docker can only do what we need
57
+ # when pushing directly from build to docker hub (i.e push by digest)
58
+ # and corresponding github action is unable to push without building
59
+ - name : Precreate temp context dir
60
+ run : |
61
+ mkdir -p /tmp/mcpk8s/arm64
62
+ echo 'FROM localhost:5000/mcpk8s/server:tmp-linux-arm64' > /tmp/mcpk8s/arm64/Dockerfile
63
+ mkdir -p /tmp/mcpk8s/amd64
64
+ echo 'FROM localhost:5000/mcpk8s/server:tmp-linux-amd64' > /tmp/mcpk8s/amd64/Dockerfile
65
+
66
+ - name : Build and push arm64 by digest
67
+ id : build-arm64
68
+ uses : docker/build-push-action@v6
69
+ with :
70
+ context : /tmp/mcpk8s/arm64
71
+ platforms : linux/arm64
72
+ tags : mcpk8s/server
73
+ outputs : type=image,push-by-digest=true,name-canonical=true,push=true
74
+
75
+ - name : Build and push amd64 by digest
76
+ id : build-amd64
77
+ uses : docker/build-push-action@v6
78
+ with :
79
+ context : /tmp/mcpk8s/amd64
80
+ platforms : linux/amd64
81
+ tags : mcpk8s/server
82
+ outputs : type=image,push-by-digest=true,name-canonical=true,push=true
83
+
84
+ - name : Create manifest list and push
85
+ run : |
86
+ goreleaser_tag=$(cat dist/metadata.json | jq -r '.tag')
87
+ echo "goreleaser_tag: ${goreleaser_tag}"
88
+
89
+ # the magic here is simply taking outputs from build- actions
90
+ # and removing sha256: prefix from them, cause we need to pass
91
+ # digests further to imagetools without the prefix
92
+
93
+ digest_arm64="${{ steps.build-arm64.outputs.digest }}"
94
+ digest_arm64="${digest_arm64#sha256:}"
95
+ digest_amd64="${{ steps.build-amd64.outputs.digest }}"
96
+ digest_amd64="${digest_amd64#sha256:}"
97
+
98
+ echo "crate multi-arch image for tag mcpk8s/server:${goreleaser_tag} with images:"
99
+ echo " arm64: mcpk8s/server@sha256:${digest_arm64}"
100
+ echo " amd64: mcpk8s/server@sha256:${digest_amd64}"
101
+
102
+ docker buildx imagetools create \
103
+ -t mcpk8s/server:${goreleaser_tag} \
104
+ -t mcpk8s/server:latest \
105
+ mcpk8s/server@sha256:${digest_arm64} \
106
+ mcpk8s/server@sha256:${digest_amd64}
32
107
33
108
- name : Publish to npm
34
109
env :
0 commit comments