@@ -3,16 +3,17 @@ name: publish
33on :
44 push :
55 branches : ['main']
6+ tags : ['v*.*.*']
67 release :
78 types : ['published']
89
910concurrency : ${{ github.ref }}
1011
1112env :
12- REGISTRY : ghcr.io
1313 IMAGE_NAME : cloudstruct/cardano-node
1414
1515jobs :
16+
1617 build-amd64 :
1718 runs-on : ubuntu-latest
1819 permissions :
@@ -21,32 +22,56 @@ jobs:
2122 steps :
2223 - uses : actions/checkout@v2
2324 - 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
2531 uses : docker/login-action@v1
2632 with :
27- registry : ${{ env.REGISTRY }}
33+ registry : ghcr.io
2834 username : ${{ github.actor }}
2935 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-
3042 - id : meta
3143 uses : docker/metadata-action@v3
3244 with :
33- images : ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
45+ images : |
46+ ${{ env.IMAGE_NAME }}
47+ ghcr.io/${{ env.IMAGE_NAME }}
3448 flavor : |
3549 latest=false
50+ suffix=-amd64
3651 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}}
4158 - name : push
4259 uses : docker/build-push-action@v2
4360 with :
4461 context : .
4562 push : true
4663 tags : ${{ steps.meta.outputs.tags }}
4764 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+
5075 build-arm64 :
5176 runs-on : self-hosted
5277 permissions :
@@ -55,32 +80,56 @@ jobs:
5580 steps :
5681 - uses : actions/checkout@v2
5782 - 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
5989 uses : docker/login-action@v1
6090 with :
61- registry : ${{ env.REGISTRY }}
91+ registry : ghcr.io
6292 username : ${{ github.actor }}
6393 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-
64100 - id : meta
65101 uses : docker/metadata-action@v3
66102 with :
67- images : ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
103+ images : |
104+ ${{ env.IMAGE_NAME }}
105+ ghcr.io/${{ env.IMAGE_NAME }}
68106 flavor : |
69107 latest=false
108+ suffix=-arm64v8
70109 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}}
75116 - name : push
76117 uses : docker/build-push-action@v2
77118 with :
78119 context : .
79120 push : true
80121 tags : ${{ steps.meta.outputs.tags }}
81122 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+
84133 multi-arch-manifest :
85134 runs-on : ubuntu-latest
86135 needs : [build-amd64, build-arm64]
@@ -90,22 +139,97 @@ jobs:
90139 steps :
91140 - uses : actions/checkout@v2
92141 - 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
94148 uses : docker/login-action@v1
95149 with :
96- registry : ${{ env.REGISTRY }}
150+ registry : ghcr.io
97151 username : ${{ github.actor }}
98152 password : ${{ secrets.GITHUB_TOKEN }}
99- - id : meta
153+ - id : meta-dockerhub
100154 uses : docker/metadata-action@v3
101155 with :
102- images : ${{ env.REGISTRY }}/${{ env. IMAGE_NAME }}
156+ images : ${{ env.IMAGE_NAME }}
103157 flavor : |
104158 latest=false
105159 tags : |
160+ # branch
106161 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