diff --git a/scripts/blueprints/workflows/os-arch.yaml b/scripts/blueprints/workflows/os-arch.yaml index 83d152f575fd..285f45759442 100644 --- a/scripts/blueprints/workflows/os-arch.yaml +++ b/scripts/blueprints/workflows/os-arch.yaml @@ -30,7 +30,7 @@ output: type: boolean default: false concurrency: - group: bake + group: ${{ github.workflow }} cancel-in-progress: ${{ inputs.cancel-in-progress == true }} jobs: prepare: @@ -71,19 +71,20 @@ output: uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4 with: fetch-depth: 1 - # https://github.com/docker/setup-qemu-action - - name: Setup QEMU - uses: docker/setup-qemu-action@68827325e0b33c7199eb31dd4e31fbe9023e06e3 # v3 - with: - platforms: all - # https://hub.docker.com/r/tonistiigi/binfmt - image: tonistiigi/binfmt:qemu-v6.2.0 # https://github.com/docker/setup-buildx-action - name: Setup buildx - uses: docker/setup-buildx-action@d70bba72b1f3fd22344832f00baa16ece964efeb # v3 + id: setup-buildx + uses: docker/setup-buildx-action@988b5a0280414f521da01fcc63a27aeeb4b104db # v3.6.1 with: driver-opts: network=host install: true + # https://github.com/docker/setup-qemu-action + - name: Setup QEMU + uses: docker/setup-qemu-action@49b3bc8e6bdd4a60e6116a5414239cba5943d3cf # v3.2.0 + with: + platforms: all + # https://hub.docker.com/r/tonistiigi/binfmt + image: tonistiigi/binfmt:qemu-v8.0.4-33 # https://github.com/docker/login-action - name: Login to DockerHub uses: docker/login-action@e92390c5fb421da1463c202d546fed0ec5c39f20 # v3 diff --git a/scripts/blueprints/workflows/os-device.yaml b/scripts/blueprints/workflows/os-device.yaml index d120eb910b05..b015eeb03e21 100644 --- a/scripts/blueprints/workflows/os-device.yaml +++ b/scripts/blueprints/workflows/os-device.yaml @@ -30,7 +30,7 @@ output: type: boolean default: false concurrency: - group: bake + group: ${{ github.workflow }} cancel-in-progress: ${{ inputs.cancel-in-progress == true }} jobs: prepare: @@ -71,19 +71,20 @@ output: uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4 with: fetch-depth: 1 - # https://github.com/docker/setup-qemu-action - - name: Setup QEMU - uses: docker/setup-qemu-action@68827325e0b33c7199eb31dd4e31fbe9023e06e3 # v3 - with: - platforms: all - # https://hub.docker.com/r/tonistiigi/binfmt - image: tonistiigi/binfmt:qemu-v6.2.0 # https://github.com/docker/setup-buildx-action - name: Setup buildx + id: setup-buildx uses: docker/setup-buildx-action@d70bba72b1f3fd22344832f00baa16ece964efeb # v3 with: driver-opts: network=host install: true + # https://github.com/docker/setup-qemu-action + - name: Setup QEMU + uses: docker/setup-qemu-action@49b3bc8e6bdd4a60e6116a5414239cba5943d3cf # v3.2.0 + with: + platforms: all + # https://hub.docker.com/r/tonistiigi/binfmt + image: tonistiigi/binfmt:qemu-v8.0.4-33 # https://github.com/docker/login-action - name: Login to DockerHub uses: docker/login-action@e92390c5fb421da1463c202d546fed0ec5c39f20 # v3 diff --git a/scripts/blueprints/workflows/stack-arch.yaml b/scripts/blueprints/workflows/stack-arch.yaml index 851465ff98a2..dec03aa0f813 100644 --- a/scripts/blueprints/workflows/stack-arch.yaml +++ b/scripts/blueprints/workflows/stack-arch.yaml @@ -31,7 +31,7 @@ output: type: boolean default: false concurrency: - group: bake + group: ${{ github.workflow }} cancel-in-progress: ${{ inputs.cancel-in-progress == true }} jobs: prepare: @@ -72,19 +72,20 @@ output: uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4 with: fetch-depth: 1 - # https://github.com/docker/setup-qemu-action - - name: Setup QEMU - uses: docker/setup-qemu-action@68827325e0b33c7199eb31dd4e31fbe9023e06e3 # v3 - with: - platforms: all - # https://hub.docker.com/r/tonistiigi/binfmt - image: tonistiigi/binfmt:qemu-v6.2.0 # https://github.com/docker/setup-buildx-action - name: Setup buildx + id: setup-buildx uses: docker/setup-buildx-action@d70bba72b1f3fd22344832f00baa16ece964efeb # v3 with: driver-opts: network=host install: true + # https://github.com/docker/setup-qemu-action + - name: Setup QEMU + uses: docker/setup-qemu-action@49b3bc8e6bdd4a60e6116a5414239cba5943d3cf # v3.2.0 + with: + platforms: all + # https://hub.docker.com/r/tonistiigi/binfmt + image: tonistiigi/binfmt:qemu-v8.0.4-33 # https://github.com/docker/login-action - name: Login to DockerHub uses: docker/login-action@e92390c5fb421da1463c202d546fed0ec5c39f20 # v3 diff --git a/scripts/blueprints/workflows/stack-device.yaml b/scripts/blueprints/workflows/stack-device.yaml index 14550cb65d9b..4e6bf3c2d456 100644 --- a/scripts/blueprints/workflows/stack-device.yaml +++ b/scripts/blueprints/workflows/stack-device.yaml @@ -31,7 +31,7 @@ output: type: boolean default: false concurrency: - group: bake + group: ${{ github.workflow }} cancel-in-progress: ${{ inputs.cancel-in-progress == true }} jobs: prepare: @@ -72,19 +72,20 @@ output: uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4 with: fetch-depth: 1 - # https://github.com/docker/setup-qemu-action - - name: Setup QEMU - uses: docker/setup-qemu-action@68827325e0b33c7199eb31dd4e31fbe9023e06e3 # v3 - with: - platforms: all - # https://hub.docker.com/r/tonistiigi/binfmt - image: tonistiigi/binfmt:qemu-v6.2.0 # https://github.com/docker/setup-buildx-action - name: Setup buildx + id: setup-buildx uses: docker/setup-buildx-action@d70bba72b1f3fd22344832f00baa16ece964efeb # v3 with: driver-opts: network=host install: true + # https://github.com/docker/setup-qemu-action + - name: Setup QEMU + uses: docker/setup-qemu-action@49b3bc8e6bdd4a60e6116a5414239cba5943d3cf # v3.2.0 + with: + platforms: all + # https://hub.docker.com/r/tonistiigi/binfmt + image: tonistiigi/binfmt:qemu-v8.0.4-33 # https://github.com/docker/login-action - name: Login to DockerHub uses: docker/login-action@e92390c5fb421da1463c202d546fed0ec5c39f20 # v3 diff --git a/scripts/generate-workflows.js b/scripts/generate-workflows.js index aafdb6bc6c6d..d6657ffd4543 100644 --- a/scripts/generate-workflows.js +++ b/scripts/generate-workflows.js @@ -32,12 +32,58 @@ const balena = getSdk({ dataDirectory: false, }); +function getRunnerLabels(arch) { + switch (arch) { + case 'aarch64': + return ['self-hosted', 'base-images', 'ARM64']; + case 'amd64': + return ['self-hosted', 'base-images', 'X64']; + case 'armv7hf': + return ['self-hosted', 'base-images', 'ARM64']; + case 'i386': + return ['self-hosted', 'base-images', 'X64']; + case 'rpi': + return ['self-hosted', 'base-images', 'ARM64']; + default: + console.error(`Unsupported arch: ${arch}`); + process.exit(1); + } +} + +function getPlatform(arch) { + switch (arch) { + case 'aarch64': + return 'linux/arm64'; + case 'amd64': + return 'linux/amd64'; + case 'armv7hf': + return 'linux/arm/v7'; + case 'i386': + return 'linux/386'; + case 'rpi': + return 'linux/arm/v5'; + default: + console.error(`Unsupported arch: ${arch}`); + process.exit(1); + } +} + const workflows = {}; function addToWorkflow(dest, context) { const workflow = context.template; workflow.jobs.bake.strategy.matrix.target = `\${{ fromJSON(needs.prepare-${context.imageName}.outputs.bake-targets) }}`; + // Use self-hosted runners with pre-defined labels + workflow.jobs.bake['runs-on'] = getRunnerLabels( + context.children.arch.sw.slug, + ); + + // Update the QEMU condition to check if emulation is needed + workflow.jobs.bake.steps[2].if = `contains(steps.setup-buildx.outputs.platforms, '${getPlatform( + context.children.arch.sw.slug, + )}') == false`; + workflow.jobs[`prepare-${context.imageName}`] = workflow.jobs.prepare; workflow.jobs[`bake-${context.imageName}`] = workflow.jobs.bake;