|
| 1 | +name: GCC |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + paths: |
| 6 | + - .github/workflows/gcc.yml |
| 7 | + - docker/gcc/Dockerfile* |
| 8 | + workflow_dispatch: |
| 9 | + |
| 10 | +concurrency: |
| 11 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 12 | + cancel-in-progress: true |
| 13 | + |
| 14 | +defaults: |
| 15 | + run: |
| 16 | + shell: bash |
| 17 | + |
| 18 | +env: |
| 19 | + CONTAINER_REGISTRY: ghcr.io |
| 20 | + BUILDKIT_PROGRESS: plain |
| 21 | + |
| 22 | +jobs: |
| 23 | + # Build the Docker image for Debian using different versions of GCC and Clang. |
| 24 | + # Note, the `os` part of matrix must be kept in sync with the `merge` job below |
| 25 | + build: |
| 26 | + strategy: |
| 27 | + matrix: |
| 28 | + architecture: |
| 29 | + - platform: linux/amd64 |
| 30 | + runner: ubuntu-24.04 |
| 31 | + - platform: linux/arm64 |
| 32 | + runner: ubuntu-24.04-arm |
| 33 | + os: |
| 34 | + - release: bullseye |
| 35 | + compiler_version: 12 |
| 36 | + - release: bullseye |
| 37 | + compiler_version: 13 |
| 38 | + - release: bullseye |
| 39 | + compiler_version: 14 |
| 40 | + - release: bullseye |
| 41 | + compiler_version: 15 |
| 42 | + runs-on: ${{ matrix.architecture.runner }} |
| 43 | + permissions: |
| 44 | + packages: write |
| 45 | + steps: |
| 46 | + - name: Checkout repository |
| 47 | + uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0 |
| 48 | + - name: Set up Docker Buildx |
| 49 | + uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # v3.11.1 |
| 50 | + - name: Login to GitHub Registry |
| 51 | + uses: docker/login-action@184bdaa0721073962dff0199f1fb9940f07167d1 # v3.5.0 |
| 52 | + with: |
| 53 | + registry: ${{ env.CONTAINER_REGISTRY }} |
| 54 | + username: ${{ github.repository_owner }} |
| 55 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 56 | + - name: Prepare environment |
| 57 | + run: | |
| 58 | + GITHUB_REPO=${{ github.repository }} |
| 59 | + CONTAINER_REPO=${GITHUB_REPO@L} |
| 60 | + PLATFORM=${{ matrix.architecture.platform }} |
| 61 | + echo "PLATFORM_PAIR=${PLATFORM//\//-}" >> $GITHUB_ENV |
| 62 | + echo "CONTAINER_REPOSITORY=${CONTAINER_REPO}/gcc" >> $GITHUB_ENV |
| 63 | + echo "CONTAINER_IMAGE=${CONTAINER_REGISTRY}/${CONTAINER_REPO}/gcc" >> $GITHUB_ENV |
| 64 | + - name: Prepare image metadata |
| 65 | + id: meta |
| 66 | + uses: docker/metadata-action@c1e51972afc2121e065aed6d45c65596fe445f3f # v5.8.0 |
| 67 | + env: |
| 68 | + DOCKER_METADATA_ANNOTATIONS_LEVELS: manifest,manifest-descriptor |
| 69 | + with: |
| 70 | + images: ${{ env.CONTAINER_IMAGE }} |
| 71 | + tags: | |
| 72 | + type=raw,value=${{ matrix.os.compiler_version }}-${{matrix.os.release}} |
| 73 | + type=sha,prefix=${{ matrix.os.compiler_version }}-${{matrix.os.release}}-sha- |
| 74 | + labels: | |
| 75 | + org.opencontainers.image.authors=For inquiries, please use https://${{ github.repository }}/issues |
| 76 | + org.opencontainers.image.documentation=https://${{ github.repository }} |
| 77 | + org.opencontainers.image.vendor=XRPLF |
| 78 | + org.opencontainers.image.title=${{ env.CONTAINER_REPOSITORY }} |
| 79 | + - name: Build image |
| 80 | + if: ${{ env.CONTAINER_IMAGE }} |
| 81 | + id: build |
| 82 | + uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0 |
| 83 | + with: |
| 84 | + build-args: | |
| 85 | + BUILDKIT_DOCKERFILE_CHECK=skip=InvalidDefaultArgInFrom |
| 86 | + BUILDKIT_INLINE_CACHE=1 |
| 87 | + context: . |
| 88 | + file: docker/gcc/Dockerfile.${{ matrix.os.compiler_version }}-${{ matrix.os.release }} |
| 89 | + labels: ${{ steps.meta.outputs.labels }} |
| 90 | + outputs: type=image,name=${{ env.CONTAINER_IMAGE }},push-by-digest=true,name-canonical=true,push=${{ github.ref_type == 'branch' && github.ref_name == github.event.repository.default_branch }} |
| 91 | + platforms: ${{ matrix.architecture.platform }} |
| 92 | + provenance: mode=max |
| 93 | + push: ${{ github.ref_type == 'branch' && github.ref_name == github.event.repository.default_branch }} |
| 94 | + sbom: true |
| 95 | + - name: Export digest |
| 96 | + if: ${{ github.ref_type == 'branch' && github.ref_name == github.event.repository.default_branch }} |
| 97 | + run: | |
| 98 | + mkdir -p /tmp/digests |
| 99 | + DIGEST="${{ steps.build.outputs.digest }}" |
| 100 | + touch "/tmp/digests/${DIGEST#sha256:}" |
| 101 | + - name: Upload digest |
| 102 | + if: ${{ github.ref_type == 'branch' && github.ref_name == github.event.repository.default_branch }} |
| 103 | + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 |
| 104 | + with: |
| 105 | + name: digests-${{ matrix.os.compiler_version }}-${{ matrix.os.release }}-${{ env.PLATFORM_PAIR }} |
| 106 | + path: /tmp/digests/* |
| 107 | + if-no-files-found: error |
| 108 | + retention-days: 1 |
| 109 | + |
| 110 | + merge: |
| 111 | + if: ${{ github.ref_type == 'branch' && github.ref_name == github.event.repository.default_branch }} |
| 112 | + strategy: |
| 113 | + matrix: |
| 114 | + os: |
| 115 | + - release: bullseye |
| 116 | + compiler_version: 12 |
| 117 | + - release: bullseye |
| 118 | + compiler_version: 13 |
| 119 | + - release: bullseye |
| 120 | + compiler_version: 14 |
| 121 | + - release: bullseye |
| 122 | + compiler_version: 15 |
| 123 | + runs-on: ubuntu-24.04 |
| 124 | + needs: |
| 125 | + - build |
| 126 | + permissions: |
| 127 | + packages: write |
| 128 | + steps: |
| 129 | + - name: Checkout repository |
| 130 | + uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0 |
| 131 | + - name: Download digests |
| 132 | + uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0 |
| 133 | + with: |
| 134 | + path: /tmp/digests |
| 135 | + pattern: digests-${{ matrix.os.compiler_version }}-${{ matrix.os.release }}-* |
| 136 | + merge-multiple: true |
| 137 | + - name: Set up Docker Buildx |
| 138 | + uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # v3.11.1 |
| 139 | + - name: Login to GitHub Registry |
| 140 | + uses: docker/login-action@184bdaa0721073962dff0199f1fb9940f07167d1 # v3.5.0 |
| 141 | + with: |
| 142 | + registry: ${{ env.CONTAINER_REGISTRY }} |
| 143 | + username: ${{ github.repository_owner }} |
| 144 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 145 | + - name: Prepare environment |
| 146 | + run: | |
| 147 | + GITHUB_REPO=${{ github.repository }} |
| 148 | + CONTAINER_REPO=${GITHUB_REPO@L} |
| 149 | + echo "CONTAINER_IMAGE=${CONTAINER_REGISTRY}/${CONTAINER_REPO}/gcc" >> $GITHUB_ENV |
| 150 | + - name: Prepare container metadata |
| 151 | + id: meta |
| 152 | + uses: docker/metadata-action@c1e51972afc2121e065aed6d45c65596fe445f3f # v5.8.0 |
| 153 | + env: |
| 154 | + DOCKER_METADATA_ANNOTATIONS_LEVELS: index |
| 155 | + with: |
| 156 | + images: ${{ env.CONTAINER_IMAGE }} |
| 157 | + tags: | |
| 158 | + type=raw,value=${{ matrix.os.compiler_version }}-${{matrix.os.release}} |
| 159 | + type=sha,prefix=${{ matrix.os.compiler_version }}-${{matrix.os.release}}-sha- |
| 160 | + - name: Create manifest list and push |
| 161 | + working-directory: /tmp/digests |
| 162 | + run: | |
| 163 | + eval "docker buildx imagetools create \ |
| 164 | + $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \ |
| 165 | + $(jq -cr '.annotations | map("--annotation \"" + . + "\"") | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \ |
| 166 | + $(printf '${{ env.CONTAINER_IMAGE }}@sha256:%s ' *)" |
| 167 | + - name: Inspect image |
| 168 | + run: | |
| 169 | + docker buildx imagetools inspect ${{ env.CONTAINER_IMAGE }}:${{ steps.meta.outputs.version }} |
0 commit comments