Docker • Build Toolchain Container #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
| # SPDX-FileCopyrightText: 2025 ETH Zurich and University of Bologna | |
| # | |
| # SPDX-License-Identifier: Apache-2.0 | |
| --- | |
| name: Docker • Build Toolchain Container | |
| "on": | |
| workflow_dispatch: | |
| jobs: | |
| prepare: | |
| name: Fetch branch name or tag | |
| runs-on: ubuntu-latest | |
| outputs: | |
| docker_tag: ${{ steps.generate_tag.outputs.docker_tag }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up environment variables | |
| run: | | |
| echo "BRANCH_NAME=${GITHUB_REF##*/}" >> $GITHUB_ENV | |
| echo "TAG_NAME=${GITHUB_REF##*/}" >> $GITHUB_ENV | |
| echo "IS_TAG=${GITHUB_REF_TYPE}" >> $GITHUB_ENV | |
| - name: Set Docker tag | |
| id: generate_tag | |
| run: | | |
| if [[ "${{ env.IS_TAG }}" == "tag" ]]; then | |
| echo "docker_tag=${{ env.TAG_NAME }}" >> $GITHUB_OUTPUT | |
| else | |
| echo "docker_tag=${{ env.BRANCH_NAME }}" >> $GITHUB_OUTPUT | |
| fi | |
| build-toolchain: | |
| name: Build Deeploy Toolchain Image | |
| needs: [prepare] | |
| runs-on: ${{ matrix.runner }} | |
| outputs: | |
| digest-amd64: ${{ steps.digest.outputs.digest-amd64 }} | |
| digest-arm64: ${{ steps.digest.outputs.digest-arm64 }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| platform: [amd64, arm64] | |
| include: | |
| - platform: amd64 | |
| runner: ubuntu-latest | |
| - platform: arm64 | |
| runner: ubuntu-22.04-arm | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Free up disk space | |
| uses: jlumbroso/free-disk-space@v1.3.1 | |
| with: | |
| android: true | |
| dotnet: true | |
| haskell: true | |
| large-packages: true | |
| - uses: docker/setup-buildx-action@v3 | |
| - name: GHCR Log-in | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Build Cache for Docker | |
| id: cache | |
| uses: actions/cache@v4 | |
| with: | |
| path: var-ccache | |
| key: ${{ runner.os }}-${{ matrix.platform }}-build-cache-toolchain | |
| - name: Inject build-cache | |
| uses: reproducible-containers/buildkit-cache-dance@v3.1.0 | |
| with: | |
| cache-map: | | |
| { | |
| "var-ccache": "/ccache" | |
| } | |
| skip-extraction: ${{ steps.cache.outputs.cache-hit }} | |
| - name: Lower Case Repository Name | |
| run: | | |
| echo "OWNER_LC=${OWNER,,}" >>${GITHUB_ENV} | |
| env: | |
| OWNER: "${{ github.repository_owner }}" | |
| - name: Build and push toolchain image | |
| id: build | |
| uses: docker/build-push-action@v6 | |
| with: | |
| platforms: linux/${{ matrix.platform }} | |
| context: . | |
| file: Container/Dockerfile.toolchain | |
| push: true | |
| outputs: type=image,name=ghcr.io/${{ env.OWNER_LC }}/deeploy-toolchain,annotation-index=true,name-canonical=true,push=true | |
| - name: Extract image digest | |
| id: digest | |
| run: echo "digest-${{ matrix.platform }}=${{ steps.build.outputs.digest }}" >> $GITHUB_OUTPUT | |
| merge-toolchain-images: | |
| name: Merge Deeploy Toolchain Images | |
| runs-on: ubuntu-latest | |
| needs: [prepare, build-toolchain] | |
| steps: | |
| - name: GHCR Log-in | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Lower Case Repository Name | |
| run: | | |
| echo "OWNER_LC=${OWNER,,}" >>${GITHUB_ENV} | |
| env: | |
| OWNER: "${{ github.repository_owner }}" | |
| - name: Merge Toolchain Images | |
| uses: Noelware/docker-manifest-action@v1 | |
| with: | |
| inputs: | | |
| ghcr.io/${{ env.OWNER_LC }}/deeploy-toolchain@${{ needs.build-toolchain.outputs.digest-amd64 }}, | |
| ghcr.io/${{ env.OWNER_LC }}/deeploy-toolchain@${{ needs.build-toolchain.outputs.digest-arm64 }} | |
| tags: | | |
| ghcr.io/${{ env.OWNER_LC }}/deeploy-toolchain:latest, | |
| ghcr.io/${{ env.OWNER_LC }}/deeploy-toolchain:${{ needs.prepare.outputs.docker_tag }} | |
| push: true |