Fix debian buster build (#162) #35
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: Build and Push Integration Containers | |
| on: | |
| workflow_dispatch: | |
| push: | |
| branches: | |
| - master | |
| paths: | |
| - 'integration/**' | |
| jobs: | |
| generate-matrix: | |
| runs-on: ubuntu-latest | |
| permissions: {} | |
| outputs: | |
| matrix: ${{ steps.set-matrix.outputs.matrix }} | |
| merge_matrix: ${{ steps.set-matrix.outputs.merge_matrix }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| persist-credentials: false | |
| - name: Generate matrix JSON | |
| id: set-matrix | |
| run: | | |
| MATRIX=$(for stage in build test testpublished upload; do | |
| subdir="integration/linux/$stage" | |
| find "$subdir" -maxdepth 1 -mindepth 1 -type d ! -name "_bootstrap" -printf "$stage\t%P\n" | |
| done | jq -R ' | |
| split("\t") as $parts | | |
| { | |
| stage: $parts[0], | |
| platform: ($parts[1] | split("-")[0]), | |
| platform_version: ($parts[1] | split("-")[1] // ""), | |
| } | | |
| if (.platform_version | test("^(x86_64|aarch64)$")) then | |
| [{ | |
| stage: .stage, | |
| platform: .platform, | |
| platform_version: .platform_version, | |
| build_on: ( | |
| if .platform_version == "x86_64" then "ubuntu-latest" | |
| elif .platform_version == "aarch64" then "ubuntu-24.04-arm" | |
| else "unrecognized" end | |
| ), | |
| docker_platform: ( | |
| if .platform_version == "x86_64" then "amd64" | |
| elif .platform_version == "aarch64" then "arm64" | |
| else "unrecognized" end | |
| ) | |
| }] | |
| else | |
| [ | |
| { | |
| stage: .stage, | |
| platform: .platform, | |
| platform_version: .platform_version, | |
| build_on: "ubuntu-latest", | |
| docker_platform: "amd64" | |
| }, | |
| { | |
| stage: .stage, | |
| platform: .platform, | |
| platform_version: .platform_version, | |
| build_on: "ubuntu-24.04-arm", | |
| docker_platform: "arm64" | |
| } | |
| ] | |
| end' | jq -s 'add') | |
| echo "matrix=$(echo "$MATRIX" | jq -c .)" >> $GITHUB_OUTPUT | |
| echo "merge_matrix=$(echo "$MATRIX" | jq -c ' | |
| group_by({stage, platform, platform_version}) | | |
| map({ | |
| stage: .[0].stage, | |
| platform: .[0].platform, | |
| platform_version: .[0].platform_version, | |
| }) | |
| ')" >> $GITHUB_OUTPUT | |
| build: | |
| needs: generate-matrix | |
| permissions: | |
| packages: write | |
| strategy: | |
| matrix: | |
| include: ${{ fromJson(needs.generate-matrix.outputs.matrix) }} | |
| runs-on: ${{ matrix.build_on }} | |
| env: | |
| REGISTRY_IMAGE: ghcr.io/${{ github.repository_owner }}/gelpkg-${{ matrix.stage }}-${{ matrix.platform }}-${{ matrix.platform_version }} | |
| SPV: ${{ matrix.stage }}-${{ matrix.platform }}-${{ matrix.platform_version }} | |
| SPVA: ${{ matrix.stage }}-${{ matrix.platform }}-${{ matrix.platform_version }}-${{ matrix.docker_platform }} | |
| outputs: | |
| date: ${{ steps.meta.outputs.date }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| persist-credentials: false | |
| - name: Set build date | |
| id: meta | |
| run: echo "date=$(date +%Y%m%d)" >> $GITHUB_OUTPUT | |
| - name: Get cache config | |
| id: gha_cache | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| core.exportVariable('ACTIONS_RESULTS_URL', process.env.ACTIONS_RESULTS_URL || ''); | |
| core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || ''); | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@b5ca514318bd6ebac0fb2aedd5d36ec1b5c232a2 # 3.10.0 | |
| with: | |
| cache-binary: false | |
| - name: Log in to GitHub Container Registry | |
| uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # 3.4.0 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Build and push by digest | |
| id: build | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: integration/linux/${{ matrix.stage }}/${{ matrix.platform }}-${{ matrix.platform_version }} | |
| platforms: linux/${{ matrix.docker_platform }} | |
| build-args: | | |
| SCCACHE_GHA_ENABLED=on | |
| ACTIONS_CACHE_SERVICE_V2=on | |
| secrets: | | |
| ACTIONS_RESULTS_URL=${{ env.ACTIONS_RESULTS_URL }} | |
| ACTIONS_RUNTIME_TOKEN=${{ env.ACTIONS_RUNTIME_TOKEN }} | |
| tags: | | |
| ${{ env.REGISTRY_IMAGE }} | |
| labels: | | |
| org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }} | |
| org.opencontainers.image.revision=${{ github.sha }} | |
| org.opencontainers.image.created=${{ steps.meta.outputs.date }} | |
| cache-from: type=registry,ref=${{ env.REGISTRY_IMAGE }}:cache-${{ matrix.docker_platform }} | |
| cache-to: type=registry,ref=${{ env.REGISTRY_IMAGE }}:cache-${{ matrix.docker_platform }} | |
| outputs: type=image,push-by-digest=true,name-canonical=true,push=true | |
| - name: Export digest | |
| run: | | |
| path="${{ runner.temp }}/digests/${{ env.SPV }}" | |
| digest="${{ steps.build.outputs.digest }}" | |
| mkdir -p "$path" | |
| touch "${path}/${digest#sha256:}" | |
| - name: Upload digest | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: digests-${{ env.SPVA }} | |
| path: ${{ runner.temp }}/digests/${{ env.SPV }}/* | |
| if-no-files-found: error | |
| retention-days: 1 | |
| merge: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| packages: write | |
| strategy: | |
| matrix: | |
| include: ${{ fromJson(needs.generate-matrix.outputs.merge_matrix) }} | |
| env: | |
| REGISTRY_IMAGE: ghcr.io/${{ github.repository_owner }}/gelpkg-${{ matrix.stage }}-${{ matrix.platform }}-${{ matrix.platform_version }} | |
| SPV: ${{ matrix.stage }}-${{ matrix.platform }}-${{ matrix.platform_version }} | |
| needs: | |
| - generate-matrix | |
| - build | |
| steps: | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@b5ca514318bd6ebac0fb2aedd5d36ec1b5c232a2 # 3.10.0 | |
| with: | |
| cache-binary: false | |
| - name: Log in to GitHub Container Registry | |
| uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # 3.4.0 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Download digests | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: ${{ runner.temp }}/digests/${{ env.SPV }} | |
| pattern: digests-${{ env.SPV }}-* | |
| merge-multiple: true | |
| - name: Create manifest list and push | |
| working-directory: ${{ runner.temp }}/digests/${{ env.SPV }} | |
| run: | | |
| ls -al | |
| printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' * | |
| docker buildx imagetools create \ | |
| --tag ${{ env.REGISTRY_IMAGE }}:latest \ | |
| --tag ${{ env.REGISTRY_IMAGE }}:${{ needs.build.outputs.date }} \ | |
| $(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *) |