@@ -3,16 +3,17 @@ name: publish
3
3
on :
4
4
push :
5
5
branches : ['main']
6
+ tags : ['v*.*.*']
6
7
release :
7
8
types : ['published']
8
9
9
10
concurrency : ${{ github.ref }}
10
11
11
12
env :
12
- REGISTRY : ghcr.io
13
13
IMAGE_NAME : cloudstruct/cardano-node
14
14
15
15
jobs :
16
+
16
17
build-amd64 :
17
18
runs-on : ubuntu-latest
18
19
permissions :
@@ -21,32 +22,56 @@ jobs:
21
22
steps :
22
23
- uses : actions/checkout@v2
23
24
- uses : docker/setup-buildx-action@v1
24
- - name : login
25
+ - name : Login to Docker Hub
26
+ uses : docker/login-action@v1
27
+ with :
28
+ username : cloudstruct
29
+ password : ${{ secrets.DOCKER_PASSWORD }} # uses token
30
+ - name : Login to GHCR
25
31
uses : docker/login-action@v1
26
32
with :
27
- registry : ${{ env.REGISTRY }}
33
+ registry : ghcr.io
28
34
username : ${{ github.actor }}
29
35
password : ${{ secrets.GITHUB_TOKEN }}
36
+ - uses : actions/cache@v3
37
+ with :
38
+ path : /tmp/.buildx-cache
39
+ key : ${{ runner.os }}-${{ runner.arch }}-buildx-${{ github.sha }}
40
+ restore-keys : |
41
+ ${{ runner.os }}-${{ runner.arch }}-buildx-
30
42
- id : meta
31
43
uses : docker/metadata-action@v3
32
44
with :
33
- images : ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
45
+ images : |
46
+ ${{ env.IMAGE_NAME }}
47
+ ghcr.io/${{ env.IMAGE_NAME }}
34
48
flavor : |
35
49
latest=false
50
+ suffix=-amd64
36
51
tags : |
37
- type=schedule,suffix=-amd64
38
- type=ref,event=branch,suffix=-amd64
39
- type=ref,event=tag,suffix=-amd64
40
- type=ref,event=pr,suffix=-amd64
52
+ # full tag minus v
53
+ type=match,pattern=v(.*),group=1
54
+ # branch
55
+ type=ref,event=branch
56
+ # semver
57
+ type=semver,pattern={{version}}
41
58
- name : push
42
59
uses : docker/build-push-action@v2
43
60
with :
44
61
context : .
45
62
push : true
46
63
tags : ${{ steps.meta.outputs.tags }}
47
64
labels : ${{ steps.meta.outputs.labels }}
48
- cache-from : type=gha
49
- cache-to : type=gha,mode=max
65
+ cache-from : type=local,src=/tmp/.buildx-cache
66
+ cache-to : type=local,dest=/tmp/.buildx-cache-new,mode=max
67
+ # TEMP fix
68
+ # https://github.com/docker/build-push-action/issues/252
69
+ # https://github.com/moby/buildkit/issues/1896
70
+ - name : cache
71
+ run : |
72
+ rm -rf /tmp/.buildx-cache
73
+ mv /tmp/.buildx-cache-new /tmp/.buildx-cache
74
+
50
75
build-arm64 :
51
76
runs-on : self-hosted
52
77
permissions :
@@ -55,32 +80,56 @@ jobs:
55
80
steps :
56
81
- uses : actions/checkout@v2
57
82
- uses : docker/setup-buildx-action@v1
58
- - name : login
83
+ - name : Login to Docker Hub
84
+ uses : docker/login-action@v1
85
+ with :
86
+ username : cloudstruct
87
+ password : ${{ secrets.DOCKER_PASSWORD }} # uses token
88
+ - name : Login to GHCR
59
89
uses : docker/login-action@v1
60
90
with :
61
- registry : ${{ env.REGISTRY }}
91
+ registry : ghcr.io
62
92
username : ${{ github.actor }}
63
93
password : ${{ secrets.GITHUB_TOKEN }}
94
+ - uses : actions/cache@v3
95
+ with :
96
+ path : /tmp/.buildx-cache
97
+ key : ${{ runner.os }}-${{ runner.arch }}-buildx-${{ github.sha }}
98
+ restore-keys : |
99
+ ${{ runner.os }}-${{ runner.arch }}-buildx-
64
100
- id : meta
65
101
uses : docker/metadata-action@v3
66
102
with :
67
- images : ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
103
+ images : |
104
+ ${{ env.IMAGE_NAME }}
105
+ ghcr.io/${{ env.IMAGE_NAME }}
68
106
flavor : |
69
107
latest=false
108
+ suffix=-arm64v8
70
109
tags : |
71
- type=schedule,suffix=-arm64v8
72
- type=ref,event=branch,suffix=-arm64v8
73
- type=ref,event=tag,suffix=-arm64v8
74
- type=ref,event=pr,suffix=-arm64v8
110
+ # full tag minus v
111
+ type=match,pattern=v(.*),group=1
112
+ # branch
113
+ type=ref,event=branch
114
+ # semver
115
+ type=semver,pattern={{version}}
75
116
- name : push
76
117
uses : docker/build-push-action@v2
77
118
with :
78
119
context : .
79
120
push : true
80
121
tags : ${{ steps.meta.outputs.tags }}
81
122
labels : ${{ steps.meta.outputs.labels }}
82
- cache-from : type=gha
83
- cache-to : type=gha,mode=max
123
+ cache-from : type=local,src=/tmp/.buildx-cache
124
+ cache-to : type=local,dest=/tmp/.buildx-cache-new,mode=max
125
+ # TEMP fix
126
+ # https://github.com/docker/build-push-action/issues/252
127
+ # https://github.com/moby/buildkit/issues/1896
128
+ - name : cache
129
+ run : |
130
+ rm -rf /tmp/.buildx-cache
131
+ mv /tmp/.buildx-cache-new /tmp/.buildx-cache
132
+
84
133
multi-arch-manifest :
85
134
runs-on : ubuntu-latest
86
135
needs : [build-amd64, build-arm64]
@@ -90,22 +139,97 @@ jobs:
90
139
steps :
91
140
- uses : actions/checkout@v2
92
141
- uses : docker/setup-buildx-action@v1
93
- - name : login
142
+ - name : Login to Docker Hub
143
+ uses : docker/login-action@v1
144
+ with :
145
+ username : cloudstruct
146
+ password : ${{ secrets.DOCKER_PASSWORD }} # uses token
147
+ - name : Login to GHCR
94
148
uses : docker/login-action@v1
95
149
with :
96
- registry : ${{ env.REGISTRY }}
150
+ registry : ghcr.io
97
151
username : ${{ github.actor }}
98
152
password : ${{ secrets.GITHUB_TOKEN }}
99
- - id : meta
153
+ - id : meta-dockerhub
100
154
uses : docker/metadata-action@v3
101
155
with :
102
- images : ${{ env.REGISTRY }}/${{ env. IMAGE_NAME }}
156
+ images : ${{ env.IMAGE_NAME }}
103
157
flavor : |
104
158
latest=false
105
159
tags : |
160
+ # branch
106
161
type=ref,event=branch
107
- type=ref,event=tag
108
- - name : manifest
109
- run : docker manifest create ${{ steps.meta.outputs.tags }} --amend ${{ steps.meta.outputs.tags }}-amd64 --amend ${{ steps.meta.outputs.tags }}-arm64v8
110
- - name : push
111
- run : docker manifest push ${{ steps.meta.outputs.tags }}
162
+ # semver
163
+ type=semver,pattern={{version}}
164
+ - id : meta-dockerhub-tag
165
+ uses : docker/metadata-action@v3
166
+ with :
167
+ images : |
168
+ ${{ env.IMAGE_NAME }}
169
+ flavor : |
170
+ latest=false
171
+ tags : |
172
+ # full tag minus v
173
+ type=match,pattern=v(.*),group=1
174
+ - id : meta-ghcr
175
+ uses : docker/metadata-action@v3
176
+ with :
177
+ images : ghcr.io/${{ env.IMAGE_NAME }}
178
+ flavor : |
179
+ latest=false
180
+ tags : |
181
+ # branch
182
+ type=ref,event=branch
183
+ # semver
184
+ type=semver,pattern={{version}}
185
+ - id : meta-ghcr-tag
186
+ uses : docker/metadata-action@v3
187
+ with :
188
+ images : |
189
+ ${{ env.IMAGE_NAME }}
190
+ flavor : |
191
+ latest=false
192
+ tags : |
193
+ # full tag minus v
194
+ type=match,pattern=v(.*),group=1
195
+ # Manifest for either branch or semver
196
+ - name : manifest-dockerhub
197
+ run : docker manifest create ${{ steps.meta-dockerhub.outputs.tags }} --amend ${{ steps.meta-dockerhub.outputs.tags }}-amd64 --amend ${{ steps.meta-dockerhub.outputs.tags }}-arm64v8
198
+ - name : manifest-ghcr
199
+ run : docker manifest create ${{ steps.meta-ghcr.outputs.tags }} --amend ${{ steps.meta-ghcr.outputs.tags }}-amd64 --amend ${{ steps.meta-ghcr.outputs.tags }}-arm64v8
200
+ # Manifest for latest
201
+ - name : manifest-dockerhub-latest
202
+ run : docker manifest create ${{ env.IMAGE_NAME }}:latest --amend ${{ steps.meta-dockerhub.outputs.tags }}-amd64 --amend ${{ steps.meta-dockerhub.outputs.tags }}-arm64v8
203
+ - name : manifest-ghcr-latest
204
+ run : docker manifest create ghcr.io/${{ env.IMAGE_NAME }}:latest --amend ${{ steps.meta-ghcr.outputs.tags }}-amd64 --amend ${{ steps.meta-ghcr.outputs.tags }}-arm64v8
205
+ # Optional manifest for tag versions (includes revisions)
206
+ - name : manifest-dockerhub-tags
207
+ run : docker manifest create ${{ steps.meta-dockerhub-tags.outputs.tags }} --amend ${{ steps.meta-dockerhub-tags.outputs.tags }}-amd64 --amend ${{ steps.meta-dockerhub-tags.outputs.tags }}-arm64v8
208
+ if : startsWith(github.ref, 'refs/tags/')
209
+ - name : manifest-ghcr-tags
210
+ run : docker manifest create ${{ steps.meta-ghcr-tags.outputs.tags }} --amend ${{ steps.meta-ghcr-tags.outputs.tags }}-amd64 --amend ${{ steps.meta-ghcr-tags.outputs.tags }}-arm64v8
211
+ if : startsWith(github.ref, 'refs/tags/')
212
+ # Push various manifests
213
+ - name : push-dockerhub
214
+ run : docker manifest push ${{ steps.meta-dockerhub.outputs.tags }}
215
+ - name : push-ghcr
216
+ run : docker manifest push ${{ steps.meta-ghcr.outputs.tags }}
217
+ - name : push-dockerhub-latest
218
+ run : docker manifest push ${{ env.IMAGE_NAME }}:latest
219
+ - name : push-ghcr-latest
220
+ run : docker manifest push ghcr.io/${{ env.IMAGE_NAME }}:latest
221
+ - name : push-dockerhub-tags
222
+ run : docker manifest push ${{ steps.meta-dockerhub-tags.outputs.tags }}
223
+ if : startsWith(github.ref, 'refs/tags/')
224
+ - name : push-ghcr-tags
225
+ run : docker manifest push ${{ steps.meta-ghcr-tags.outputs.tags }}
226
+ if : startsWith(github.ref, 'refs/tags/')
227
+ # Update Docker Hub from README
228
+ - name : Docker Hub Description
229
+ uses : peter-evans/dockerhub-description@v3
230
+ with :
231
+ username : cloudstruct
232
+ password : ${{ secrets.DOCKER_PASSWORD }}
233
+ repository : ${{ env.IMAGE_NAME }}
234
+ readme-filepath : ./README.md
235
+ short-description : " Cardano Node built from source on Debian"
0 commit comments