From cc8a20da29532eec5c40e3f7ee190020832a007b Mon Sep 17 00:00:00 2001 From: Yves Date: Thu, 6 Feb 2025 15:17:57 +0100 Subject: [PATCH 1/9] Merge images --- .github/workflows/docker.yaml | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml index fb0039ab..7d43e469 100644 --- a/.github/workflows/docker.yaml +++ b/.github/workflows/docker.yaml @@ -13,8 +13,8 @@ on: workflow_dispatch: jobs: - docker: - name: Build Docker + docker_build: + name: Build Docker image for Postgres ${{ matrix.postgres }} on ${{ matrix.runner }} strategy: matrix: postgres: ["14", "15", "16", "17"] @@ -36,6 +36,7 @@ jobs: uses: actions/checkout@v4 with: submodules: "recursive" + - name: Compute platform id: compute_platform run: | @@ -65,3 +66,28 @@ jobs: *.cache-from=type=gha postgres.tags=pgduckdb/pgduckdb:${{ matrix.postgres }}-${{ steps.compute_platform.outputs.platform }}-${{ github.sha }} ${{ !contains(github.ref_name, '/') && format('postgres.tags=pgduckdb/pgduckdb:{0}-${1}-{2}', matrix.postgres, steps.compute_platform.outputs.platform, github.ref_name) || '' }} + + docker_merge: + name: Merge Docker image for Postgres ${{ matrix.postgres }} + strategy: + matrix: + postgres: ["14", "15", "16", "17"] + + runs-on: ubuntu-24.04 + needs: docker_build + steps: + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: pgduckdb + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Pull images + run: | + docker pull pgduckdb/pgduckdb:${{ matrix.postgres }}-amd64-${{ github.sha }} + docker pull pgduckdb/pgduckdb:${{ matrix.postgres }}-arm64-${{ github.sha }} + docker manifest create \ + pgduckdb/pgduckdb:${{ matrix.postgres }}-${{ github.sha }} \ + --amend pgduckdb/pgduckdb:${{ matrix.postgres }}-amd64-${{ github.sha }} \ + --amend pgduckdb/pgduckdb:${{ matrix.postgres }}-arm64-${{ github.sha }} + docker manifest push pgduckdb/pgduckdb:${{ matrix.postgres }}-${{ github.sha }} From 7205504b515a5e55019f976a7faf247e3b795080 Mon Sep 17 00:00:00 2001 From: Yves Date: Thu, 6 Feb 2025 15:59:05 +0100 Subject: [PATCH 2/9] Update docker.yaml --- .github/workflows/docker.yaml | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml index 7d43e469..3dd7ba28 100644 --- a/.github/workflows/docker.yaml +++ b/.github/workflows/docker.yaml @@ -40,6 +40,14 @@ jobs: - name: Compute platform id: compute_platform run: | + # Tag is XX-YYYYY--latest so 16 + branch name length + # since maximum docker tag is 128 characters, we need to truncate the branch name to 112 + BRANCH=$(echo "${{ github.head_ref || github.ref_name }}" \ + | sed 's/[^a-zA-Z0-9\-]/-/g' \ + | cut -c 1-112 | tr '[:upper:]' '[:lower:]' \ + | sed -e 's/-*$//') + + echo "branch_tag=$BRANCH" >> "$GITHUB_OUTPUT" # Set platform depending on which runner we're using if [ "${{ matrix.runner }}" = "ubuntu-24.04" ]; then echo "platform=amd64" >> "$GITHUB_OUTPUT" @@ -47,6 +55,11 @@ jobs: echo "platform=arm64" >> "$GITHUB_OUTPUT" fi + - name: Attempt to pull previous image + run: | + docker pull pgduckdb/pgduckdb:${{ matrix.postgres }}-${{ steps.compute_platform.outputs.platform }}-${{ steps.compute_platform.outputs.branch_tag }}-latest || true + + - name: Set up QEMU uses: docker/setup-qemu-action@v3 @@ -65,7 +78,7 @@ jobs: *.cache-to=type=gha,mode=max *.cache-from=type=gha postgres.tags=pgduckdb/pgduckdb:${{ matrix.postgres }}-${{ steps.compute_platform.outputs.platform }}-${{ github.sha }} - ${{ !contains(github.ref_name, '/') && format('postgres.tags=pgduckdb/pgduckdb:{0}-${1}-{2}', matrix.postgres, steps.compute_platform.outputs.platform, github.ref_name) || '' }} + postgres.tags=pgduckdb/pgduckdb:${{ matrix.postgres }}-${{ steps.compute_platform.outputs.platform }}-${{ steps.compute_platform.outputs.branch_tag }}-latest docker_merge: name: Merge Docker image for Postgres ${{ matrix.postgres }} @@ -84,8 +97,8 @@ jobs: - name: Pull images run: | - docker pull pgduckdb/pgduckdb:${{ matrix.postgres }}-amd64-${{ github.sha }} - docker pull pgduckdb/pgduckdb:${{ matrix.postgres }}-arm64-${{ github.sha }} + docker pull --platform linux/amd64 pgduckdb/pgduckdb:${{ matrix.postgres }}-amd64-${{ github.sha }} + docker pull --platform linux/arm64 pgduckdb/pgduckdb:${{ matrix.postgres }}-arm64-${{ github.sha }} docker manifest create \ pgduckdb/pgduckdb:${{ matrix.postgres }}-${{ github.sha }} \ --amend pgduckdb/pgduckdb:${{ matrix.postgres }}-amd64-${{ github.sha }} \ From 732a3eb4253eeefbb0dad7c7ae74934074c97155 Mon Sep 17 00:00:00 2001 From: Yves Date: Fri, 7 Feb 2025 09:34:26 +0100 Subject: [PATCH 3/9] Update docker.yaml --- .github/workflows/docker.yaml | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml index 3dd7ba28..6dd5afc2 100644 --- a/.github/workflows/docker.yaml +++ b/.github/workflows/docker.yaml @@ -25,6 +25,8 @@ jobs: env: BUILDKIT_PROGRESS: plain POSTGRES_VERSION: ${{ matrix.postgres }} + outputs: + branch_tag: ${{ steps.compute_platform.outputs.branch_tag }} steps: - name: Login to Docker Hub uses: docker/login-action@v3 @@ -99,8 +101,13 @@ jobs: run: | docker pull --platform linux/amd64 pgduckdb/pgduckdb:${{ matrix.postgres }}-amd64-${{ github.sha }} docker pull --platform linux/arm64 pgduckdb/pgduckdb:${{ matrix.postgres }}-arm64-${{ github.sha }} - docker manifest create \ - pgduckdb/pgduckdb:${{ matrix.postgres }}-${{ github.sha }} \ - --amend pgduckdb/pgduckdb:${{ matrix.postgres }}-amd64-${{ github.sha }} \ - --amend pgduckdb/pgduckdb:${{ matrix.postgres }}-arm64-${{ github.sha }} - docker manifest push pgduckdb/pgduckdb:${{ matrix.postgres }}-${{ github.sha }} + + BRANCH="${{ needs.docker_build.outputs.branch_tag }}" + + docker buildx imagetools create \ + --tag pgduckdb/pgduckdb:${{ matrix.postgres }}-${{ github.sha }} \ + --tag pgduckdb/pgduckdb:${{ matrix.postgres }}-${BRANCH}-latest \ + pgduckdb/pgduckdb:${{ matrix.postgres }}-amd64-${{ github.sha }} \ + pgduckdb/pgduckdb:${{ matrix.postgres }}-arm64-${{ github.sha }} + + docker buildx imagetools inspect pgduckdb/pgduckdb:${{ matrix.postgres }}-${{ github.sha }} From ef9ea041983b48b742e88b7575ac0eba3ced64b5 Mon Sep 17 00:00:00 2001 From: Yves Date: Fri, 7 Feb 2025 14:30:40 +0100 Subject: [PATCH 4/9] Update docker.yaml --- .github/workflows/docker.yaml | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml index 6dd5afc2..e3c33cbe 100644 --- a/.github/workflows/docker.yaml +++ b/.github/workflows/docker.yaml @@ -1,5 +1,9 @@ name: Build Docker +permissions: + id-token: write + contents: write + on: push: tags: ["v*"] @@ -34,6 +38,13 @@ jobs: username: pgduckdb password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Login to GitHub Containers + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GH_TOKEN }} + - name: Checkout pg_duckdb extension code uses: actions/checkout@v4 with: @@ -60,7 +71,7 @@ jobs: - name: Attempt to pull previous image run: | docker pull pgduckdb/pgduckdb:${{ matrix.postgres }}-${{ steps.compute_platform.outputs.platform }}-${{ steps.compute_platform.outputs.branch_tag }}-latest || true - + docker pull ghcr.io/duckdb/pg_duckdb:${{ matrix.postgres }}-${{ steps.compute_platform.outputs.platform }}-${{ steps.compute_platform.outputs.branch_tag }}-latest || true - name: Set up QEMU uses: docker/setup-qemu-action@v3 @@ -78,9 +89,11 @@ jobs: set: | *.platform=linux/${{ steps.compute_platform.outputs.platform }} *.cache-to=type=gha,mode=max + *.cache-from=type=registry,ref=pgduckdb/pgduckdb:${{ matrix.postgres }}-${{ steps.compute_platform.outputs.platform }}-${{ steps.compute_platform.outputs.branch_tag }}-latest + *.cache-from=type=registry,ref=ghcr.io/duckdb/pg_duckdb:${{ matrix.postgres }}-${{ steps.compute_platform.outputs.platform }}-${{ steps.compute_platform.outputs.branch_tag }}-latest *.cache-from=type=gha - postgres.tags=pgduckdb/pgduckdb:${{ matrix.postgres }}-${{ steps.compute_platform.outputs.platform }}-${{ github.sha }} - postgres.tags=pgduckdb/pgduckdb:${{ matrix.postgres }}-${{ steps.compute_platform.outputs.platform }}-${{ steps.compute_platform.outputs.branch_tag }}-latest + postgres.tags=ghcr.io/duckdb/pg_duckdb:${{ matrix.postgres }}-${{ steps.compute_platform.outputs.platform }}-${{ github.sha }} + postgres.tags=ghcr.io/duckdb/pg_duckdb:${{ matrix.postgres }}-${{ steps.compute_platform.outputs.platform }}-${{ steps.compute_platform.outputs.branch_tag }}-latest docker_merge: name: Merge Docker image for Postgres ${{ matrix.postgres }} From 95bfdbb206a0f1cd8856be71f71fb86869ed5f08 Mon Sep 17 00:00:00 2001 From: Yves Date: Fri, 7 Feb 2025 14:39:29 +0100 Subject: [PATCH 5/9] Update docker.yaml --- .github/workflows/docker.yaml | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml index e3c33cbe..881d7343 100644 --- a/.github/workflows/docker.yaml +++ b/.github/workflows/docker.yaml @@ -38,13 +38,6 @@ jobs: username: pgduckdb password: ${{ secrets.DOCKERHUB_TOKEN }} - - name: Login to GitHub Containers - uses: docker/login-action@v3 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GH_TOKEN }} - - name: Checkout pg_duckdb extension code uses: actions/checkout@v4 with: @@ -71,7 +64,7 @@ jobs: - name: Attempt to pull previous image run: | docker pull pgduckdb/pgduckdb:${{ matrix.postgres }}-${{ steps.compute_platform.outputs.platform }}-${{ steps.compute_platform.outputs.branch_tag }}-latest || true - docker pull ghcr.io/duckdb/pg_duckdb:${{ matrix.postgres }}-${{ steps.compute_platform.outputs.platform }}-${{ steps.compute_platform.outputs.branch_tag }}-latest || true + docker pull pgduckdb/ci-builds:${{ matrix.postgres }}-${{ steps.compute_platform.outputs.platform }}-${{ steps.compute_platform.outputs.branch_tag }}-latest || true - name: Set up QEMU uses: docker/setup-qemu-action@v3 @@ -90,10 +83,10 @@ jobs: *.platform=linux/${{ steps.compute_platform.outputs.platform }} *.cache-to=type=gha,mode=max *.cache-from=type=registry,ref=pgduckdb/pgduckdb:${{ matrix.postgres }}-${{ steps.compute_platform.outputs.platform }}-${{ steps.compute_platform.outputs.branch_tag }}-latest - *.cache-from=type=registry,ref=ghcr.io/duckdb/pg_duckdb:${{ matrix.postgres }}-${{ steps.compute_platform.outputs.platform }}-${{ steps.compute_platform.outputs.branch_tag }}-latest + *.cache-from=type=registry,ref=pgduckdb/ci-builds:${{ matrix.postgres }}-${{ steps.compute_platform.outputs.platform }}-${{ steps.compute_platform.outputs.branch_tag }}-latest *.cache-from=type=gha - postgres.tags=ghcr.io/duckdb/pg_duckdb:${{ matrix.postgres }}-${{ steps.compute_platform.outputs.platform }}-${{ github.sha }} - postgres.tags=ghcr.io/duckdb/pg_duckdb:${{ matrix.postgres }}-${{ steps.compute_platform.outputs.platform }}-${{ steps.compute_platform.outputs.branch_tag }}-latest + postgres.tags=pgduckdb/ci-builds:${{ matrix.postgres }}-${{ steps.compute_platform.outputs.platform }}-${{ github.sha }} + postgres.tags=pgduckdb/ci-builds:${{ matrix.postgres }}-${{ steps.compute_platform.outputs.platform }}-${{ steps.compute_platform.outputs.branch_tag }}-latest docker_merge: name: Merge Docker image for Postgres ${{ matrix.postgres }} @@ -112,15 +105,15 @@ jobs: - name: Pull images run: | - docker pull --platform linux/amd64 pgduckdb/pgduckdb:${{ matrix.postgres }}-amd64-${{ github.sha }} - docker pull --platform linux/arm64 pgduckdb/pgduckdb:${{ matrix.postgres }}-arm64-${{ github.sha }} + docker pull --platform linux/amd64 pgduckdb/ci-builds:${{ matrix.postgres }}-amd64-${{ github.sha }} + docker pull --platform linux/arm64 pgduckdb/ci-builds:${{ matrix.postgres }}-arm64-${{ github.sha }} BRANCH="${{ needs.docker_build.outputs.branch_tag }}" docker buildx imagetools create \ --tag pgduckdb/pgduckdb:${{ matrix.postgres }}-${{ github.sha }} \ --tag pgduckdb/pgduckdb:${{ matrix.postgres }}-${BRANCH}-latest \ - pgduckdb/pgduckdb:${{ matrix.postgres }}-amd64-${{ github.sha }} \ - pgduckdb/pgduckdb:${{ matrix.postgres }}-arm64-${{ github.sha }} + pgduckdb/ci-builds:${{ matrix.postgres }}-amd64-${{ github.sha }} \ + pgduckdb/ci-builds:${{ matrix.postgres }}-arm64-${{ github.sha }} docker buildx imagetools inspect pgduckdb/pgduckdb:${{ matrix.postgres }}-${{ github.sha }} From 61f26872ce598a09403cbb9b3c21114c22e16be1 Mon Sep 17 00:00:00 2001 From: Yves Date: Fri, 7 Feb 2025 15:25:44 +0100 Subject: [PATCH 6/9] Update docker.yaml --- .github/workflows/docker.yaml | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml index 881d7343..160c451a 100644 --- a/.github/workflows/docker.yaml +++ b/.github/workflows/docker.yaml @@ -63,7 +63,6 @@ jobs: - name: Attempt to pull previous image run: | - docker pull pgduckdb/pgduckdb:${{ matrix.postgres }}-${{ steps.compute_platform.outputs.platform }}-${{ steps.compute_platform.outputs.branch_tag }}-latest || true docker pull pgduckdb/ci-builds:${{ matrix.postgres }}-${{ steps.compute_platform.outputs.platform }}-${{ steps.compute_platform.outputs.branch_tag }}-latest || true - name: Set up QEMU @@ -82,7 +81,6 @@ jobs: set: | *.platform=linux/${{ steps.compute_platform.outputs.platform }} *.cache-to=type=gha,mode=max - *.cache-from=type=registry,ref=pgduckdb/pgduckdb:${{ matrix.postgres }}-${{ steps.compute_platform.outputs.platform }}-${{ steps.compute_platform.outputs.branch_tag }}-latest *.cache-from=type=registry,ref=pgduckdb/ci-builds:${{ matrix.postgres }}-${{ steps.compute_platform.outputs.platform }}-${{ steps.compute_platform.outputs.branch_tag }}-latest *.cache-from=type=gha postgres.tags=pgduckdb/ci-builds:${{ matrix.postgres }}-${{ steps.compute_platform.outputs.platform }}-${{ github.sha }} @@ -103,17 +101,25 @@ jobs: username: pgduckdb password: ${{ secrets.DOCKERHUB_TOKEN }} - - name: Pull images + - name: Merge images run: | docker pull --platform linux/amd64 pgduckdb/ci-builds:${{ matrix.postgres }}-amd64-${{ github.sha }} docker pull --platform linux/arm64 pgduckdb/ci-builds:${{ matrix.postgres }}-arm64-${{ github.sha }} BRANCH="${{ needs.docker_build.outputs.branch_tag }}" - docker buildx imagetools create \ - --tag pgduckdb/pgduckdb:${{ matrix.postgres }}-${{ github.sha }} \ - --tag pgduckdb/pgduckdb:${{ matrix.postgres }}-${BRANCH}-latest \ + # If main or tag, then push to `pgduckdb/pgduckdb` + if [ "$BRANCH" = "main" ] || [ "$BRANCH" = "v"* ]; then + TARGET_REPO='pgduckdb/pgduckdb' + else + TARGET_REPO='pgduckdb/ci-builds' + SHA_TAG="--tag ${TARGET_REPO}:${{ matrix.postgres }}-${{ github.sha }}" + fi + + echo "Will push merged image to '${TARGET_REPO}'." + docker buildx imagetools create ${SHA_TAG} \ + --tag ${TARGET_REPO}:${{ matrix.postgres }}-${BRANCH} \ pgduckdb/ci-builds:${{ matrix.postgres }}-amd64-${{ github.sha }} \ pgduckdb/ci-builds:${{ matrix.postgres }}-arm64-${{ github.sha }} - docker buildx imagetools inspect pgduckdb/pgduckdb:${{ matrix.postgres }}-${{ github.sha }} + docker buildx imagetools inspect ${TARGET_REPO}:${{ matrix.postgres }}-${{ github.sha }} From 621cc4fee7b970a7276bbbd2c013a72ce6a036d3 Mon Sep 17 00:00:00 2001 From: Yves Date: Fri, 7 Feb 2025 15:43:48 +0100 Subject: [PATCH 7/9] Update docker.yaml --- .github/workflows/docker.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml index 160c451a..f9eaf038 100644 --- a/.github/workflows/docker.yaml +++ b/.github/workflows/docker.yaml @@ -80,9 +80,9 @@ jobs: push: true set: | *.platform=linux/${{ steps.compute_platform.outputs.platform }} - *.cache-to=type=gha,mode=max *.cache-from=type=registry,ref=pgduckdb/ci-builds:${{ matrix.postgres }}-${{ steps.compute_platform.outputs.platform }}-${{ steps.compute_platform.outputs.branch_tag }}-latest - *.cache-from=type=gha + *.cache-from=type=gha,scope=${{ github.workflow }} + *.cache-to=type=gha,mode=max,scope=${{ github.workflow }} postgres.tags=pgduckdb/ci-builds:${{ matrix.postgres }}-${{ steps.compute_platform.outputs.platform }}-${{ github.sha }} postgres.tags=pgduckdb/ci-builds:${{ matrix.postgres }}-${{ steps.compute_platform.outputs.platform }}-${{ steps.compute_platform.outputs.branch_tag }}-latest From dad2cc5b074faa7d7ddbc6321177237213294b0b Mon Sep 17 00:00:00 2001 From: Yves Date: Fri, 7 Feb 2025 16:06:34 +0100 Subject: [PATCH 8/9] Update docker.yaml --- .github/workflows/docker.yaml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml index f9eaf038..1958e564 100644 --- a/.github/workflows/docker.yaml +++ b/.github/workflows/docker.yaml @@ -64,9 +64,7 @@ jobs: - name: Attempt to pull previous image run: | docker pull pgduckdb/ci-builds:${{ matrix.postgres }}-${{ steps.compute_platform.outputs.platform }}-${{ steps.compute_platform.outputs.branch_tag }}-latest || true - - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 + docker pull moby/buildkit:buildx-stable-1 - name: Set up Docker buildx uses: docker/setup-buildx-action@v3 From e7debff51bf6de4ad795647b7da5588f54aba888 Mon Sep 17 00:00:00 2001 From: Yves Date: Mon, 10 Feb 2025 11:22:04 +0100 Subject: [PATCH 9/9] Fix build on tag --- .github/workflows/docker.yaml | 55 ++++++++++++++++++++--------------- 1 file changed, 31 insertions(+), 24 deletions(-) diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml index 1958e564..38c3dc0b 100644 --- a/.github/workflows/docker.yaml +++ b/.github/workflows/docker.yaml @@ -30,7 +30,8 @@ jobs: BUILDKIT_PROGRESS: plain POSTGRES_VERSION: ${{ matrix.postgres }} outputs: - branch_tag: ${{ steps.compute_platform.outputs.branch_tag }} + branch_tag: ${{ steps.params.outputs.branch_tag }} + target_repo: ${{ steps.params.outputs.target_repo }} steps: - name: Login to Docker Hub uses: docker/login-action@v3 @@ -43,33 +44,45 @@ jobs: with: submodules: "recursive" - - name: Compute platform - id: compute_platform + - name: Compute job parameters + id: params run: | # Tag is XX-YYYYY--latest so 16 + branch name length # since maximum docker tag is 128 characters, we need to truncate the branch name to 112 BRANCH=$(echo "${{ github.head_ref || github.ref_name }}" \ - | sed 's/[^a-zA-Z0-9\-]/-/g' \ + | sed 's/[^a-zA-Z0-9\-\.]/-/g' \ | cut -c 1-112 | tr '[:upper:]' '[:lower:]' \ | sed -e 's/-*$//') - echo "branch_tag=$BRANCH" >> "$GITHUB_OUTPUT" # Set platform depending on which runner we're using if [ "${{ matrix.runner }}" = "ubuntu-24.04" ]; then - echo "platform=amd64" >> "$GITHUB_OUTPUT" + PLATFORM=amd64 + else + PLATFORM=arm64 + fi + + # If main or tag, then push to `pgduckdb/pgduckdb` + git fetch --tags + if [ "$BRANCH" = "main" ] || git rev-parse --verify $BRANCH^{tag} > /dev/null 2>&1; then + TARGET_REPO='pgduckdb/pgduckdb' else - echo "platform=arm64" >> "$GITHUB_OUTPUT" + TARGET_REPO='pgduckdb/ci-builds' fi + echo "platform=$PLATFORM" >> "$GITHUB_OUTPUT" + echo "branch_tag=$BRANCH" >> "$GITHUB_OUTPUT" + echo "target_repo=$TARGET_REPO" >> "$GITHUB_OUTPUT" + echo "latest_image=pgduckdb/ci-builds:${{ matrix.postgres }}-${PLATFORM}-${BRANCH}-latest" >> "$GITHUB_OUTPUT" + - name: Attempt to pull previous image run: | - docker pull pgduckdb/ci-builds:${{ matrix.postgres }}-${{ steps.compute_platform.outputs.platform }}-${{ steps.compute_platform.outputs.branch_tag }}-latest || true + docker pull ${{ steps.params.outputs.latest_image }} || true docker pull moby/buildkit:buildx-stable-1 - name: Set up Docker buildx uses: docker/setup-buildx-action@v3 with: - platforms: linux/${{ steps.compute_platform.outputs.platform }} + platforms: linux/${{ steps.params.outputs.platform }} - name: docker bake uses: docker/bake-action@v5 @@ -77,12 +90,12 @@ jobs: targets: pg_duckdb_${{ matrix.postgres }} push: true set: | - *.platform=linux/${{ steps.compute_platform.outputs.platform }} - *.cache-from=type=registry,ref=pgduckdb/ci-builds:${{ matrix.postgres }}-${{ steps.compute_platform.outputs.platform }}-${{ steps.compute_platform.outputs.branch_tag }}-latest + *.platform=linux/${{ steps.params.outputs.platform }} + *.cache-from=type=registry,ref=${{ steps.params.outputs.latest_image }} *.cache-from=type=gha,scope=${{ github.workflow }} *.cache-to=type=gha,mode=max,scope=${{ github.workflow }} - postgres.tags=pgduckdb/ci-builds:${{ matrix.postgres }}-${{ steps.compute_platform.outputs.platform }}-${{ github.sha }} - postgres.tags=pgduckdb/ci-builds:${{ matrix.postgres }}-${{ steps.compute_platform.outputs.platform }}-${{ steps.compute_platform.outputs.branch_tag }}-latest + postgres.tags=pgduckdb/ci-builds:${{ matrix.postgres }}-${{ steps.params.outputs.platform }}-${{ github.sha }} + postgres.tags=${{ steps.params.outputs.latest_image }} docker_merge: name: Merge Docker image for Postgres ${{ matrix.postgres }} @@ -105,19 +118,13 @@ jobs: docker pull --platform linux/arm64 pgduckdb/ci-builds:${{ matrix.postgres }}-arm64-${{ github.sha }} BRANCH="${{ needs.docker_build.outputs.branch_tag }}" - - # If main or tag, then push to `pgduckdb/pgduckdb` - if [ "$BRANCH" = "main" ] || [ "$BRANCH" = "v"* ]; then - TARGET_REPO='pgduckdb/pgduckdb' - else - TARGET_REPO='pgduckdb/ci-builds' - SHA_TAG="--tag ${TARGET_REPO}:${{ matrix.postgres }}-${{ github.sha }}" - fi + TARGET_REPO="${{ needs.docker_build.outputs.target_repo }}" echo "Will push merged image to '${TARGET_REPO}'." - docker buildx imagetools create ${SHA_TAG} \ - --tag ${TARGET_REPO}:${{ matrix.postgres }}-${BRANCH} \ + docker buildx imagetools create \ + --tag ${TARGET_REPO}:${{ matrix.postgres }}-${BRANCH} \ + --tag pgduckdb/ci-builds:${{ matrix.postgres }}-${{ github.sha }} \ pgduckdb/ci-builds:${{ matrix.postgres }}-amd64-${{ github.sha }} \ pgduckdb/ci-builds:${{ matrix.postgres }}-arm64-${{ github.sha }} - docker buildx imagetools inspect ${TARGET_REPO}:${{ matrix.postgres }}-${{ github.sha }} + docker buildx imagetools inspect pgduckdb/ci-builds:${{ matrix.postgres }}-${{ github.sha }}