1
+ name : Docker
2
+
3
+ on :
4
+ push :
5
+ tags : [ 'v*.*.*' ]
6
+
7
+ env :
8
+ # Use docker.io for Docker Hub if empty
9
+ REGISTRY : docker.io
10
+ # github.repository as <account>/<repo>
11
+ REGISTRY_IMAGE : <dockerhub_account_name_here>/hdkeygen
12
+
13
+
14
+ jobs :
15
+ build :
16
+ runs-on : ubuntu-latest
17
+ strategy :
18
+ fail-fast : false
19
+ matrix :
20
+ platform :
21
+ - linux/amd64
22
+ - linux/arm64
23
+ steps :
24
+ -
25
+ name : Prepare
26
+ run : |
27
+ platform=${{ matrix.platform }}
28
+ echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
29
+ -
30
+ name : Checkout
31
+ uses : actions/checkout@v4
32
+ -
33
+ name : Docker meta
34
+ id : meta
35
+ uses : docker/metadata-action@v5
36
+ with :
37
+ images : ${{ env.REGISTRY_IMAGE }}
38
+ -
39
+ name : Set up QEMU
40
+ uses : docker/setup-qemu-action@v3
41
+ -
42
+ name : Set up Docker Buildx
43
+ uses : docker/setup-buildx-action@v3
44
+ -
45
+ name : Login to Docker Hub
46
+ uses : docker/login-action@v3
47
+ with :
48
+ username : <dockerhub_account_name_here>
49
+ password : ${{ secrets.DOCKERHUB_TOKEN }}
50
+ -
51
+ name : Build and push by digest
52
+ id : build
53
+ uses : docker/build-push-action@v5
54
+ with :
55
+ context : .
56
+ platforms : ${{ matrix.platform }}
57
+ file : Dockerfile
58
+ labels : ${{ steps.meta.outputs.labels }}
59
+ outputs : type=image,name=${{ env.REGISTRY_IMAGE }},push-by-digest=true,name-canonical=true,push=true
60
+ -
61
+ name : Export digest
62
+ run : |
63
+ mkdir -p /tmp/digests
64
+ digest="${{ steps.build.outputs.digest }}"
65
+ touch "/tmp/digests/${digest#sha256:}"
66
+ -
67
+ name : Upload digest
68
+ uses : actions/upload-artifact@v4
69
+ with :
70
+ name : digests-${{ env.PLATFORM_PAIR }}
71
+ path : /tmp/digests/*
72
+ if-no-files-found : error
73
+ retention-days : 1
74
+
75
+ merge :
76
+ runs-on : ubuntu-latest
77
+ needs :
78
+ - build
79
+ steps :
80
+ -
81
+ name : Download digests
82
+ uses : actions/download-artifact@v4
83
+ with :
84
+ path : /tmp/digests
85
+ pattern : digests-*
86
+ merge-multiple : true
87
+ -
88
+ name : Set up Docker Buildx
89
+ uses : docker/setup-buildx-action@v3
90
+ -
91
+ name : Docker meta
92
+ id : meta
93
+ uses : docker/metadata-action@v5
94
+ with :
95
+ images : ${{ env.REGISTRY_IMAGE }}
96
+ -
97
+ name : Login to Docker Hub
98
+ uses : docker/login-action@v3
99
+ with :
100
+ username : <dockerhub_account_name_here>
101
+ password : ${{ secrets.DOCKERHUB_TOKEN }}
102
+ -
103
+ name : Create manifest list and push
104
+ working-directory : /tmp/digests
105
+ run : |
106
+ docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
107
+ $(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *)
108
+ -
109
+ name : Inspect image
110
+ run : |
111
+ docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ steps.meta.outputs.version }}
0 commit comments