From b943609390a76cd682d279ba678cf4be4521c0f6 Mon Sep 17 00:00:00 2001 From: CrazyMax Date: Tue, 11 Aug 2020 21:49:46 +0200 Subject: [PATCH] Switch to tonistiigi/binfmt Add platforms input to choose what platforms to install Signed-off-by: CrazyMax --- .github/workflows/setup-qemu-ci.yml | 12 ++++++++---- setup-qemu/README.md | 10 ++++++---- setup-qemu/action.yml | 10 +++++++--- setup-qemu/dist/index.js | 15 +++------------ setup-qemu/src/main.ts | 15 +++------------ 5 files changed, 27 insertions(+), 35 deletions(-) diff --git a/.github/workflows/setup-qemu-ci.yml b/.github/workflows/setup-qemu-ci.yml index 29aec6b..2ab6bca 100644 --- a/.github/workflows/setup-qemu-ci.yml +++ b/.github/workflows/setup-qemu-ci.yml @@ -16,9 +16,12 @@ jobs: strategy: fail-fast: false matrix: - qemu-version: - - latest - - 4.2.0-7 + image: + - tonistiigi/binfmt:latest + - tonistiigi/binfmt:buildkit + platforms: + - all + - arm64,riscv64,arm steps: - name: Runner info @@ -33,4 +36,5 @@ jobs: name: Set up QEMU uses: ./setup-qemu/ with: - qemu-version: ${{ matrix.qemu-version }} + image: ${ matrix.image } + platforms: ${ matrix.platforms } diff --git a/setup-qemu/README.md b/setup-qemu/README.md index c6c48ec..d4990b5 100644 --- a/setup-qemu/README.md +++ b/setup-qemu/README.md @@ -32,7 +32,8 @@ jobs: name: Set up QEMU uses: docker/actions/setup-qemu@v2 with: - qemu-version: latest + image: tonistiigi/binfmt:latest + platforms: all ``` ## Customizing @@ -41,9 +42,10 @@ jobs: Following inputs can be used as `step.with` keys -| Name | Type | Default | Description | -|------------------|---------|-----------|------------------------------------| -| `qemu-version` | String | `latest` | [qemu-user-static](https://github.com/multiarch/qemu-user-static) version (Docker tag). Example: `4.2.0-7` | +| Name | Type | Default | Description | +|------------------|---------|-----------------------------|------------------------------------| +| `image` | String | `tonistiigi/binfmt:latest` | QEMU static binaries Docker image. Example: [`tonistiigi/binfmt:latest`](https://hub.docker.com/r/tonistiigi/binfmt/tags) | +| `platforms` | String | `all` | Platforms to install. Example: `arm64,riscv64,arm` | ## Limitation diff --git a/setup-qemu/action.yml b/setup-qemu/action.yml index c50d676..d75993a 100644 --- a/setup-qemu/action.yml +++ b/setup-qemu/action.yml @@ -7,9 +7,13 @@ branding: icon: 'truck' inputs: - qemu-version: - description: 'QEMU static binaries Docker image version. Example: 4.2.0-7' - default: 'latest' + image: + description: 'QEMU static binaries Docker image. Example: tonistiigi/binfmt:latest' + default: 'tonistiigi/binfmt:latest' + required: false + platforms: + description: 'Platforms to install. Example: arm64,riscv64,arm' + default: 'all' required: false runs: diff --git a/setup-qemu/dist/index.js b/setup-qemu/dist/index.js index 3c67a7d..163a4b3 100644 --- a/setup-qemu/dist/index.js +++ b/setup-qemu/dist/index.js @@ -1011,19 +1011,10 @@ function run() { core.setFailed('Only supported on linux platform'); return; } - const qemuVer = core.getInput('qemu-version') || 'latest'; + const image = core.getInput('image') || 'tonistiigi/binfmt:latest'; + const platforms = core.getInput('platforms') || 'all'; core.info(`💎 Installing QEMU static binaries...`); - yield exec.exec('docker', [ - 'run', - '--rm', - '--privileged', - `multiarch/qemu-user-static:${qemuVer}`, - '--reset', - '-p', - 'yes', - '--credential', - 'yes' - ]); + yield exec.exec('docker', ['run', '--rm', '--privileged', image, '--install', platforms]); } catch (error) { core.setFailed(error.message); diff --git a/setup-qemu/src/main.ts b/setup-qemu/src/main.ts index 6b7ea91..7ffbc19 100644 --- a/setup-qemu/src/main.ts +++ b/setup-qemu/src/main.ts @@ -9,20 +9,11 @@ async function run(): Promise { return; } - const qemuVer: string = core.getInput('qemu-version') || 'latest'; + const image: string = core.getInput('image') || 'tonistiigi/binfmt:latest'; + const platforms: string = core.getInput('platforms') || 'all'; core.info(`💎 Installing QEMU static binaries...`); - await exec.exec('docker', [ - 'run', - '--rm', - '--privileged', - `multiarch/qemu-user-static:${qemuVer}`, - '--reset', - '-p', - 'yes', - '--credential', - 'yes' - ]); + await exec.exec('docker', ['run', '--rm', '--privileged', image, '--install', platforms]); } catch (error) { core.setFailed(error.message); }