Skip to content

Commit 76c5d7d

Browse files
committed
Add manifest creation for bake.
1 parent 743945a commit 76c5d7d

File tree

2 files changed

+41
-84
lines changed

2 files changed

+41
-84
lines changed

.github/workflows/docker-hub.yml

Lines changed: 7 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -155,10 +155,15 @@ jobs:
155155
needs: [matrix, build]
156156
runs-on: ubuntu-latest
157157
steps:
158+
- name: Checkout Repository
159+
uses: actions/[email protected]
160+
with:
161+
fetch-depth: 0
162+
158163
- name: Download digests
159164
uses: actions/[email protected]
160165
with:
161-
path: /tmp/digests
166+
path: .bake/digests/
162167
pattern: digests-*
163168
merge-multiple: true
164169

@@ -180,86 +185,5 @@ jobs:
180185
password: ${{ secrets.DOCKER_PASSWORD }}
181186

182187
- name: Create manifest list and push
183-
working-directory: /tmp/digests
184188
run: |
185-
ls -laR
186-
187-
# TODO:
188-
# - name: Create manifest list and push
189-
# working-directory: /tmp/digests
190-
# run: |
191-
# IMAGE_HASHES=$(printf '${{ env.DOCKER_USERNAME }}/${{ env.IMAGE_NAME }}@sha256:%s ' *)
192-
# docker buildx imagetools create -t ${{ env.DOCKER_USERNAME }}/${{ env.IMAGE_NAME }}:latest $IMAGE_HASHES
193-
# if [[ "${{ contains(github.ref, 'refs/tags/') }}" = true ]]; then
194-
# TAG=${GITHUB_REF#refs/*/}
195-
# VERSION=${TAG#v}
196-
# docker buildx imagetools create -t ${{ env.REGISTRY_IMAGE }}:${VERSION} $IMAGE_HASHES
197-
# fi
198-
199-
# - name: Inspect image
200-
# run: |
201-
# docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:latest
202-
203-
204-
205-
206-
# manifest:
207-
# name: Create and Push Manifest Lists
208-
# needs: [matrix, build]
209-
# # Only run when master or when tagging a version
210-
# if: (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/')) && github.event_name != 'pull_request'
211-
# runs-on: ubuntu-latest
212-
# steps:
213-
# - name: Login to Docker Hub
214-
# uses: docker/login-action@v3
215-
# with:
216-
# username: ${{ secrets.DOCKER_HUB_USERNAME }}
217-
# password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
218-
219-
# - name: Create and Push Manifest Lists
220-
# run: |
221-
# set -exuo pipefail
222-
223-
# tags=("deps" "dev" "runtime" "cli")
224-
# platforms=($(echo '${{ needs.matrix.outputs.platform_list }}' | jq -r '.[]'))
225-
226-
# echo "Create all the tags by platform"
227-
228-
# for tag in "${tags[@]}"; do
229-
# echo "Creating manifest for tag: $tag"
230-
# platform_tags=""
231-
# for platform in "${platforms[@]}"; do
232-
# platform_tag=$(echo "${platform}" | tr '/' '-')
233-
# platform_tags="${platform_tags} ${DOCKER_REGISTRY}/${DOCKER_USERNAME}/${IMAGE_NAME}:${tag}-${platform_tag}"
234-
# done
235-
# echo "Creating manifest with tags: ${platform_tags}"
236-
# docker manifest create ${DOCKER_REGISTRY}/${DOCKER_USERNAME}/${IMAGE_NAME}:${tag} ${platform_tags} --amend
237-
# docker manifest push ${DOCKER_REGISTRY}/${DOCKER_USERNAME}/${IMAGE_NAME}:${tag}
238-
# done
239-
240-
# echo "Create the latest tag"
241-
242-
# cli_platform_tags=""
243-
# for platform in "${platforms[@]}"; do
244-
# platform_tag=$(echo "${platform}" | tr '/' '-')
245-
# cli_platform_tags="${cli_platform_tags} ${DOCKER_USERNAME}/${IMAGE_NAME}:cli-${platform_tag}"
246-
# done
247-
# docker manifest create ${DOCKER_REGISTRY}/${DOCKER_USERNAME}/${IMAGE_NAME}:latest ${cli_platform_tags} --amend
248-
# docker manifest push ${DOCKER_REGISTRY}/${DOCKER_USERNAME}/${IMAGE_NAME}:latest
249-
250-
# if [[ "${{ startsWith(github.ref, 'refs/tags/') }}" = true ]]; then
251-
# VERSION=${GITHUB_REF#refs/tags/v}
252-
253-
# echo "Create the version ${VERSION} tag"
254-
255-
# for tag in "${tags[@]}"; do
256-
# platform_tags=""
257-
# for platform in "${platforms[@]}"; do
258-
# platform_tag=$(echo "${platform}" | tr '/' '-')
259-
# platform_tags="${platform_tags} ${DOCKER_REGISTRY}/${DOCKER_USERNAME}/${IMAGE_NAME}:${tag}-${platform_tag}"
260-
# done
261-
# docker manifest create ${DOCKER_REGISTRY}/${DOCKER_USERNAME}/${IMAGE_NAME}:${VERSION}-${tag} ${platform_tags} --amend
262-
# docker manifest push ${DOCKER_REGISTRY}/${DOCKER_USERNAME}/${IMAGE_NAME}:${VERSION}-${tag}
263-
# done
264-
# fi
265-
189+
./docker-compose.sh manifest

docker-compose.sh

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ sub_platform() {
208208
rm -rf docker-compose.bake.yml
209209
}
210210

211-
# Build MetaCall Docker Compose with multi-platform specifier
211+
# Build MetaCall Docker Bake with multi-platform specifier
212212
sub_bake() {
213213
if [ -z "${METACALL_PLATFORM+x}" ]; then
214214
echo "Error: METACALL_PLATFORM variable not defined"
@@ -266,6 +266,36 @@ sub_bake() {
266266
done
267267
}
268268

269+
# Create Manifest for multi-platform images from Docker Bake
270+
sub_manifest() {
271+
if [ -z "${DOCKER_USERNAME+x}" ]; then
272+
echo "Error: IMAGE_NAME variable not defined"
273+
exit 1
274+
fi
275+
276+
if [ -z "${IMAGE_NAME+x}" ]; then
277+
echo "Error: IMAGE_NAME variable not defined"
278+
exit 1
279+
fi
280+
281+
# Get current directory
282+
workdir=$(pwd)
283+
284+
for tag in "${METACALL_TAGS[@]}"; do
285+
cd "${workdir}/.bake/digests/${tag}"
286+
image_hashes=$(printf '${DOCKER_USERNAME}/${IMAGE_NAME}@sha256:%s ' *)
287+
docker buildx imagetools create -t ${DOCKER_USERNAME}/${IMAGE_NAME}:${tag} ${image_hashes}
288+
# TODO: Implement versions for each tag
289+
docker buildx imagetools inspect ${DOCKER_USERNAME}/${IMAGE_NAME}:${tag}
290+
291+
if [[ "${tag}" == "cli" ]]; then
292+
docker buildx imagetools create -t ${DOCKER_USERNAME}/${IMAGE_NAME}:latest ${image_hashes}
293+
docker buildx imagetools inspect ${DOCKER_USERNAME}/${IMAGE_NAME}:latest
294+
# TODO: Implement version for latest
295+
fi
296+
done
297+
}
298+
269299
# Push MetaCall Docker Compose
270300
sub_push() {
271301
if [ -z "${IMAGE_NAME+x}" ]; then
@@ -389,6 +419,9 @@ case "$1" in
389419
bake)
390420
sub_bake
391421
;;
422+
manifest)
423+
sub_manifest
424+
;;
392425
push)
393426
sub_push
394427
;;

0 commit comments

Comments
 (0)