From 80a59094f95a34130386be0d00f1fe4ac63824eb Mon Sep 17 00:00:00 2001 From: sjdonado Date: Sun, 2 Nov 2025 10:29:55 +0100 Subject: [PATCH] refactor: publish workflow replace manifest with multi-platform build in one step --- .github/workflows/publish.yml | 51 +++++++---------------------------- 1 file changed, 9 insertions(+), 42 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index f43023c..8220828 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -8,12 +8,9 @@ on: types: [published] jobs: - build-platforms: - name: Build Platforms + build-and-push: + name: Build and Push Multi-Platform runs-on: ubuntu-latest - strategy: - matrix: - platform: [linux/amd64, linux/arm64] permissions: contents: read packages: write @@ -22,8 +19,11 @@ jobs: - name: Checkout uses: actions/checkout@v4 + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 + uses: docker/setup-buildx-action@v3 - name: Login to Docker Hub uses: docker/login-action@v3 @@ -40,45 +40,12 @@ jobs: echo "version=latest" >> $GITHUB_OUTPUT fi - - name: Build and push platform image + - name: Build and push multi-platform image uses: docker/build-push-action@v5 - env: - CRYSTAL_WORKERS: ${{ matrix.platform == 'linux/amd64' && 4 || 2 }} with: context: . - platforms: ${{ matrix.platform }} + platforms: linux/amd64,linux/arm64 push: true - tags: | - sjdonado/bit:${{ steps.version.outputs.version }}-${{ matrix.platform == 'linux/amd64' && 'amd64' || 'arm64' }} - build-args: | - TARGETARCH=${{ matrix.platform == 'linux/amd64' && 'amd64' || 'arm64' }} + tags: sjdonado/bit:${{ steps.version.outputs.version }} cache-from: type=gha cache-to: type=gha,mode=max - - create-manifest: - name: Create Manifest - runs-on: ubuntu-latest - needs: build-platforms - permissions: - packages: write - steps: - - name: Login to Docker Hub - uses: docker/login-action@v3 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - - name: Determine version - id: version - run: | - if [ "${{ github.event_name }}" = "release" ]; then - echo "version=${{ github.event.release.tag_name }}" >> $GITHUB_OUTPUT - else - echo "version=latest" >> $GITHUB_OUTPUT - fi - - - name: Create manifest - run: | - docker buildx imagetools create \ - -t sjdonado/bit:${{ steps.version.outputs.version }} \ - sjdonado/bit:${{ steps.version.outputs.version }}-{amd64,arm64}