11name : Upload Python Package
22
33on :
4+ push :
45 release :
56 types : [published]
67
78env :
89 REGISTRY : ghcr.io
910 DOCKER_REGISTRY : docker.io
10- DOCKER_REGISTRY_USER : pinto0309
11+ DOCKER_REGISTRY_USER : sohma440
1112 IMAGE_NAME : ${{ github.repository }}
1213
1314jobs :
1415 pypi-deploy :
16+ # todo
17+ if : ${{ false }}
1518 runs-on : ubuntu-latest
1619 steps :
1720 - uses : actions/checkout@v3
@@ -32,16 +35,19 @@ jobs:
3235 user : __token__
3336 password : ${{ secrets.PYPI_API_TOKEN }}
3437
35- docker-deploy :
38+ build :
3639 runs-on : ubuntu-latest
37- needs : pypi-deploy
40+ # todo
41+ # needs: pypi-deploy
3842 permissions :
3943 contents : read
4044 packages : write
4145 strategy :
4246 fail-fast : false # do not cancel even if any platform fails.
4347 matrix :
44- platform : [linux/amd64,linux/arm64]
48+ platform :
49+ - linux/amd64
50+ - linux/arm64
4551 steps :
4652 - name : Git checkout
4753 uses : actions/checkout@v3
5056 - name : Set up QEMU
5157 uses : docker/setup-qemu-action@v3
5258
59+ - name : Prepare
60+ run : |
61+ platform=${{ matrix.platform }}
62+ echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
63+
5364 - name : Log in to the GitHub Container registry
5465 uses : docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
5566 with :
6172 uses : docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
6273 with :
6374 images : ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
75+
6476 - name : Build and push Docker image
6577 uses : docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
6678 with :
@@ -81,11 +93,66 @@ jobs:
8193 uses : docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
8294 with :
8395 images : ${{ env.DOCKER_REGISTRY }}/${{ env.IMAGE_NAME }}
84- - name : Build and push Docker image
85- uses : docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
96+
97+ - name : Build and push by digest
98+ id : build
99+ uses : docker/build-push-action@v5
86100 with :
87101 context : .
88102 platforms : ${{ matrix.platform }}
89103 push : true
90104 tags : ${{ steps.meta_dh.outputs.tags }}
91105 labels : ${{ steps.meta_dh.outputs.labels }}
106+ outputs : type=image,name=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }},push-by-digest=true,name-canonical=true,push=true
107+
108+ - name : Export digest
109+ run : |
110+ mkdir -p /tmp/digests
111+ digest="${{ steps.build.outputs.digest }}"
112+ touch "/tmp/digests/${digest#sha256:}"
113+
114+ - name : Upload digest
115+ uses : actions/upload-artifact@v4
116+ with :
117+ name : digests-${{ env.PLATFORM_PAIR }}
118+ path : /tmp/digests/*
119+ if-no-files-found : error
120+ retention-days : 1
121+
122+ merge :
123+ runs-on : ubuntu-latest
124+ needs :
125+ - build
126+ steps :
127+ - name : Download digests
128+ uses : actions/download-artifact@v4
129+ with :
130+ path : /tmp/digests
131+ pattern : digests-*
132+ merge-multiple : true
133+
134+ - name : Set up Docker Buildx
135+ uses : docker/setup-buildx-action@v3
136+
137+ - name : Docker meta
138+ id : meta
139+ uses : docker/metadata-action@v5
140+ with :
141+ images : ${{ env.DOCKER_REGISTRY }}/${{ env.IMAGE_NAME }}
142+
143+ - name : Log in to the Docker Container registry
144+ uses : docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
145+ with :
146+ registry : ${{ env.DOCKER_REGISTRY }}
147+ username : ${{ env.DOCKER_REGISTRY_USER }}
148+ password : ${{ secrets.DH_ACCESS_TOKEN }}
149+
150+ - name : Create manifest list and push
151+ working-directory : /tmp/digests
152+ run : |
153+ docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
154+ $(printf '${{ env.DOCKER_REGISTRY }}/${{ env.IMAGE_NAME }}@sha256:%s ' *)
155+
156+ - name : Inspect image
157+ run : |
158+ docker buildx imagetools inspect ${{ env.DOCKER_REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.meta.outputs.version }}
0 commit comments