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