@@ -16,8 +16,71 @@ defaults:
1616 run :
1717 shell : bash
1818
19+ env :
20+ REGISTRY_IMAGE : stellar/stellar-cli
21+
1922jobs :
20- docker :
23+ # Build each platform on a native runner and push the image by digest.
24+ build :
25+ strategy :
26+ fail-fast : false
27+ matrix :
28+ include :
29+ - runs-on : ubuntu-latest
30+ platform : linux/amd64
31+ - runs-on : ubuntu-24.04-arm
32+ platform : linux/arm64
33+ runs-on : ${{ matrix.runs-on }}
34+ permissions :
35+ contents : read
36+ steps :
37+ - name : Prepare
38+ run : |
39+ platform="${{ matrix.platform }}"
40+ echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
41+
42+ - uses : actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
43+ with :
44+ ref : ${{ github.event_name == 'workflow_dispatch' && inputs.ref || github.ref }}
45+ fetch-depth : 0
46+
47+ - name : Set up Docker Buildx
48+ uses : docker/setup-buildx-action@d7f5e7f509e45cec5c76c4d5afdd7de93d0b3df5 # v4
49+
50+ - name : Log in to Docker Hub
51+ uses : docker/login-action@650006c6eb7dba73a995cc03b0b2d7f5ca915bee # v4
52+ with :
53+ username : ${{ secrets.DOCKERHUB_USERNAME }}
54+ password : ${{ secrets.DOCKERHUB_TOKEN }}
55+
56+ - name : Build and push by digest
57+ id : build
58+ uses : docker/build-push-action@f9f3042f7e2789586610d6e8b85c8f03e5195baf # v7
59+ with :
60+ context : .
61+ platforms : ${{ matrix.platform }}
62+ build-args : |
63+ STELLAR_CLI_REV=${{ github.event_name == 'workflow_dispatch' && inputs.ref || github.ref_name }}
64+ outputs : type=image,name=${{ env.REGISTRY_IMAGE }},push-by-digest=true,name-canonical=true,push=true
65+
66+ - name : Export digest
67+ run : |
68+ mkdir -p "${{ runner.temp }}/digests"
69+ digest="${{ steps.build.outputs.digest }}"
70+ touch "${{ runner.temp }}/digests/${digest#sha256:}"
71+
72+ - name : Upload digest
73+ uses : actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
74+ with :
75+ name : digests-${{ env.PLATFORM_PAIR }}
76+ path : ${{ runner.temp }}/digests/*
77+ if-no-files-found : error
78+ retention-days : 1
79+
80+ # Combine the per-platform digests into a single multi-arch manifest list
81+ # and push it under the final tags.
82+ merge :
83+ needs : build
2184 runs-on : ubuntu-latest
2285 permissions :
2386 contents : read
2790 ref : ${{ github.event_name == 'workflow_dispatch' && inputs.ref || github.ref }}
2891 fetch-depth : 0
2992
30- - name : Set up QEMU
31- uses : docker/setup-qemu-action@06116385d9baf250c9f4dcb4858b16962ea869c3 # v4
93+ - name : Download digests
94+ uses : actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
95+ with :
96+ path : ${{ runner.temp }}/digests
97+ pattern : digests-*
98+ merge-multiple : true
3299
33100 - name : Set up Docker Buildx
34101 uses : docker/setup-buildx-action@d7f5e7f509e45cec5c76c4d5afdd7de93d0b3df5 # v4
@@ -48,24 +115,20 @@ jobs:
48115
49116 if [[ "$ref" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
50117 version="${ref#v}"
51- echo "DOCKER_TAGS=stellar/stellar-cli :${version},stellar/stellar-cli :latest" >> $GITHUB_ENV
118+ echo "TAGS=-t ${REGISTRY_IMAGE} :${version} -t ${REGISTRY_IMAGE} :latest" >> $GITHUB_ENV
52119 elif [[ "${{ github.event_name }}" == "release" ]]; then
53120 echo "::error::Release tag '${ref}' is not a valid version tag (expected vX.Y.Z)."
54121 exit 1
55122 else
56123 commit="$(git rev-parse HEAD)"
57- echo "DOCKER_TAGS=stellar/stellar-cli :${commit}" >> $GITHUB_ENV
124+ echo "TAGS=-t ${REGISTRY_IMAGE} :${commit}" >> $GITHUB_ENV
58125 fi
59126
60- - name : Build and push
61- uses : docker/build-push-action@f9f3042f7e2789586610d6e8b85c8f03e5195baf # v7
62- with :
63- context : .
64- platforms : linux/amd64,linux/arm64
65- push : true
66- tags : ${{ env.DOCKER_TAGS }}
67- build-args : |
68- STELLAR_CLI_REV=${{ github.event_name == 'workflow_dispatch' && inputs.ref || github.ref_name }}
127+ - name : Create manifest list and push
128+ working-directory : ${{ runner.temp }}/digests
129+ run : |
130+ docker buildx imagetools create ${TAGS} \
131+ $(printf "${REGISTRY_IMAGE}@sha256:%s " *)
69132
70133 - name : Update Docker Hub description
71134 run : |
0 commit comments