ci: add arm64 docker builds (#63) #1
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 nilchaind to GHCR | |
| on: | |
| push: | |
| branches: | |
| - main | |
| workflow_dispatch: | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| permissions: | |
| contents: read | |
| packages: write # Required to push to GHCR | |
| jobs: | |
| build-and-push-arch: | |
| runs-on: ${{ matrix.runner }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - arch: amd64 | |
| platform: linux/amd64 | |
| runner: ubuntu-latest | |
| - arch: arm64 | |
| platform: linux/arm64 | |
| runner: ubuntu-24.04-arm | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Log in to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Extract metadata for version | |
| id: meta_tag | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ghcr.io/nillionnetwork/nilchaind | |
| tags: | | |
| type=ref,event=branch | |
| type=ref,event=tag | |
| type=sha,prefix= | |
| flavor: | | |
| latest=false | |
| - name: Build and push arch-specific image | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| platforms: ${{ matrix.platform }} | |
| push: true | |
| tags: ghcr.io/nillionnetwork/nilchaind:${{ github.sha }}-${{ matrix.arch }} | |
| build-args: | | |
| VERSION=${{ steps.meta_tag.outputs.version }} | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| provenance: false | |
| create-and-push-manifest: | |
| runs-on: ubuntu-latest | |
| needs: build-and-push-arch | |
| steps: | |
| - name: Log in to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Extract final tags | |
| id: meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ghcr.io/nillionnetwork/nilchaind | |
| tags: | | |
| type=ref,event=branch | |
| type=ref,event=tag | |
| flavor: | | |
| latest=false | |
| - name: Create and push multi-arch manifest | |
| run: | | |
| echo "${{ steps.meta.outputs.tags }}" > tags.txt | |
| while IFS= read -r tag; do | |
| if [ -n "$tag" ]; then | |
| echo "Creating and pushing manifest for tag: $tag" | |
| docker manifest create "$tag" \ | |
| ghcr.io/nillionnetwork/nilchaind:${{ github.sha }}-amd64 \ | |
| ghcr.io/nillionnetwork/nilchaind:${{ github.sha }}-arm64 | |
| docker manifest push "$tag" | |
| fi | |
| done < tags.txt |