From 1b74de0a8bcb34a96bcc38a1ed106953fe3f7af6 Mon Sep 17 00:00:00 2001 From: perf3ct Date: Sat, 2 Nov 2024 21:05:52 +0000 Subject: [PATCH] have the latest tag be the same as stable tag get rid of this annoying default "latest" tag useage to squash to squash, I love whitespace --- .github/workflows/main-docker.yml | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main-docker.yml b/.github/workflows/main-docker.yml index a9b7521671..3881212e9f 100644 --- a/.github/workflows/main-docker.yml +++ b/.github/workflows/main-docker.yml @@ -129,6 +129,8 @@ jobs: type=ref,event=branch type=ref,event=tag type=sha + flavor: | + latest=false - name: Set up QEMU uses: docker/setup-qemu-action@v3 @@ -213,7 +215,9 @@ jobs: images: | ${{ env.GHCR_REGISTRY }}/${{ env.IMAGE_NAME }} ${{ env.DOCKERHUB_REGISTRY }}/${{ env.IMAGE_NAME }} - + flavor: | + latest=false + - name: Login to GHCR uses: docker/login-action@v2 with: @@ -233,7 +237,7 @@ jobs: run: | # Extract the branch or tag name from the ref REF_NAME=$(echo "${GITHUB_REF}" | sed 's/refs\/heads\///' | sed 's/refs\/tags\///') - + # Create and push the manifest list with both the branch/tag name and the commit SHA docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \ -t ${{ env.GHCR_REGISTRY }}/${{ env.IMAGE_NAME }}:${REF_NAME} \ @@ -246,6 +250,7 @@ jobs: # If the ref is a tag, also tag the image as stable as this is part of a 'release' # and only go in the `if` if there is NOT a `-` in the tag's name, due to tagging of `-alpha`, `-beta`, etc... if [[ "${GITHUB_REF}" == refs/tags/* && ! "${REF_NAME}" =~ - ]]; then + # First create stable tags docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \ -t ${{ env.GHCR_REGISTRY }}/${{ env.IMAGE_NAME }}:stable \ $(printf '${{ env.GHCR_REGISTRY }}/${{ env.IMAGE_NAME }}@sha256:%s ' *) @@ -253,6 +258,26 @@ jobs: docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \ -t ${{ env.DOCKERHUB_REGISTRY }}/${{ env.IMAGE_NAME }}:stable \ $(printf '${{ env.DOCKERHUB_REGISTRY }}/${{ env.IMAGE_NAME }}@sha256:%s ' *) + + # Verify stable tags + docker buildx imagetools inspect ${{ env.GHCR_REGISTRY }}/${{ env.IMAGE_NAME }}:stable + docker buildx imagetools inspect ${{ env.DOCKERHUB_REGISTRY }}/${{ env.IMAGE_NAME }}:stable + + # Small delay to ensure stable tag is fully propagated + sleep 5 + + # Now update latest tags + docker buildx imagetools create \ + -t ${{ env.GHCR_REGISTRY }}/${{ env.IMAGE_NAME }}:latest \ + ${{ env.GHCR_REGISTRY }}/${{ env.IMAGE_NAME }}:stable + + docker buildx imagetools create \ + -t ${{ env.DOCKERHUB_REGISTRY }}/${{ env.IMAGE_NAME }}:latest \ + ${{ env.DOCKERHUB_REGISTRY }}/${{ env.IMAGE_NAME }}:stable + + # Verify latest tags + docker buildx imagetools inspect ${{ env.GHCR_REGISTRY }}/${{ env.IMAGE_NAME }}:latest + docker buildx imagetools inspect ${{ env.DOCKERHUB_REGISTRY }}/${{ env.IMAGE_NAME }}:latest fi - name: Inspect image