diff --git a/.github/workflows/.test-bake.yml b/.github/workflows/.test-bake.yml index afdbe9e..7655a84 100644 --- a/.github/workflows/.test-bake.yml +++ b/.github/workflows/.test-bake.yml @@ -408,3 +408,42 @@ jobs: output: local sbom: true target: hello-cross + + bake-aws-nodistrib: + uses: ./.github/workflows/bake.yml + permissions: + contents: read + id-token: write + with: + distribute: false + cache: true + cache-scope: bake-aws-nodistrib + context: test + output: image + push: ${{ github.event_name != 'pull_request' }} + sbom: true + target: hello-cross + meta-images: | + public.ecr.aws/q3b5f1u4/test-docker-action + meta-tags: | + type=raw,value=bake-ghbuilder-nodistrib-${{ github.run_id }} + secrets: + registry-auths: | + - registry: public.ecr.aws + username: ${{ secrets.AWS_ACCESS_KEY_ID }} + password: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + + bake-local-nodistrib: + uses: ./.github/workflows/bake.yml + permissions: + contents: read + id-token: write + with: + distribute: false + artifact-name: bake-nodistrib-output + artifact-upload: true + context: test + output: local + sbom: true + sign: ${{ github.event_name != 'pull_request' }} + target: hello-cross diff --git a/.github/workflows/.test-build.yml b/.github/workflows/.test-build.yml index 4ba6b74..f2733bd 100644 --- a/.github/workflows/.test-build.yml +++ b/.github/workflows/.test-build.yml @@ -503,3 +503,42 @@ jobs: output: local platforms: linux/amd64,linux/arm64 sbom: true + + build-aws-nodistrib: + uses: ./.github/workflows/build.yml + permissions: + contents: read + id-token: write + with: + distribute: false + cache: true + cache-scope: build-aws-nodistrib + file: test/hello.Dockerfile + output: image + platforms: linux/amd64,linux/arm64 + push: ${{ github.event_name != 'pull_request' }} + sbom: true + meta-images: | + public.ecr.aws/q3b5f1u4/test-docker-action + meta-tags: | + type=raw,value=build-ghbuilder-nodistrib-${{ github.run_id }} + secrets: + registry-auths: | + - registry: public.ecr.aws + username: ${{ secrets.AWS_ACCESS_KEY_ID }} + password: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + + build-local-nodistrib: + uses: ./.github/workflows/build.yml + permissions: + contents: read + id-token: write + with: + distribute: false + artifact-name: build-nodistrib-output + artifact-upload: true + file: test/hello.Dockerfile + output: local + platforms: linux/amd64,linux/arm64 + sbom: true + sign: ${{ github.event_name != 'pull_request' }} diff --git a/.github/workflows/bake.yml b/.github/workflows/bake.yml index 73662a7..709ebd4 100644 --- a/.github/workflows/bake.yml +++ b/.github/workflows/bake.yml @@ -8,6 +8,11 @@ on: description: "Ubuntu GitHub Hosted Runner to build on (one of auto, amd64, arm64). The auto runner selects the best-matching runner based on target platforms. You can set it to amd64 if your build doesn't require emulation (e.g. cross-compilation)" required: false default: 'auto' + distribute: + type: boolean + description: "Whether to distribute the build across multiple runners (one platform per runner)" + required: false + default: true setup-qemu: type: boolean description: "Runs the setup-qemu-action step to install QEMU static binaries" @@ -174,6 +179,7 @@ jobs: INPUT_MATRIX-SIZE-LIMIT: ${{ env.MATRIX_SIZE_LIMIT }} INPUT_ACTIONS-ID-TOKEN-SET: ${{ env.ACTIONS_ID_TOKEN_REQUEST_TOKEN != '' && env.ACTIONS_ID_TOKEN_REQUEST_URL != '' }} INPUT_RUNNER: ${{ inputs.runner }} + INPUT_DISTRIBUTE: ${{ inputs.distribute }} INPUT_ARTIFACT-UPLOAD: ${{ inputs.artifact-upload }} INPUT_CONTEXT: ${{ inputs.context }} INPUT_FILES: ${{ inputs.files }} @@ -196,6 +202,7 @@ jobs: const inpActionsIdTokenSet = core.getBooleanInput('actions-id-token-set'); const inpRunner = core.getInput('runner'); + const inpDistribute = core.getBooleanInput('distribute'); const inpArtifactUpload = core.getBooleanInput('artifact-upload'); const inpContext = core.getInput('context'); const inpFiles = Util.getInputList('files'); @@ -265,7 +272,7 @@ jobs: } const platforms = def.target[target].platforms || []; - if (platforms.length > inpMatrixSizeLimit) { + if (inpDistribute && platforms.length > inpMatrixSizeLimit) { core.setFailed(`Platforms to build exceed matrix size limit of ${inpMatrixSizeLimit}`); return; } @@ -278,7 +285,7 @@ jobs: await core.group(`Set includes output`, async () => { let includes = []; - if (platforms.length === 0) { + if (!inpDistribute || platforms.length === 0) { includes.push({ index: 0, runner: runner === 'auto' ? 'ubuntu-24.04' : runner diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 06023ed..08dd418 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -8,6 +8,11 @@ on: description: "Ubuntu GitHub Hosted Runner to build on (one of auto, amd64, arm64). The auto runner selects the best-matching runner based on target platforms. You can set it to amd64 if your build doesn't require emulation (e.g. cross-compilation)" required: false default: 'auto' + distribute: + type: boolean + description: "Whether to distribute the build across multiple runners (one platform per runner)" + required: false + default: true setup-qemu: type: boolean description: "Runs the setup-qemu-action step to install QEMU static binaries" @@ -181,6 +186,7 @@ jobs: INPUT_MATRIX-SIZE-LIMIT: ${{ env.MATRIX_SIZE_LIMIT }} INPUT_ACTIONS-ID-TOKEN-SET: ${{ env.ACTIONS_ID_TOKEN_REQUEST_TOKEN != '' && env.ACTIONS_ID_TOKEN_REQUEST_URL != '' }} INPUT_RUNNER: ${{ inputs.runner }} + INPUT_DISTRIBUTE: ${{ inputs.distribute }} INPUT_ARTIFACT-UPLOAD: ${{ inputs.artifact-upload }} INPUT_OUTPUT: ${{ inputs.output }} INPUT_PLATFORMS: ${{ inputs.platforms }} @@ -195,6 +201,7 @@ jobs: const inpActionsIdTokenSet = core.getBooleanInput('actions-id-token-set'); const inpRunner = core.getInput('runner'); + const inpDistribute = core.getBooleanInput('distribute'); const inpArtifactUpload = core.getBooleanInput('artifact-upload'); const inpPlatforms = Util.getInputList('platforms'); const inpOutput = core.getInput('output'); @@ -226,7 +233,7 @@ jobs: return; } - if (inpPlatforms.length > inpMatrixSizeLimit) { + if (inpDistribute && inpPlatforms.length > inpMatrixSizeLimit) { core.setFailed(`Platforms to build exceed matrix size limit of ${inpMatrixSizeLimit}`); return; } @@ -239,7 +246,7 @@ jobs: await core.group(`Set includes output`, async () => { let includes = []; - if (inpPlatforms.length === 0) { + if (!inpDistribute || inpPlatforms.length === 0) { includes.push({ index: 0, runner: runner === 'auto' ? 'ubuntu-24.04' : runner @@ -438,6 +445,7 @@ jobs: INPUT_PLATFORM: ${{ matrix.platform }} INPUT_SBOM-IMAGE: ${{ env.SBOM_IMAGE }} INPUT_LOCAL-EXPORT-DIR: ${{ env.LOCAL_EXPORT_DIR }} + INPUT_DISTRIBUTE: ${{ inputs.distribute }} INPUT_ANNOTATIONS: ${{ inputs.annotations }} INPUT_CACHE: ${{ inputs.cache }} INPUT_CACHE-SCOPE: ${{ inputs.cache-scope }} @@ -445,6 +453,7 @@ jobs: INPUT_LABELS: ${{ inputs.labels }} INPUT_CONTEXT: ${{ inputs.context }} INPUT_OUTPUT: ${{ inputs.output }} + INPUT_PLATFORMS: ${{ inputs.platforms }} INPUT_PUSH: ${{ inputs.push }} INPUT_SBOM: ${{ inputs.sbom }} INPUT_TARGET: ${{ inputs.target }} @@ -463,6 +472,7 @@ jobs: const inpSbomImage = core.getInput('sbom-image'); const inpLocalExportDir = core.getInput('local-export-dir'); + const inpDistribute = core.getBooleanInput('distribute'); const inpAnnotations = core.getMultilineInput('annotations'); const inpCache = core.getBooleanInput('cache'); @@ -471,6 +481,7 @@ jobs: const inpContext = core.getInput('context'); const inpLabels = core.getMultilineInput('labels'); const inpOutput = core.getInput('output'); + const inpPlatforms = core.getInput('platforms'); const inpPush = core.getBooleanInput('push'); const inpSbom = core.getBooleanInput('sbom'); const inpTarget = core.getInput('target'); @@ -502,6 +513,8 @@ jobs: if (inpPlatform) { core.setOutput('platform', inpPlatform); + } else if (!inpDistribute && inpPlatforms) { + core.setOutput('platform', inpPlatforms); } core.setOutput('sbom', inpSbom ? `generator=${inpSbomImage}` : 'false'); diff --git a/README.md b/README.md index bd721ec..9a322a0 100644 --- a/README.md +++ b/README.md @@ -228,6 +228,7 @@ on: | Name | Type | Default | Description | |------------------------|----------|--------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | `runner` | String | `auto` | [Ubuntu GitHub Hosted Runner](https://github.com/actions/runner-images?tab=readme-ov-file#available-images) to build on (one of `auto`, `amd64`, `arm64`). The `auto` runner selects the best-matching runner based on target `platforms`. You can set it to `amd64` if your build doesn't require emulation (e.g. cross-compilation) | +| `distribute` | Bool | `true` | Whether to distribute the build across multiple runners (one platform per runner) | | `setup-qemu` | Bool | `false` | Runs the `setup-qemu-action` step to install QEMU static binaries | | `artifact-name` | String | `docker-github-builder-assets` | Name of the uploaded GitHub artifact (for `local` output) | | `artifact-upload` | Bool | `false` | Upload build output GitHub artifact (for `local` output) | @@ -335,6 +336,7 @@ on: | Name | Type | Default | Description | |------------------------|--------|--------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | `runner` | String | `auto` | [Ubuntu GitHub Hosted Runner](https://github.com/actions/runner-images?tab=readme-ov-file#available-images) to build on (one of `auto`, `amd64`, `arm64`). The `auto` runner selects the best-matching runner based on target `platforms`. You can set it to `amd64` if your build doesn't require emulation (e.g. cross-compilation) | +| `distribute` | Bool | `true` | Whether to distribute the build across multiple runners (one platform per runner) | | `setup-qemu` | Bool | `false` | Runs the `setup-qemu-action` step to install QEMU static binaries | | `artifact-name` | String | `docker-github-builder-assets` | Name of the uploaded GitHub artifact (for `local` output) | | `artifact-upload` | Bool | `false` | Upload build output GitHub artifact (for `local` output) |