@@ -3,40 +3,72 @@ name: Docker Image
3
3
4
4
on :
5
5
push :
6
- tags : [ '*.*.*' ]
6
+ # tags: [ '*.*.*' ]
7
7
8
8
env :
9
9
REGISTRY_IMAGE : ghcr.io/rgrizzell/circuitpython
10
10
11
11
jobs :
12
+ prepare :
13
+ runs-on : ubuntu-latest
14
+ outputs :
15
+ matrix : ${{ steps.platforms.outputs.matrix }}
16
+ steps :
17
+ - name : Checkout
18
+ uses : actions/checkout@v4
19
+
20
+ - name : Create matrix
21
+ id : platforms
22
+ run : |
23
+ echo "matrix=$(docker buildx bake runtime --print | jq -cr '.target."runtime".platforms')" >>${GITHUB_OUTPUT}
24
+
25
+ - name : Show matrix
26
+ run : |
27
+ echo ${{ steps.platforms.outputs.matrix }}
28
+
29
+ - name : Docker meta
30
+ id : meta
31
+ uses : docker/metadata-action@v5
32
+ with :
33
+ images : ${{ env.REGISTRY_IMAGE }}
34
+ annotations : |
35
+ org.opencontainers.image.description=CircuitPython for Unix/Linux
36
+ org.opencontainers.image.license=MIT
37
+
38
+ - name : Rename meta bake definition file
39
+ run : |
40
+ mv "${{ steps.meta.outputs.bake-file }}" "/tmp/bake-meta.json"
41
+
42
+ - name : Upload meta bake definition
43
+ uses : actions/upload-artifact@v4
44
+ with :
45
+ name : bake-meta
46
+ path : /tmp/bake-meta.json
47
+ if-no-files-found : error
48
+ retention-days : 1
49
+
12
50
build :
13
51
runs-on : ubuntu-latest
52
+ needs :
53
+ - prepare
14
54
strategy :
15
55
fail-fast : false
16
56
matrix :
17
- platform :
18
- - linux/amd64
19
- - linux/arm64
57
+ platform : ${{ fromJson(needs.prepare.outputs.matrix) }}
20
58
steps :
21
59
- name : Prepare
22
60
run : |
23
61
platform=${{ matrix.platform }}
24
- echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
62
+ echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
25
63
26
64
- name : Checkout
27
65
uses : actions/checkout@v4
28
66
29
- - name : Docker meta
30
- id : meta
31
- uses : docker/metadata-action@v5
67
+ - name : Download meta bake definition
68
+ uses : actions/download-artifact@v4
32
69
with :
33
- images : ${{ env.REGISTRY_IMAGE }}
34
-
35
- - name : Set up QEMU
36
- uses : docker/setup-qemu-action@v3
37
-
38
- - name : Set up Docker Buildx
39
- uses : docker/setup-buildx-action@v3
70
+ name : bake-meta
71
+ path : /tmp
40
72
41
73
- name : Login to GitHub Container Registry
42
74
uses : docker/login-action@v3
@@ -45,20 +77,30 @@ jobs:
45
77
username : ${{ github.repository_owner }}
46
78
password : ${{ secrets.GITHUB_TOKEN }}
47
79
48
- - name : Build and push by digest
49
- id : build
50
- uses : docker/build-push-action@v5
80
+ - name : Set up QEMU
81
+ uses : docker/setup-qemu-action@v3
82
+
83
+ - name : Set up Docker Buildx
84
+ uses : docker/setup-buildx-action@v3
85
+
86
+ - name : Build
87
+ id : bake
88
+ uses : docker/bake-action@v5
51
89
with :
52
- context : .
53
- platforms : ${{ matrix.platform }}
54
- labels : ${{ steps.meta.outputs.labels }}
55
- outputs : type=image,name=${{ env.REGISTRY_IMAGE }},push-by-digest=true,name-canonical=true,push=true,annotation-index.org.opencontainers.image.description=CircuitPython for Linux,annotation-index.org.opencontainers.image.license=MIT
90
+ files : |
91
+ ./docker-bake.hcl
92
+ /tmp/bake-meta.json
93
+ targets : image
94
+ set : |
95
+ *.tags=
96
+ *.platform=${{ matrix.platform }}
97
+ *.output=type=image,"name=${{ env.REGISTRY_IMAGE }}",push-by-digest=true,name-canonical=true,push=true
56
98
57
99
- name : Export digest
58
100
run : |
59
101
mkdir -p /tmp/digests
60
- digest="${{ steps.build .outputs.digest }}"
61
- touch "/tmp/digests/${digest#sha256:}"
102
+ digest="${{ fromJSON( steps.bake .outputs.metadata).image['containerimage. digest'] }}"
103
+ touch "/tmp/digests/${digest#sha256:}"
62
104
63
105
- name : Upload digest
64
106
uses : actions/upload-artifact@v4
@@ -73,35 +115,35 @@ jobs:
73
115
needs :
74
116
- build
75
117
steps :
118
+ - name : Download meta bake definition
119
+ uses : actions/download-artifact@v4
120
+ with :
121
+ name : bake-meta
122
+ path : /tmp
123
+
76
124
- name : Download digests
77
125
uses : actions/download-artifact@v4
78
126
with :
79
127
path : /tmp/digests
80
128
pattern : digests-*
81
129
merge-multiple : true
82
130
83
- - name : Set up Docker Buildx
84
- uses : docker/setup-buildx-action@v3
85
-
86
- - name : Docker meta
87
- id : meta
88
- uses : docker/metadata-action@v5
89
- with :
90
- images : ${{ env.REGISTRY_IMAGE }}
91
-
92
131
- name : Login to GitHub Container Registry
93
132
uses : docker/login-action@v3
94
133
with :
95
134
registry : ghcr.io
96
135
username : ${{ github.repository_owner }}
97
136
password : ${{ secrets.GITHUB_TOKEN }}
98
137
138
+ - name : Set up Docker Buildx
139
+ uses : docker/setup-buildx-action@v3
140
+
99
141
- name : Create manifest list and push
100
142
working-directory : /tmp/digests
101
143
run : |
102
- docker buildx imagetools create $(jq -cr '.tags | map(" -t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON" ) \
103
- $(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *)
144
+ docker buildx imagetools create $(jq -cr '.target."docker-metadata-action". tags | map(select(startswith("${{ env.REGISTRY_IMAGE }}")) | " -t " + .) | join(" ")' /tmp/bake-meta.json ) \
145
+ $(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *)
104
146
105
147
- name : Inspect image
106
148
run : |
107
- docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ steps.meta.outputs.version }}
149
+ docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:$(jq -r '.target."docker-metadata-action".args.DOCKER_META_VERSION' /tmp/bake-meta.json)
0 commit comments