diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 885cdc6..c6703a9 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -31,7 +31,7 @@ jobs: - name: Checkout uses: actions/checkout@v4 - # We don't need QEMU since we're running on native hardware. + # Set up Docker Buildx - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 @@ -42,23 +42,15 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Generate build ID - id: prep - run: | - branch=${GITHUB_REF##*/} - sha=${GITHUB_SHA::8} - ts=$(date +%s) - echo "BUILD_ID=${branch}-${sha}-${ts}" >> $GITHUB_OUTPUT - + # Use docker/metadata-action to generate tags with an architecture suffix - name: Extract Docker metadata id: meta uses: docker/metadata-action@v5 with: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} tags: | - type=raw,value=latest - type=raw,value=${{ steps.prep.outputs.BUILD_ID }} - type=raw,value=${{ inputs.version }} + type=raw,value=latest-${{ matrix.platform == 'linux/amd64' && 'amd64' || 'arm64' }} + type=raw,value=${{ inputs.version }}-${{ matrix.platform == 'linux/amd64' && 'amd64' || 'arm64' }} - name: Build and push Docker image for ${{ matrix.platform }} uses: docker/build-push-action@v6 @@ -70,9 +62,39 @@ jobs: tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} - release: + manifest: needs: build runs-on: ubuntu-latest + permissions: + contents: read + packages: write + steps: + - name: Log into registry ${{ env.REGISTRY }} + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + # Create a multi-arch manifest for the "latest" tag + - name: Create multi-arch manifest for latest + run: | + docker manifest create ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest \ + ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest-amd64 \ + ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest-arm64 + docker manifest push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest + + # Create a multi-arch manifest for the version tag + - name: Create multi-arch manifest for version tag + run: | + docker manifest create ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ inputs.version }} \ + ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ inputs.version }}-amd64 \ + ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ inputs.version }}-arm64 + docker manifest push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ inputs.version }} + + release: + needs: manifest + runs-on: ubuntu-latest steps: - uses: actions/checkout@v4