Skip to content

Commit

Permalink
use buildx to merge manifests (#686)
Browse files Browse the repository at this point in the history
  • Loading branch information
d4mr authored Sep 26, 2024
1 parent cbf33f9 commit 49fb34c
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 14 deletions.
14 changes: 11 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ jobs:
include:
- platform: linux/amd64
runner: ubuntu-latest
arch: amd64
- platform: linux/arm64
runner: ubuntu-24.04-arm64
arch: arm64
steps:
- name: Checkout code
uses: actions/checkout@v3
Expand All @@ -38,7 +40,7 @@ jobs:
context: .
target: prod
push: true
tags: thirdweb/engine:nightly-${{ matrix.platform == 'linux/amd64' && 'amd64' || 'arm64' }}
tags: thirdweb/engine:nightly-${{matrix.arch }}
platforms: ${{ matrix.platform }}
cache-from: type=gha,scope=${{ matrix.platform }}
cache-to: type=gha,scope=${{ matrix.platform }},mode=max
Expand All @@ -48,6 +50,9 @@ jobs:
needs: build
runs-on: ubuntu-latest
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to DockerHub
uses: docker/login-action@v3
with:
Expand All @@ -56,7 +61,10 @@ jobs:

- name: Create and Push Multi-arch Manifest
run: |
docker manifest create ${{ env.REGISTRY_IMAGE }}:nightly \
docker buildx imagetools create -t ${{ env.REGISTRY_IMAGE }}:nightly \
${{ env.REGISTRY_IMAGE }}:nightly-amd64 \
${{ env.REGISTRY_IMAGE }}:nightly-arm64
docker manifest push ${{ env.REGISTRY_IMAGE }}:nightly
- name: Inspect image
run: |
docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:nightly
33 changes: 22 additions & 11 deletions .github/workflows/tagBasedImageBuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ jobs:
include:
- platform: linux/amd64
runner: ubuntu-latest
arch: amd64
- platform: linux/arm64
runner: ubuntu-24.04-arm64
arch: arm64
env:
LATEST_TAG: ${{ github.event.release.target_commitish == 'main' && 'thirdweb/engine:latest' || '' }}

Expand All @@ -43,8 +45,8 @@ jobs:
platforms: ${{ matrix.platform }}
push: true
tags: |
${{ env.REGISTRY_IMAGE }}:${{ github.event.release.tag_name }}-${{ matrix.platform == 'linux/amd64' && 'amd64' || 'arm64' }}
${{ env.LATEST_TAG != '' && format('thirdweb/engine:latest-{0}', matrix.platform == 'linux/amd64' && 'amd64' || 'arm64') || '' }}
${{ env.REGISTRY_IMAGE }}:${{ github.event.release.tag_name }}-${{ matrix.arch }}
${{ env.LATEST_TAG != '' && format('thirdweb/engine:latest-{0}', matrix.arch) || '' }}
cache-from: type=gha,scope=${{ matrix.platform }}
cache-to: type=gha,scope=${{ matrix.platform }},mode=max
build-args: ENGINE_VERSION=${{ github.event.release.tag_name }}
Expand All @@ -55,24 +57,33 @@ jobs:
env:
LATEST_TAG: ${{ github.event.release.target_commitish == 'main' && 'thirdweb/engine:latest' || '' }}
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Create and Push Multi-arch Manifest (release tag)
- name: Create and Push Multi-arch Manifest (release tag)
run: |
docker manifest create ${{ env.REGISTRY_IMAGE }}:${{ github.event.release.tag_name }} \
docker buildx imagetools create -t ${{ env.REGISTRY_IMAGE }}:${{ github.event.release.tag_name }} \
${{ env.REGISTRY_IMAGE }}:${{ github.event.release.tag_name }}-amd64 \
${{ env.REGISTRY_IMAGE }}:${{ github.event.release.tag_name }}-arm64
docker manifest push ${{ env.REGISTRY_IMAGE }}:${{ github.event.release.tag_name }}
- name: Inspect release image
run: |
docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ github.event.release.tag_name }}
- name: Create and Push Multi-arch Manifest (latest tag) (if applicable)
- name: Create and Push Multi-arch Manifest (latest tag) (if applicable)
if: ${{ env.LATEST_TAG != '' }}
run: |
docker buildx imagetools create -t ${{ env.REGISTRY_IMAGE }}:latest \
${{ env.REGISTRY_IMAGE }}:latest-amd64 \
${{ env.REGISTRY_IMAGE }}:latest-arm64
- name: Inspect latest image (if applicable)
if: ${{ env.LATEST_TAG != '' }}
run: |
docker manifest create ${{ env.REGISTRY_IMAGE }}:latest \
${{ env.REGISTRY_IMAGE }}:latest-arm64 \
${{ env.REGISTRY_IMAGE }}:latest-amd64
docker manifest push ${{ env.REGISTRY_IMAGE }}:latest
docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:latest

0 comments on commit 49fb34c

Please sign in to comment.