Cache added. #7
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: Continuous Integration | |
| on: [push] | |
| env: | |
| VERSION: ${{ github.ref_name }} | |
| REGISTRY_IMAGE: ghcr.io/throttr/builder-alpine | |
| jobs: | |
| build: | |
| name: Build | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| version: [1.87.0] | |
| variant: [debug, release] | |
| platform: [linux/amd64, linux/arm64] | |
| runs-on: ${{ matrix.platform == 'linux/arm64' && 'ubuntu-22.04-arm' || 'ubuntu-latest' }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set platform name | |
| run: | | |
| PLATFORM="${{ matrix.platform }}" | |
| PLATFORM_PAIR="${PLATFORM////-}" | |
| echo "PLATFORM_PAIR=$PLATFORM_PAIR" >> $GITHUB_ENV | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v3 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Login to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ secrets.GHCR_USERNAME }} | |
| password: ${{ secrets.GHCR_PAT }} | |
| - name: Build and push image | |
| id: build | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| platforms: ${{ matrix.platform }} | |
| tags: ${{ env.REGISTRY_IMAGE }}:${{ matrix.version }}-${{ matrix.variant }} | |
| build-args: | | |
| BOOST_VERSION=${{ matrix.version }} | |
| BOOST_VARIANT=${{ matrix.variant }} | |
| outputs: type=image,push-by-digest=true,name-canonical=true | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| - name: Export digest | |
| run: | | |
| mkdir -p ${{ runner.temp }}/digests | |
| digest="${{ steps.build.outputs.digest }}" | |
| echo "${{ env.REGISTRY_IMAGE }}@${digest}" > "${{ runner.temp }}/digests/${{ matrix.version }}-${{ matrix.variant }}-${{ env.PLATFORM_PAIR }}.txt" | |
| - name: Upload digest | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: digests-${{ matrix.version }}-${{ matrix.variant }}-${{ env.PLATFORM_PAIR }} | |
| path: ${{ runner.temp }}/digests/* | |
| if-no-files-found: error | |
| retention-days: 1 | |
| merge: | |
| name: Merge manifests | |
| runs-on: ubuntu-latest | |
| needs: build | |
| if: github.ref_type == 'tag' || github.ref_name == 'master' | |
| steps: | |
| - name: Download all digests | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: ${{ runner.temp }}/digests | |
| pattern: digests-* | |
| merge-multiple: true | |
| - name: Login to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ secrets.GHCR_USERNAME }} | |
| password: ${{ secrets.GHCR_PAT }} | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Group and create manifests | |
| working-directory: ${{ runner.temp }}/digests | |
| run: | | |
| for combo in $(ls digests-* | sed 's/^digests-\(.*\)-linux-.*/\1/' | sort -u); do | |
| echo "::group::Creating manifest for $combo" | |
| files=$(ls digests-${combo}-* 2>/dev/null || true) | |
| if [ -z "$files" ]; then | |
| echo "⚠️ Skipping $combo – no digests found" | |
| echo "::endgroup::" | |
| continue | |
| fi | |
| digests=$(cat $files | tr '\n' ' ') | |
| docker buildx imagetools create $digests \ | |
| -t ${{ env.REGISTRY_IMAGE }}:${combo} | |
| docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${combo} | |
| echo "::endgroup::" | |
| done |