1
1
name : Upload Python Package
2
2
3
3
on :
4
+ push :
4
5
release :
5
6
types : [published]
6
7
7
8
env :
8
9
REGISTRY : ghcr.io
9
10
DOCKER_REGISTRY : docker.io
10
- DOCKER_REGISTRY_USER : pinto0309
11
+ DOCKER_REGISTRY_USER : sohma440
11
12
IMAGE_NAME : ${{ github.repository }}
12
13
13
14
jobs :
14
15
pypi-deploy :
16
+ # todo
17
+ if : ${{ false }}
15
18
runs-on : ubuntu-latest
16
19
steps :
17
20
- uses : actions/checkout@v3
@@ -32,16 +35,19 @@ jobs:
32
35
user : __token__
33
36
password : ${{ secrets.PYPI_API_TOKEN }}
34
37
35
- docker-deploy :
38
+ build :
36
39
runs-on : ubuntu-latest
37
- needs : pypi-deploy
40
+ # todo
41
+ # needs: pypi-deploy
38
42
permissions :
39
43
contents : read
40
44
packages : write
41
45
strategy :
42
46
fail-fast : false # do not cancel even if any platform fails.
43
47
matrix :
44
- platform : [linux/amd64,linux/arm64]
48
+ platform :
49
+ - linux/amd64
50
+ - linux/arm64
45
51
steps :
46
52
- name : Git checkout
47
53
uses : actions/checkout@v3
50
56
- name : Set up QEMU
51
57
uses : docker/setup-qemu-action@v3
52
58
59
+ - name : Prepare
60
+ run : |
61
+ platform=${{ matrix.platform }}
62
+ echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
63
+
53
64
- name : Log in to the GitHub Container registry
54
65
uses : docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
55
66
with :
61
72
uses : docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
62
73
with :
63
74
images : ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
75
+
64
76
- name : Build and push Docker image
65
77
uses : docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
66
78
with :
@@ -81,11 +93,66 @@ jobs:
81
93
uses : docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
82
94
with :
83
95
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
86
100
with :
87
101
context : .
88
102
platforms : ${{ matrix.platform }}
89
103
push : true
90
104
tags : ${{ steps.meta_dh.outputs.tags }}
91
105
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