Skip to content

Commit b4e5489

Browse files
committed
chore: windows
1 parent b139d23 commit b4e5489

File tree

4 files changed

+64
-27
lines changed

4 files changed

+64
-27
lines changed

.github/docker/Dockerfile.win

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#escape=`
2+
FROM mcr.microsoft.com/windows/servercore:ltsc2016
3+
4+
# Set the Node.js version you want to install
5+
ENV NODE_VERSION 16.20.1
6+
7+
# Download and install Node.js
8+
RUN powershell -Command `
9+
$ErrorActionPreference = 'Stop'; `
10+
Invoke-WebRequest -Uri https://nodejs.org/dist/v$env:NODE_VERSION/node-v$env:NODE_VERSION-win-x64.zip -OutFile node.zip; `
11+
Expand-Archive -Path node.zip -DestinationPath C:\; `
12+
Rename-Item -Path C:\node-v$env:NODE_VERSION-win-x64 -NewName C:\nodejs; `
13+
Remove-Item -Force node.zip
14+
15+
# Add Node.js to PATH
16+
ENV PATH="C:\nodejs;C:\nodejs\node_modules\npm\bin;${PATH}"
17+
18+
WORKDIR "C:\mongodb-client-encryption"
19+
COPY . .
20+
21+
RUN node "C:\mongodb-client-encryption\.github\scripts\libmongocrypt.mjs"
22+
23+
CMD ["ping", "-i", "20", "localhost"]

.github/scripts/build_linux.mjs renamed to .github/scripts/buildx.mjs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ function resolveRoot(...paths) {
1313

1414
/** `xtrace` style command runner, uses spawn so that stdio is inherited */
1515
async function run(command, args = [], options = {}) {
16-
const commandDetails = `+ ${command} ${args.join(' ')}${options.cwd ? ` (in: ${options.cwd})` : ''}`
16+
const commandDetails = `+ ${command} ${args.join(' ')}${options.cwd ? ` (in: ${options.cwd})` : ''}`;
1717
console.error(commandDetails);
1818
const proc = child_process.spawn(command, args, {
1919
stdio: 'inherit',
@@ -37,16 +37,23 @@ async function main() {
3737
await run('docker', ['buildx', 'create', '--name', 'builder', '--bootstrap', '--use']);
3838
}
3939

40+
const platform =
41+
process.platform === 'win32' ? 'windows/amd64' : 'linux/s390x,linux/arm64,linux/amd64';
42+
const dockerFile =
43+
process.platform === 'win32'
44+
? resolveRoot('./.github/docker/Dockerfile.win')
45+
: resolveRoot('./.github/docker/Dockerfile.glibc');
46+
4047
await run('docker', [
4148
'buildx',
4249
'build',
4350
// '--progress=plain', // By default buildx detects tty and does some fancy collapsing, set progress=plain for debugging
4451
'--platform',
45-
'linux/s390x,linux/arm64,linux/amd64',
52+
platform,
4653
'--output',
4754
'type=local,dest=./prebuilds,platform-split=false',
4855
'-f',
49-
resolveRoot('./.github/docker/Dockerfile.glibc'),
56+
dockerFile,
5057
resolveRoot('.')
5158
]);
5259

.github/scripts/libmongocrypt.mjs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,10 @@ export async function downloadLibMongoCrypt(nodeDepsRoot, { ref }) {
174174

175175
const unzipArgs = ['-xzv', '-C', `_libmongocrypt-${ref}`, `${prebuild}/nocrypto`];
176176
console.error(`+ tar ${unzipArgs.join(' ')}`);
177-
const unzip = child_process.spawn('tar', unzipArgs, { stdio: ['pipe', 'inherit'], cwd: resolveRoot('.') });
177+
const unzip = child_process.spawn('tar', unzipArgs, {
178+
stdio: ['pipe', 'inherit'],
179+
cwd: resolveRoot('.')
180+
});
178181

179182
const [response] = await events.once(https.get(downloadURL), 'response');
180183

.github/workflows/build.yml

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -8,46 +8,50 @@ on:
88
name: build
99

1010
jobs:
11-
builds:
11+
macos_windows_builds:
1212
outputs:
1313
artifact_id: ${{ steps.upload.outputs.artifact-id }}
1414
strategy:
1515
matrix:
16-
os: [ubuntu-latest, windows-2019, macos-11, macos-latest]
16+
os: [macos-11, macos-latest, windows-2019]
1717
runs-on: ${{ matrix.os }}
1818
steps:
1919
- uses: actions/checkout@v4
2020

21-
- if: ${{ runner.os == 'Linux' }}
22-
name: Set up QEMU
23-
uses: docker/setup-qemu-action@v3
21+
- name: Build ${{ matrix.os }} Prebuild
22+
run: node .github/scripts/libmongocrypt.mjs ${{ runner.os == 'Windows' && '--build' || '' }}
23+
shell: bash
2424

25-
- if: ${{ runner.os == 'Linux' }}
26-
name: Set up Docker Buildx
27-
uses: docker/setup-buildx-action@v3
25+
- id: upload
26+
name: Upload prebuild
27+
uses: actions/upload-artifact@v4
28+
with:
29+
name: build-${{ matrix.os }}
30+
path: prebuilds/
31+
if-no-files-found: 'error'
32+
retention-days: 1
2833

29-
- if: ${{ runner.os == 'Linux' }}
30-
name: Build ${{ runner.os }} Prebuild
31-
run: node .github/scripts/build_linux.mjs
34+
linux_builds:
35+
outputs:
36+
artifact_id: ${{ steps.upload.outputs.artifact-id }}
37+
runs-on: ubuntu-latest
38+
steps:
39+
- uses: actions/checkout@v4
3240

33-
- if: ${{ runner.os != 'Linux' }}
34-
name: Setup nodejs
35-
uses: actions/setup-node@v4
36-
with:
37-
node-version: 'lts/*'
38-
cache: 'npm'
39-
registry-url: 'https://registry.npmjs.org'
41+
- name: Set up QEMU
42+
uses: docker/setup-qemu-action@v3
4043

41-
- if: ${{ runner.os != 'Linux' }}
42-
name: Build ${{ runner.os }} Prebuild
43-
run: node .github/scripts/libmongocrypt.mjs
44-
shell: bash
44+
- name: Set up Docker Buildx
45+
uses: docker/setup-buildx-action@v3
46+
47+
- name: Run Buildx
48+
run: node .github/scripts/buildx.mjs
4549

4650
- id: upload
4751
name: Upload prebuild
4852
uses: actions/upload-artifact@v4
4953
with:
50-
name: build-${{ matrix.os }}
54+
name: build-linux
5155
path: prebuilds/
5256
if-no-files-found: 'error'
5357
retention-days: 1

0 commit comments

Comments
 (0)