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