diff --git a/.github/docker/Dockerfile.win b/.github/docker/Dockerfile.win deleted file mode 100644 index 2f0409c..0000000 --- a/.github/docker/Dockerfile.win +++ /dev/null @@ -1,23 +0,0 @@ -#escape=` -FROM mcr.microsoft.com/windows/servercore:ltsc2016 - -# Set the Node.js version you want to install -ENV NODE_VERSION 16.20.1 - -# Download and install Node.js -RUN powershell -Command ` - $ErrorActionPreference = 'Stop'; ` - Invoke-WebRequest -Uri https://nodejs.org/dist/v$env:NODE_VERSION/node-v$env:NODE_VERSION-win-x64.zip -OutFile node.zip; ` - Expand-Archive -Path node.zip -DestinationPath C:\; ` - Rename-Item -Path C:\node-v$env:NODE_VERSION-win-x64 -NewName C:\nodejs; ` - Remove-Item -Force node.zip - -# Add Node.js to PATH -ENV PATH="C:\nodejs;C:\nodejs\node_modules\npm\bin;${PATH}" - -WORKDIR "C:\mongodb-client-encryption" -COPY . . - -RUN node "C:\mongodb-client-encryption\.github\scripts\libmongocrypt.mjs" - -CMD ["ping", "-i", "20", "localhost"] diff --git a/.github/scripts/buildx.mjs b/.github/scripts/buildx.mjs deleted file mode 100644 index fb5f342..0000000 --- a/.github/scripts/buildx.mjs +++ /dev/null @@ -1,68 +0,0 @@ -import child_process from 'node:child_process'; -import events from 'node:events'; -import fs from 'node:fs/promises'; -import path from 'node:path'; -import url from 'node:url'; - -const __dirname = path.dirname(url.fileURLToPath(import.meta.url)); - -/** Resolves to the root of this repository */ -function resolveRoot(...paths) { - return path.resolve(__dirname, '..', '..', ...paths); -} - -/** `xtrace` style command runner, uses spawn so that stdio is inherited */ -async function run(command, args = [], options = {}) { - const commandDetails = `+ ${command} ${args.join(' ')}${options.cwd ? ` (in: ${options.cwd})` : ''}`; - console.error(commandDetails); - const proc = child_process.spawn(command, args, { - stdio: 'inherit', - cwd: resolveRoot('.'), - ...options - }); - await events.once(proc, 'exit'); - - if (proc.exitCode != 0) throw new Error(`CRASH(${proc.exitCode}): ${commandDetails}`); -} - -async function main() { - await fs.rm(resolveRoot('build'), { recursive: true, force: true }); - await fs.rm(resolveRoot('prebuilds'), { recursive: true, force: true }); - - try { - // Locally you probably already have this - await run('docker', ['buildx', 'use', 'builder']); - } catch { - // But if not, create one - await run('docker', ['buildx', 'create', '--name', 'builder', '--bootstrap', '--use']); - } - - const platform = - process.platform === 'win32' ? 'windows/amd64' : 'linux/s390x,linux/arm64,linux/amd64'; - const dockerFile = - process.platform === 'win32' - ? resolveRoot('./.github/docker/Dockerfile.win') - : resolveRoot('./.github/docker/Dockerfile.glibc'); - - await run('docker', [ - 'buildx', - 'build', - // '--progress=plain', // By default buildx detects tty and does some fancy collapsing, set progress=plain for debugging - '--platform', - platform, - '--output', - 'type=local,dest=./prebuilds,platform-split=false', - '-f', - dockerFile, - resolveRoot('.') - ]); - - /** - * Running locally and want a fresh start? - * - * docker buildx prune --force - * docker buildx rm builder - */ -} - -await main(); diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0e5bf77..5add203 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -8,7 +8,7 @@ on: name: build jobs: - macos_windows_builds: + host_builds: strategy: matrix: os: [macos-11, macos-latest, windows-2019] @@ -30,10 +30,13 @@ jobs: retention-days: 1 compression-level: 0 - linux_builds: + container_builds: outputs: artifact_id: ${{ steps.upload.outputs.artifact-id }} runs-on: ubuntu-latest + strategy: + matrix: + linux_arch: [linux/s390x, linux/arm64, linux/amd64] steps: - uses: actions/checkout@v4 @@ -44,7 +47,9 @@ jobs: uses: docker/setup-buildx-action@v3 - name: Run Buildx - run: node .github/scripts/buildx.mjs + run: | + docker buildx create --name builder --bootstrap --use + docker buildx build --platform ${{ matrix.linux_arch }} --ouput type=local,dest=./prebuilds,platform-split=false -f ./.github/docker/Dockerfile.glibc . - id: upload name: Upload prebuild @@ -57,7 +62,7 @@ jobs: compression-level: 0 collect: - needs: [linux_builds, macos_windows_builds] + needs: [host_builds, container_builds] runs-on: ubunutu-latest steps: - uses: actions/download-artifact@v4