v0.51.3 #2
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Publish Docker Image | |
| on: | |
| workflow_dispatch: | |
| release: | |
| types: [published] | |
| env: | |
| REGISTRY: ghcr.io | |
| IMAGE_NAME: ${{ github.repository }} | |
| jobs: | |
| # 1. Build each arch, push by digest, upload as artifact | |
| build: | |
| name: Build (${{ matrix.arch }}, ${{ matrix.suffix }}) | |
| runs-on: ubuntu-24.04 | |
| permissions: | |
| contents: read | |
| packages: write | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - libc: musl | |
| suffix: alpine | |
| arch: amd64 | |
| platform: linux/amd64 | |
| - libc: musl | |
| suffix: alpine | |
| arch: arm64 | |
| platform: linux/arm64 | |
| - libc: gnu | |
| suffix: trixie | |
| arch: amd64 | |
| platform: linux/amd64 | |
| - libc: gnu | |
| suffix: trixie | |
| arch: arm64 | |
| platform: linux/arm64 | |
| outputs: | |
| # Each matrix leg writes its digest; the merge job reads them by index | |
| digest-musl-amd64: ${{ steps.build.outputs.digest && matrix.libc == 'musl' && matrix.arch == 'amd64' && steps.build.outputs.digest || '' }} | |
| digest-musl-arm64: ${{ steps.build.outputs.digest && matrix.libc == 'musl' && matrix.arch == 'arm64' && steps.build.outputs.digest || '' }} | |
| digest-gnu-amd64: ${{ steps.build.outputs.digest && matrix.libc == 'gnu' && matrix.arch == 'amd64' && steps.build.outputs.digest || '' }} | |
| digest-gnu-arm64: ${{ steps.build.outputs.digest && matrix.libc == 'gnu' && matrix.arch == 'arm64' && steps.build.outputs.digest || '' }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Log in to GHCR | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Build and push by digest | |
| id: build | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| push: true | |
| platforms: ${{ matrix.platform }} | |
| build-args: LIBC=${{ matrix.libc }} | |
| # Push to a digest-only ref (no tag) so the merge job can assemble | |
| # the final multi-arch manifest cleanly | |
| outputs: type=image,name=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }},push-by-digest=true,name-canonical=true,push=true | |
| cache-from: type=gha,scope=${{ matrix.suffix }}-${{ matrix.arch }} | |
| cache-to: type=gha,mode=max,scope=${{ matrix.suffix }}-${{ matrix.arch }} | |
| - name: Export digest | |
| run: | | |
| mkdir -p /tmp/digests | |
| digest="${{ steps.build.outputs.digest }}" | |
| touch "/tmp/digests/${digest#sha256:}" | |
| - name: Upload digest artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: digest-${{ matrix.suffix }}-${{ matrix.arch }} | |
| path: /tmp/digests/* | |
| if-no-files-found: error | |
| retention-days: 1 | |
| # 2. merge arch digests into a single multi-arch manifest per variant | |
| merge: | |
| name: Merge (${{ matrix.suffix }}) | |
| runs-on: ubuntu-24.04 | |
| needs: build | |
| permissions: | |
| contents: read | |
| packages: write | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - libc: musl | |
| suffix: alpine | |
| - libc: gnu | |
| suffix: trixie | |
| steps: | |
| - name: Download digests | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: /tmp/digests | |
| pattern: digest-${{ matrix.suffix }}-* | |
| merge-multiple: true | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Log in to GHCR | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Extract metadata | |
| id: meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
| flavor: | | |
| suffix=-${{ matrix.suffix }},onlatest=true | |
| tags: | | |
| type=semver,pattern={{version}} | |
| type=semver,pattern={{major}}.{{minor}} | |
| type=raw,value=latest | |
| - name: Create and push multi-arch manifest | |
| working-directory: /tmp/digests | |
| run: | | |
| docker buildx imagetools create \ | |
| $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \ | |
| $(printf '${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@sha256:%s ' *) |