# This file is generated. Please edit publish-images.yml.erb instead!


name: Weekly publish docker images to GHCR
on:
  workflow_dispatch:
  schedule:
    - cron: "0 3 * * 3" # At 03:00 on Wednesday # https://crontab.guru/#0_3_*_*_3


concurrency:
  group: "${{github.workflow}}-${{github.ref}}"
  cancel-in-progress: true

jobs:

  aarch64-linux-musl:
    name: "build aarch64-linux-musl ${{ matrix.os }}"
    needs: common-7f790bc
    strategy:
      fail-fast: false
      matrix:
        os:
          - ubuntu-latest
          - ubuntu-24.04-arm
    runs-on: ${{ matrix.os }}
    steps:
      - uses: actions/checkout@v4

      - uses: ruby/setup-ruby@v1
        with:
          ruby-version: "3.4"
          bundler-cache: true

      - name: Fetch docker buildx layer cache
        uses: actions/cache@v4
        with:
          path: tmp/build-cache-${{ runner.arch }}
          key: ${{ runner.os }}-on-${{ runner.arch }}-aarch64-linux-musl-${{ github.sha }}
          restore-keys: |
            ${{ runner.os }}-on-${{ runner.arch }}-aarch64-linux-musl
            ${{ runner.os }}-on-${{ runner.arch }}-common-7f790bc
          enableCrossOsArchive: true
      - name: Build the image layers aarch64-linux-musl on ${{ runner.arch }}
        env:
          RCD_TASK_DEPENDENCIES: "false"
        run: |
          # Change docker to a cache-able driver
          docker buildx create --driver docker-container --use
          bundle exec rake build:common-723ac6e RCD_DOCKER_BUILD="docker buildx build --cache-from=type=local,compression=zstd,src=tmp/build-cache-${{ runner.arch }} --cache-to=type=local,compression=zstd,dest=tmp/build-cache-new"
      - name: Update and prune docker buildx layer cache
        run: |
          rm -rf tmp/build-cache-${{ runner.arch }}
          mv tmp/build-cache-new tmp/build-cache-${{ runner.arch }}

  common-7f790bc:
    name: "build common-7f790bc ${{ matrix.os }}"
    needs: common-8c26987
    strategy:
      fail-fast: false
      matrix:
        os:
          - ubuntu-latest
          - ubuntu-24.04-arm
    runs-on: ${{ matrix.os }}
    steps:
      - uses: actions/checkout@v4

      - uses: ruby/setup-ruby@v1
        with:
          ruby-version: "3.4"
          bundler-cache: true

      - name: Fetch docker buildx layer cache
        uses: actions/cache@v4
        with:
          path: tmp/build-cache-${{ runner.arch }}
          key: ${{ runner.os }}-on-${{ runner.arch }}-common-7f790bc-${{ github.sha }}
          restore-keys: |
            ${{ runner.os }}-on-${{ runner.arch }}-common-7f790bc
            ${{ runner.os }}-on-${{ runner.arch }}-common-8c26987
          enableCrossOsArchive: true
      - name: Build the image layers common-7f790bc on ${{ runner.arch }}
        env:
          RCD_TASK_DEPENDENCIES: "false"
        run: |
          # Change docker to a cache-able driver
          docker buildx create --driver docker-container --use
          bundle exec rake build:common-7f790bc RCD_DOCKER_BUILD="docker buildx build --cache-from=type=local,compression=zstd,src=tmp/build-cache-${{ runner.arch }} --cache-to=type=local,compression=zstd,dest=tmp/build-cache-new"
      - name: Update and prune docker buildx layer cache
        run: |
          rm -rf tmp/build-cache-${{ runner.arch }}
          mv tmp/build-cache-new tmp/build-cache-${{ runner.arch }}

  arm-linux-musl:
    name: "build arm-linux-musl ${{ matrix.os }}"
    needs: common-7f790bc
    strategy:
      fail-fast: false
      matrix:
        os:
          - ubuntu-latest
          - ubuntu-24.04-arm
    runs-on: ${{ matrix.os }}
    steps:
      - uses: actions/checkout@v4

      - uses: ruby/setup-ruby@v1
        with:
          ruby-version: "3.4"
          bundler-cache: true

      - name: Fetch docker buildx layer cache
        uses: actions/cache@v4
        with:
          path: tmp/build-cache-${{ runner.arch }}
          key: ${{ runner.os }}-on-${{ runner.arch }}-arm-linux-musl-${{ github.sha }}
          restore-keys: |
            ${{ runner.os }}-on-${{ runner.arch }}-arm-linux-musl
            ${{ runner.os }}-on-${{ runner.arch }}-common-7f790bc
          enableCrossOsArchive: true
      - name: Build the image layers arm-linux-musl on ${{ runner.arch }}
        env:
          RCD_TASK_DEPENDENCIES: "false"
        run: |
          # Change docker to a cache-able driver
          docker buildx create --driver docker-container --use
          bundle exec rake build:common-fbc527a RCD_DOCKER_BUILD="docker buildx build --cache-from=type=local,compression=zstd,src=tmp/build-cache-${{ runner.arch }} --cache-to=type=local,compression=zstd,dest=tmp/build-cache-new"
      - name: Update and prune docker buildx layer cache
        run: |
          rm -rf tmp/build-cache-${{ runner.arch }}
          mv tmp/build-cache-new tmp/build-cache-${{ runner.arch }}

  x86-linux-musl:
    name: "build x86-linux-musl ${{ matrix.os }}"
    needs: common-7f790bc
    strategy:
      fail-fast: false
      matrix:
        os:
          - ubuntu-latest
          - ubuntu-24.04-arm
    runs-on: ${{ matrix.os }}
    steps:
      - uses: actions/checkout@v4

      - uses: ruby/setup-ruby@v1
        with:
          ruby-version: "3.4"
          bundler-cache: true

      - name: Fetch docker buildx layer cache
        uses: actions/cache@v4
        with:
          path: tmp/build-cache-${{ runner.arch }}
          key: ${{ runner.os }}-on-${{ runner.arch }}-x86-linux-musl-${{ github.sha }}
          restore-keys: |
            ${{ runner.os }}-on-${{ runner.arch }}-x86-linux-musl
            ${{ runner.os }}-on-${{ runner.arch }}-common-7f790bc
          enableCrossOsArchive: true
      - name: Build the image layers x86-linux-musl on ${{ runner.arch }}
        env:
          RCD_TASK_DEPENDENCIES: "false"
        run: |
          # Change docker to a cache-able driver
          docker buildx create --driver docker-container --use
          bundle exec rake build:common-63da253 RCD_DOCKER_BUILD="docker buildx build --cache-from=type=local,compression=zstd,src=tmp/build-cache-${{ runner.arch }} --cache-to=type=local,compression=zstd,dest=tmp/build-cache-new"
      - name: Update and prune docker buildx layer cache
        run: |
          rm -rf tmp/build-cache-${{ runner.arch }}
          mv tmp/build-cache-new tmp/build-cache-${{ runner.arch }}

  x86_64-linux-musl:
    name: "build x86_64-linux-musl ${{ matrix.os }}"
    needs: common-7f790bc
    strategy:
      fail-fast: false
      matrix:
        os:
          - ubuntu-latest
          - ubuntu-24.04-arm
    runs-on: ${{ matrix.os }}
    steps:
      - uses: actions/checkout@v4

      - uses: ruby/setup-ruby@v1
        with:
          ruby-version: "3.4"
          bundler-cache: true

      - name: Fetch docker buildx layer cache
        uses: actions/cache@v4
        with:
          path: tmp/build-cache-${{ runner.arch }}
          key: ${{ runner.os }}-on-${{ runner.arch }}-x86_64-linux-musl-${{ github.sha }}
          restore-keys: |
            ${{ runner.os }}-on-${{ runner.arch }}-x86_64-linux-musl
            ${{ runner.os }}-on-${{ runner.arch }}-common-7f790bc
          enableCrossOsArchive: true
      - name: Build the image layers x86_64-linux-musl on ${{ runner.arch }}
        env:
          RCD_TASK_DEPENDENCIES: "false"
        run: |
          # Change docker to a cache-able driver
          docker buildx create --driver docker-container --use
          bundle exec rake build:common-dc7239b RCD_DOCKER_BUILD="docker buildx build --cache-from=type=local,compression=zstd,src=tmp/build-cache-${{ runner.arch }} --cache-to=type=local,compression=zstd,dest=tmp/build-cache-new"
      - name: Update and prune docker buildx layer cache
        run: |
          rm -rf tmp/build-cache-${{ runner.arch }}
          mv tmp/build-cache-new tmp/build-cache-${{ runner.arch }}

  arm64-darwin:
    name: "build arm64-darwin ${{ matrix.os }}"
    needs: common-d1f4370
    strategy:
      fail-fast: false
      matrix:
        os:
          - ubuntu-latest
          - ubuntu-24.04-arm
    runs-on: ${{ matrix.os }}
    steps:
      - uses: actions/checkout@v4

      - uses: ruby/setup-ruby@v1
        with:
          ruby-version: "3.4"
          bundler-cache: true

      - name: Fetch docker buildx layer cache
        uses: actions/cache@v4
        with:
          path: tmp/build-cache-${{ runner.arch }}
          key: ${{ runner.os }}-on-${{ runner.arch }}-arm64-darwin-${{ github.sha }}
          restore-keys: |
            ${{ runner.os }}-on-${{ runner.arch }}-arm64-darwin
            ${{ runner.os }}-on-${{ runner.arch }}-common-d1f4370
          enableCrossOsArchive: true
      - name: Build the image layers arm64-darwin on ${{ runner.arch }}
        env:
          RCD_TASK_DEPENDENCIES: "false"
        run: |
          # Change docker to a cache-able driver
          docker buildx create --driver docker-container --use
          bundle exec rake build:common-2829589 RCD_DOCKER_BUILD="docker buildx build --cache-from=type=local,compression=zstd,src=tmp/build-cache-${{ runner.arch }} --cache-to=type=local,compression=zstd,dest=tmp/build-cache-new"
      - name: Update and prune docker buildx layer cache
        run: |
          rm -rf tmp/build-cache-${{ runner.arch }}
          mv tmp/build-cache-new tmp/build-cache-${{ runner.arch }}

  common-d1f4370:
    name: "build common-d1f4370 ${{ matrix.os }}"
    needs: common-8c26987
    strategy:
      fail-fast: false
      matrix:
        os:
          - ubuntu-latest
          - ubuntu-24.04-arm
    runs-on: ${{ matrix.os }}
    steps:
      - uses: actions/checkout@v4

      - uses: ruby/setup-ruby@v1
        with:
          ruby-version: "3.4"
          bundler-cache: true

      - name: Fetch docker buildx layer cache
        uses: actions/cache@v4
        with:
          path: tmp/build-cache-${{ runner.arch }}
          key: ${{ runner.os }}-on-${{ runner.arch }}-common-d1f4370-${{ github.sha }}
          restore-keys: |
            ${{ runner.os }}-on-${{ runner.arch }}-common-d1f4370
            ${{ runner.os }}-on-${{ runner.arch }}-common-8c26987
          enableCrossOsArchive: true
      - name: Build the image layers common-d1f4370 on ${{ runner.arch }}
        env:
          RCD_TASK_DEPENDENCIES: "false"
        run: |
          # Change docker to a cache-able driver
          docker buildx create --driver docker-container --use
          bundle exec rake build:common-d1f4370 RCD_DOCKER_BUILD="docker buildx build --cache-from=type=local,compression=zstd,src=tmp/build-cache-${{ runner.arch }} --cache-to=type=local,compression=zstd,dest=tmp/build-cache-new"
      - name: Update and prune docker buildx layer cache
        run: |
          rm -rf tmp/build-cache-${{ runner.arch }}
          mv tmp/build-cache-new tmp/build-cache-${{ runner.arch }}

  x86_64-darwin:
    name: "build x86_64-darwin ${{ matrix.os }}"
    needs: common-d1f4370
    strategy:
      fail-fast: false
      matrix:
        os:
          - ubuntu-latest
          - ubuntu-24.04-arm
    runs-on: ${{ matrix.os }}
    steps:
      - uses: actions/checkout@v4

      - uses: ruby/setup-ruby@v1
        with:
          ruby-version: "3.4"
          bundler-cache: true

      - name: Fetch docker buildx layer cache
        uses: actions/cache@v4
        with:
          path: tmp/build-cache-${{ runner.arch }}
          key: ${{ runner.os }}-on-${{ runner.arch }}-x86_64-darwin-${{ github.sha }}
          restore-keys: |
            ${{ runner.os }}-on-${{ runner.arch }}-x86_64-darwin
            ${{ runner.os }}-on-${{ runner.arch }}-common-d1f4370
          enableCrossOsArchive: true
      - name: Build the image layers x86_64-darwin on ${{ runner.arch }}
        env:
          RCD_TASK_DEPENDENCIES: "false"
        run: |
          # Change docker to a cache-able driver
          docker buildx create --driver docker-container --use
          bundle exec rake build:common-bc54075 RCD_DOCKER_BUILD="docker buildx build --cache-from=type=local,compression=zstd,src=tmp/build-cache-${{ runner.arch }} --cache-to=type=local,compression=zstd,dest=tmp/build-cache-new"
      - name: Update and prune docker buildx layer cache
        run: |
          rm -rf tmp/build-cache-${{ runner.arch }}
          mv tmp/build-cache-new tmp/build-cache-${{ runner.arch }}

  aarch64-linux-gnu:
    name: "build aarch64-linux-gnu ${{ matrix.os }}"
    needs: common-8c26987
    strategy:
      fail-fast: false
      matrix:
        os:
          - ubuntu-latest
          - ubuntu-24.04-arm
    runs-on: ${{ matrix.os }}
    steps:
      - uses: actions/checkout@v4

      - uses: ruby/setup-ruby@v1
        with:
          ruby-version: "3.4"
          bundler-cache: true

      - name: Fetch docker buildx layer cache
        uses: actions/cache@v4
        with:
          path: tmp/build-cache-${{ runner.arch }}
          key: ${{ runner.os }}-on-${{ runner.arch }}-aarch64-linux-gnu-${{ github.sha }}
          restore-keys: |
            ${{ runner.os }}-on-${{ runner.arch }}-aarch64-linux-gnu
            ${{ runner.os }}-on-${{ runner.arch }}-common-8c26987
          enableCrossOsArchive: true
      - name: Build the image layers aarch64-linux-gnu on ${{ runner.arch }}
        env:
          RCD_TASK_DEPENDENCIES: "false"
        run: |
          # Change docker to a cache-able driver
          docker buildx create --driver docker-container --use
          bundle exec rake build:common-b45d14a RCD_DOCKER_BUILD="docker buildx build --cache-from=type=local,compression=zstd,src=tmp/build-cache-${{ runner.arch }} --cache-to=type=local,compression=zstd,dest=tmp/build-cache-new"
      - name: Update and prune docker buildx layer cache
        run: |
          rm -rf tmp/build-cache-${{ runner.arch }}
          mv tmp/build-cache-new tmp/build-cache-${{ runner.arch }}

  common-8c26987:
    name: "build common-8c26987 ${{ matrix.os }}"
    needs: common-8a6d861
    strategy:
      fail-fast: false
      matrix:
        os:
          - ubuntu-latest
          - ubuntu-24.04-arm
    runs-on: ${{ matrix.os }}
    steps:
      - uses: actions/checkout@v4

      - uses: ruby/setup-ruby@v1
        with:
          ruby-version: "3.4"
          bundler-cache: true

      - name: Fetch docker buildx layer cache
        uses: actions/cache@v4
        with:
          path: tmp/build-cache-${{ runner.arch }}
          key: ${{ runner.os }}-on-${{ runner.arch }}-common-8c26987-${{ github.sha }}
          restore-keys: |
            ${{ runner.os }}-on-${{ runner.arch }}-common-8c26987
            ${{ runner.os }}-on-${{ runner.arch }}-common-8a6d861
          enableCrossOsArchive: true
      - name: Build the image layers common-8c26987 on ${{ runner.arch }}
        env:
          RCD_TASK_DEPENDENCIES: "false"
        run: |
          # Change docker to a cache-able driver
          docker buildx create --driver docker-container --use
          bundle exec rake build:common-8c26987 RCD_DOCKER_BUILD="docker buildx build --cache-from=type=local,compression=zstd,src=tmp/build-cache-${{ runner.arch }} --cache-to=type=local,compression=zstd,dest=tmp/build-cache-new"
      - name: Update and prune docker buildx layer cache
        run: |
          rm -rf tmp/build-cache-${{ runner.arch }}
          mv tmp/build-cache-new tmp/build-cache-${{ runner.arch }}

  aarch64-mingw-ucrt:
    name: "build aarch64-mingw-ucrt ${{ matrix.os }}"
    needs: common-8c26987
    strategy:
      fail-fast: false
      matrix:
        os:
          - ubuntu-latest
          - ubuntu-24.04-arm
    runs-on: ${{ matrix.os }}
    steps:
      - uses: actions/checkout@v4

      - uses: ruby/setup-ruby@v1
        with:
          ruby-version: "3.4"
          bundler-cache: true

      - name: Fetch docker buildx layer cache
        uses: actions/cache@v4
        with:
          path: tmp/build-cache-${{ runner.arch }}
          key: ${{ runner.os }}-on-${{ runner.arch }}-aarch64-mingw-ucrt-${{ github.sha }}
          restore-keys: |
            ${{ runner.os }}-on-${{ runner.arch }}-aarch64-mingw-ucrt
            ${{ runner.os }}-on-${{ runner.arch }}-common-8c26987
          enableCrossOsArchive: true
      - name: Build the image layers aarch64-mingw-ucrt on ${{ runner.arch }}
        env:
          RCD_TASK_DEPENDENCIES: "false"
        run: |
          # Change docker to a cache-able driver
          docker buildx create --driver docker-container --use
          bundle exec rake build:common-2378386 RCD_DOCKER_BUILD="docker buildx build --cache-from=type=local,compression=zstd,src=tmp/build-cache-${{ runner.arch }} --cache-to=type=local,compression=zstd,dest=tmp/build-cache-new"
      - name: Update and prune docker buildx layer cache
        run: |
          rm -rf tmp/build-cache-${{ runner.arch }}
          mv tmp/build-cache-new tmp/build-cache-${{ runner.arch }}

  arm-linux-gnu:
    name: "build arm-linux-gnu ${{ matrix.os }}"
    needs: common-8c26987
    strategy:
      fail-fast: false
      matrix:
        os:
          - ubuntu-latest
          - ubuntu-24.04-arm
    runs-on: ${{ matrix.os }}
    steps:
      - uses: actions/checkout@v4

      - uses: ruby/setup-ruby@v1
        with:
          ruby-version: "3.4"
          bundler-cache: true

      - name: Fetch docker buildx layer cache
        uses: actions/cache@v4
        with:
          path: tmp/build-cache-${{ runner.arch }}
          key: ${{ runner.os }}-on-${{ runner.arch }}-arm-linux-gnu-${{ github.sha }}
          restore-keys: |
            ${{ runner.os }}-on-${{ runner.arch }}-arm-linux-gnu
            ${{ runner.os }}-on-${{ runner.arch }}-common-8c26987
          enableCrossOsArchive: true
      - name: Build the image layers arm-linux-gnu on ${{ runner.arch }}
        env:
          RCD_TASK_DEPENDENCIES: "false"
        run: |
          # Change docker to a cache-able driver
          docker buildx create --driver docker-container --use
          bundle exec rake build:common-8fd4771 RCD_DOCKER_BUILD="docker buildx build --cache-from=type=local,compression=zstd,src=tmp/build-cache-${{ runner.arch }} --cache-to=type=local,compression=zstd,dest=tmp/build-cache-new"
      - name: Update and prune docker buildx layer cache
        run: |
          rm -rf tmp/build-cache-${{ runner.arch }}
          mv tmp/build-cache-new tmp/build-cache-${{ runner.arch }}

  x64-mingw-ucrt:
    name: "build x64-mingw-ucrt ${{ matrix.os }}"
    needs: common-8c26987
    strategy:
      fail-fast: false
      matrix:
        os:
          - ubuntu-latest
          - ubuntu-24.04-arm
    runs-on: ${{ matrix.os }}
    steps:
      - uses: actions/checkout@v4

      - uses: ruby/setup-ruby@v1
        with:
          ruby-version: "3.4"
          bundler-cache: true

      - name: Fetch docker buildx layer cache
        uses: actions/cache@v4
        with:
          path: tmp/build-cache-${{ runner.arch }}
          key: ${{ runner.os }}-on-${{ runner.arch }}-x64-mingw-ucrt-${{ github.sha }}
          restore-keys: |
            ${{ runner.os }}-on-${{ runner.arch }}-x64-mingw-ucrt
            ${{ runner.os }}-on-${{ runner.arch }}-common-8c26987
          enableCrossOsArchive: true
      - name: Build the image layers x64-mingw-ucrt on ${{ runner.arch }}
        env:
          RCD_TASK_DEPENDENCIES: "false"
        run: |
          # Change docker to a cache-able driver
          docker buildx create --driver docker-container --use
          bundle exec rake build:common-fad6604 RCD_DOCKER_BUILD="docker buildx build --cache-from=type=local,compression=zstd,src=tmp/build-cache-${{ runner.arch }} --cache-to=type=local,compression=zstd,dest=tmp/build-cache-new"
      - name: Update and prune docker buildx layer cache
        run: |
          rm -rf tmp/build-cache-${{ runner.arch }}
          mv tmp/build-cache-new tmp/build-cache-${{ runner.arch }}

  x64-mingw32:
    name: "build x64-mingw32 ${{ matrix.os }}"
    needs: common-8c26987
    strategy:
      fail-fast: false
      matrix:
        os:
          - ubuntu-latest
          - ubuntu-24.04-arm
    runs-on: ${{ matrix.os }}
    steps:
      - uses: actions/checkout@v4

      - uses: ruby/setup-ruby@v1
        with:
          ruby-version: "3.4"
          bundler-cache: true

      - name: Fetch docker buildx layer cache
        uses: actions/cache@v4
        with:
          path: tmp/build-cache-${{ runner.arch }}
          key: ${{ runner.os }}-on-${{ runner.arch }}-x64-mingw32-${{ github.sha }}
          restore-keys: |
            ${{ runner.os }}-on-${{ runner.arch }}-x64-mingw32
            ${{ runner.os }}-on-${{ runner.arch }}-common-8c26987
          enableCrossOsArchive: true
      - name: Build the image layers x64-mingw32 on ${{ runner.arch }}
        env:
          RCD_TASK_DEPENDENCIES: "false"
        run: |
          # Change docker to a cache-able driver
          docker buildx create --driver docker-container --use
          bundle exec rake build:common-c435c44 RCD_DOCKER_BUILD="docker buildx build --cache-from=type=local,compression=zstd,src=tmp/build-cache-${{ runner.arch }} --cache-to=type=local,compression=zstd,dest=tmp/build-cache-new"
      - name: Update and prune docker buildx layer cache
        run: |
          rm -rf tmp/build-cache-${{ runner.arch }}
          mv tmp/build-cache-new tmp/build-cache-${{ runner.arch }}

  x86-linux-gnu:
    name: "build x86-linux-gnu ${{ matrix.os }}"
    needs: common-8c26987
    strategy:
      fail-fast: false
      matrix:
        os:
          - ubuntu-latest
          - ubuntu-24.04-arm
    runs-on: ${{ matrix.os }}
    steps:
      - uses: actions/checkout@v4

      - uses: ruby/setup-ruby@v1
        with:
          ruby-version: "3.4"
          bundler-cache: true

      - name: Fetch docker buildx layer cache
        uses: actions/cache@v4
        with:
          path: tmp/build-cache-${{ runner.arch }}
          key: ${{ runner.os }}-on-${{ runner.arch }}-x86-linux-gnu-${{ github.sha }}
          restore-keys: |
            ${{ runner.os }}-on-${{ runner.arch }}-x86-linux-gnu
            ${{ runner.os }}-on-${{ runner.arch }}-common-8c26987
          enableCrossOsArchive: true
      - name: Build the image layers x86-linux-gnu on ${{ runner.arch }}
        env:
          RCD_TASK_DEPENDENCIES: "false"
        run: |
          # Change docker to a cache-able driver
          docker buildx create --driver docker-container --use
          bundle exec rake build:common-cda3746 RCD_DOCKER_BUILD="docker buildx build --cache-from=type=local,compression=zstd,src=tmp/build-cache-${{ runner.arch }} --cache-to=type=local,compression=zstd,dest=tmp/build-cache-new"
      - name: Update and prune docker buildx layer cache
        run: |
          rm -rf tmp/build-cache-${{ runner.arch }}
          mv tmp/build-cache-new tmp/build-cache-${{ runner.arch }}

  x86-mingw32:
    name: "build x86-mingw32 ${{ matrix.os }}"
    needs: common-8c26987
    strategy:
      fail-fast: false
      matrix:
        os:
          - ubuntu-latest
          - ubuntu-24.04-arm
    runs-on: ${{ matrix.os }}
    steps:
      - uses: actions/checkout@v4

      - uses: ruby/setup-ruby@v1
        with:
          ruby-version: "3.4"
          bundler-cache: true

      - name: Fetch docker buildx layer cache
        uses: actions/cache@v4
        with:
          path: tmp/build-cache-${{ runner.arch }}
          key: ${{ runner.os }}-on-${{ runner.arch }}-x86-mingw32-${{ github.sha }}
          restore-keys: |
            ${{ runner.os }}-on-${{ runner.arch }}-x86-mingw32
            ${{ runner.os }}-on-${{ runner.arch }}-common-8c26987
          enableCrossOsArchive: true
      - name: Build the image layers x86-mingw32 on ${{ runner.arch }}
        env:
          RCD_TASK_DEPENDENCIES: "false"
        run: |
          # Change docker to a cache-able driver
          docker buildx create --driver docker-container --use
          bundle exec rake build:common-697f3ca RCD_DOCKER_BUILD="docker buildx build --cache-from=type=local,compression=zstd,src=tmp/build-cache-${{ runner.arch }} --cache-to=type=local,compression=zstd,dest=tmp/build-cache-new"
      - name: Update and prune docker buildx layer cache
        run: |
          rm -rf tmp/build-cache-${{ runner.arch }}
          mv tmp/build-cache-new tmp/build-cache-${{ runner.arch }}

  x86_64-linux-gnu:
    name: "build x86_64-linux-gnu ${{ matrix.os }}"
    needs: common-8c26987
    strategy:
      fail-fast: false
      matrix:
        os:
          - ubuntu-latest
          - ubuntu-24.04-arm
    runs-on: ${{ matrix.os }}
    steps:
      - uses: actions/checkout@v4

      - uses: ruby/setup-ruby@v1
        with:
          ruby-version: "3.4"
          bundler-cache: true

      - name: Fetch docker buildx layer cache
        uses: actions/cache@v4
        with:
          path: tmp/build-cache-${{ runner.arch }}
          key: ${{ runner.os }}-on-${{ runner.arch }}-x86_64-linux-gnu-${{ github.sha }}
          restore-keys: |
            ${{ runner.os }}-on-${{ runner.arch }}-x86_64-linux-gnu
            ${{ runner.os }}-on-${{ runner.arch }}-common-8c26987
          enableCrossOsArchive: true
      - name: Build the image layers x86_64-linux-gnu on ${{ runner.arch }}
        env:
          RCD_TASK_DEPENDENCIES: "false"
        run: |
          # Change docker to a cache-able driver
          docker buildx create --driver docker-container --use
          bundle exec rake build:common-7b065f9 RCD_DOCKER_BUILD="docker buildx build --cache-from=type=local,compression=zstd,src=tmp/build-cache-${{ runner.arch }} --cache-to=type=local,compression=zstd,dest=tmp/build-cache-new"
      - name: Update and prune docker buildx layer cache
        run: |
          rm -rf tmp/build-cache-${{ runner.arch }}
          mv tmp/build-cache-new tmp/build-cache-${{ runner.arch }}

  common-8a6d861:
    name: "build common-8a6d861 ${{ matrix.os }}"
    
    strategy:
      fail-fast: false
      matrix:
        os:
          - ubuntu-latest
          - ubuntu-24.04-arm
    runs-on: ${{ matrix.os }}
    steps:
      - uses: actions/checkout@v4

      - uses: ruby/setup-ruby@v1
        with:
          ruby-version: "3.4"
          bundler-cache: true

      - name: Fetch docker buildx layer cache
        uses: actions/cache@v4
        with:
          path: tmp/build-cache-${{ runner.arch }}
          key: ${{ runner.os }}-on-${{ runner.arch }}-common-8a6d861-${{ github.sha }}
          restore-keys: |
            ${{ runner.os }}-on-${{ runner.arch }}-common-8a6d861
            ${{ runner.os }}-on-${{ runner.arch }}-
          enableCrossOsArchive: true
      - name: Build the image layers common-8a6d861 on ${{ runner.arch }}
        env:
          RCD_TASK_DEPENDENCIES: "false"
        run: |
          # Change docker to a cache-able driver
          docker buildx create --driver docker-container --use
          bundle exec rake build:common-8a6d861 RCD_DOCKER_BUILD="docker buildx build --cache-from=type=local,compression=zstd,src=tmp/build-cache-${{ runner.arch }} --cache-to=type=local,compression=zstd,dest=tmp/build-cache-new"
      - name: Update and prune docker buildx layer cache
        run: |
          rm -rf tmp/build-cache-${{ runner.arch }}
          mv tmp/build-cache-new tmp/build-cache-${{ runner.arch }}

  jruby:
    name: "build jruby ${{ matrix.os }}"
    needs: common-8a6d861
    strategy:
      fail-fast: false
      matrix:
        os:
          - ubuntu-latest
          - ubuntu-24.04-arm
    runs-on: ${{ matrix.os }}
    steps:
      - uses: actions/checkout@v4

      - uses: ruby/setup-ruby@v1
        with:
          ruby-version: "3.4"
          bundler-cache: true

      - name: Fetch docker buildx layer cache
        uses: actions/cache@v4
        with:
          path: tmp/build-cache-${{ runner.arch }}
          key: ${{ runner.os }}-on-${{ runner.arch }}-jruby-${{ github.sha }}
          restore-keys: |
            ${{ runner.os }}-on-${{ runner.arch }}-jruby
            ${{ runner.os }}-on-${{ runner.arch }}-common-8a6d861
          enableCrossOsArchive: true
      - name: Build the image layers jruby on ${{ runner.arch }}
        env:
          RCD_TASK_DEPENDENCIES: "false"
        run: |
          # Change docker to a cache-able driver
          docker buildx create --driver docker-container --use
          bundle exec rake build:common-58bf949 RCD_DOCKER_BUILD="docker buildx build --cache-from=type=local,compression=zstd,src=tmp/build-cache-${{ runner.arch }} --cache-to=type=local,compression=zstd,dest=tmp/build-cache-new"
      - name: Update and prune docker buildx layer cache
        run: |
          rm -rf tmp/build-cache-${{ runner.arch }}
          mv tmp/build-cache-new tmp/build-cache-${{ runner.arch }}


  push:
    name: push
    needs: [aarch64-linux-gnu,aarch64-linux-musl,aarch64-mingw-ucrt,arm-linux-gnu,arm-linux-musl,arm64-darwin,x64-mingw-ucrt,x64-mingw32,x86-linux-gnu,x86-linux-musl,x86-mingw32,x86_64-darwin,x86_64-linux-gnu,x86_64-linux-musl,jruby]
    strategy:
      fail-fast: false
      matrix:
        platform:

          - aarch64-linux-gnu

          - aarch64-linux-musl

          - aarch64-mingw-ucrt

          - arm-linux-gnu

          - arm-linux-musl

          - arm64-darwin

          - x64-mingw-ucrt

          - x64-mingw32

          - x86-linux-gnu

          - x86-linux-musl

          - x86-mingw32

          - x86_64-darwin

          - x86_64-linux-gnu

          - x86_64-linux-musl

          - jruby

    runs-on: ubuntu-24.04-arm
    steps:
      - uses: actions/checkout@v4

      - name: Use X64 cache from tree pipeline of ${{ matrix.platform }}
        uses: actions/cache/restore@v4
        with:
          path: tmp/build-cache-X64
          key: ${{ runner.os }}-on-X64-${{ matrix.platform }}-${{ github.sha }}
          restore-keys: ${{ runner.os }}-on-X64-${{ matrix.platform }}
          enableCrossOsArchive: true
      - name: Use ARM64 cache from tree pipeline of ${{ matrix.platform }}
        uses: actions/cache/restore@v4
        with:
          path: tmp/build-cache-ARM64
          key: ${{ runner.os }}-on-ARM64-${{ matrix.platform }}-${{ github.sha }}
          restore-keys: ${{ runner.os }}-on-ARM64-${{ matrix.platform }}
          enableCrossOsArchive: true
          fail-on-cache-miss: true

      - uses: ruby/setup-ruby@v1
        with:
          ruby-version: "3.4"
          bundler-cache: true
      - uses: docker/login-action@v3
        with:
          registry: ghcr.io
          username: ${{github.actor}}
          password: ${{secrets.GITHUB_TOKEN}}
      - name: Use cache and push docker image
        env:
          RCD_IMAGE_VERSION: snapshot
          RCD_DOCKER_BUILD: docker buildx build --cache-from=type=local,compression=zstd,src=tmp/build-cache-X64 --cache-from=type=local,compression=zstd,src=tmp/build-cache-ARM64
          RCD_TASK_DEPENDENCIES: "false"
        run: |
          docker buildx create --driver docker-container --use
          bundle exec rake release:${{ matrix.platform }}
