diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4b9a17a..50193fb 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -52,12 +52,6 @@ jobs: run: | mv "${{ steps.meta.outputs.bake-file }}" "/tmp/bake-meta.json" - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - name: Upload meta bake definition uses: actions/upload-artifact@v4 with: @@ -114,11 +108,13 @@ jobs: - name: Build id: bake uses: docker/bake-action@v4 + env: + PLATFORM: ${{ env.ARCH }} with: files: | ./docker-bake.hcl /tmp/bake-meta.json - targets: ${{ env.PLATFORM_PAIR }} + targets: image set: | *.tags= *.platform=${{ matrix.platform }} @@ -126,18 +122,10 @@ jobs: *.cache-to=type=gha,scope=build-${{ env.PLATFORM_PAIR }} *.output=type=image,"name=${{ env.DOCKERHUB_SLUG }},${{ env.GHCR_SLUG }}",push-by-digest=true,name-canonical=true,push=true - - name: Export digest (amd64) - if: matrix.platform == 'linux/amd64' + - name: Export digest run: | mkdir -p /tmp/digests - digest="${{ fromJSON(steps.bake.outputs.metadata).image-amd64['containerimage.digest'] }}" - touch "/tmp/digests/${digest#sha256:}" - - - name: Export digest (arm64) - if: matrix.platform == 'linux/arm64' - run: | - mkdir -p /tmp/digests - digest="${{ fromJSON(steps.bake.outputs.metadata).image-arm64['containerimage.digest'] }}" + digest="${{ fromJSON(steps.bake.outputs.metadata).image['containerimage.digest'] }}" touch "/tmp/digests/${digest#sha256:}" - name: Upload digest diff --git a/docker-bake.hcl b/docker-bake.hcl index d9c1b90..e1db758 100644 --- a/docker-bake.hcl +++ b/docker-bake.hcl @@ -2,24 +2,32 @@ variable "DEFAULT_TAG" { default = "baidunetdisk-docker:latest" } -group "linux-amd64" { - targets = ["image-amd64"] -} -group "linux-arm64" { - targets = ["image-arm64"] +variable "ARCH" { + default = "arm64" } target "docker-metadata-action" { tags = ["${DEFAULT_TAG}"] } +// Default target if none specified +group "default" { + targets = ["image-local"] +} -target "image-amd64" { - platforms = ["linux/amd64"] +target "image" { inherits = ["docker-metadata-action"] - dockerfile = "Dockerfile" + dockerfile = format("Dockerfile%s", equal("arm64", ARCH) ? "" : ".${ARCH}") } -target "image-arm64" { - platforms = ["linux/arm64"] - inherits = ["docker-metadata-action"] - dockerfile = "Dockerfile.arm64" + +target "image-local" { + inherits = ["image"] + output = ["type=docker"] } + +target "image-all" { + inherits = ["image"] + platforms = [ + "linux/amd64", + "linux/arm64", + ] +} \ No newline at end of file