diff --git a/.github/typescript-ci-patch.yaml b/.github/typescript-ci-patch.yaml index 009707b..71545a9 100644 --- a/.github/typescript-ci-patch.yaml +++ b/.github/typescript-ci-patch.yaml @@ -2,24 +2,29 @@ - op: replace path: /jobs/test/strategy/matrix value: - node_version: - - "12" - - "14" - - "16" - rust_version: + rust_version: - 1.56.0 - stable - beta - os: - - macos-10.15 - - ubuntu-20.04 - - windows-2019 + node_version: + - 12 + - 14 + - 16 + system: + - os: macos-10.15 + target: x86_64-apple-darwin + - os: macos-11 + target: aarch64-apple-darwin + - os: ubuntu-20.04 + target: x86_64-unknown-linux-gnu + - os: windows-2019 + target: x86_64-pc-windows-msvc - op: add path: /jobs/test/strategy/fail-fast value: false - op: replace path: /jobs/test/runs-on - value: "${{ matrix.os }}" + value: "${{ matrix.system.os }}" # These steps are lifted from the Rust CI workflow, cargo-test job. - op: add @@ -44,17 +49,22 @@ # Only check coverage in one of the matrix job instances. - op: add path: /jobs/test/steps/6/if - value: ${{ contains(matrix.os, 'ubuntu') && matrix.node_version == '16' && matrix.rust_version == 'stable' && github.base_ref != '' }} + value: ${{ contains(matrix.system.os, 'ubuntu') && matrix.node_version == '16' && matrix.rust_version == 'stable' && github.base_ref != '' }} # Also run on musl. That means we need to run it in a Docker container. To do that, we copy the entire job and modify its # strategy/matrix. - op: copy from: /jobs/test path: /jobs/test-docker -- op: replace +- op: remove + path: /jobs/test-docker/strategy/matrix/system +- op: add path: /jobs/test-docker/strategy/matrix/os value: - ubuntu-20.04 +- op: replace + path: /jobs/test-docker/runs-on + value: "${{ matrix.os }}" - op: add path: /jobs/test-docker/container value: diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index 21db244..16c716e 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -16,18 +16,26 @@ env: jobs: publish-github: - runs-on: ${{ matrix.os }} + runs-on: ${{ matrix.system.os }} strategy: fail-fast: false matrix: node_version: - - '12' - - '14' - - '16' - os: - - macos-10.15 - - ubuntu-20.04 - - windows-2019 + - 12 + - 14 + - 16 + system: + - os: macos-10.15 + target: x86_64-apple-darwin + - os: macos-11 + target: aarch64-apple-darwin + # only needed in this case, where we're cross compiling until runners with m1 chips exist + pre_gyp_platform: darwin + pre_gyp_arch: arm64 + - os: ubuntu-20.04 + target: x86_64-unknown-linux-gnu + - os: windows-2019 + target: x86_64-pc-windows-msvc steps: - uses: actions/checkout@v2 with: @@ -40,6 +48,8 @@ jobs: with: profile: minimal toolchain: stable + target: ${{ matrix.system.target }} + default: true override: true - name: Install modules run: yarn install --ignore-scripts @@ -47,6 +57,9 @@ jobs: id: build # Use bash, even on Windows. shell: bash + env: + PRE_GYP_PLATFORM: ${{ matrix.system.pre_gyp_platform }} + PRE_GYP_ARCH: ${{ matrix.system.pre_gyp_arch }} run: | node publish.js cd bin-package diff --git a/.github/workflows/typescript-ci.yaml b/.github/workflows/typescript-ci.yaml index a0fe410..34e46ac 100644 --- a/.github/workflows/typescript-ci.yaml +++ b/.github/workflows/typescript-ci.yaml @@ -11,21 +11,26 @@ name: TypeScript CI workflow_dispatch: null jobs: test: - runs-on: ${{ matrix.os }} + runs-on: ${{ matrix.system.os }} strategy: matrix: - node_version: - - '12' - - '14' - - '16' rust_version: - 1.56.0 - stable - beta - os: - - macos-10.15 - - ubuntu-20.04 - - windows-2019 + node_version: + - 12 + - 14 + - 16 + system: + - os: macos-10.15 + target: x86_64-apple-darwin + - os: macos-11 + target: aarch64-apple-darwin + - os: ubuntu-20.04 + target: x86_64-unknown-linux-gnu + - os: windows-2019 + target: x86_64-pc-windows-msvc fail-fast: false steps: - uses: actions/checkout@v2 @@ -45,8 +50,8 @@ jobs: - name: Run tests run: yarn run test - name: Check test coverage - if: ${{ contains(matrix.os, 'ubuntu') && matrix.node_version == '16' && matrix.rust_version - == 'stable' && github.base_ref != '' }} + if: ${{ contains(matrix.system.os, 'ubuntu') && matrix.node_version == '16' + && matrix.rust_version == 'stable' && github.base_ref != '' }} uses: anuraag016/Jest-Coverage-Diff@V1.3 with: fullCoverageDiff: false @@ -56,14 +61,14 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - node_version: - - '12' - - '14' - - '16' rust_version: - 1.56.0 - stable - beta + node_version: + - 12 + - 14 + - 16 os: - ubuntu-20.04 fail-fast: false diff --git a/package.json b/package.json index 54b3a8e..b1d31b6 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,8 @@ "win32" ], "cpu": [ - "x64" + "x64", + "arm64" ], "scripts": { "compile": "cargo-cp-artifact -a cdylib recrypt_node ./bin-package/index.node -- cargo build --release --message-format=json-render-diagnostics", diff --git a/publish.js b/publish.js index 58e272b..2fe4de8 100755 --- a/publish.js +++ b/publish.js @@ -45,7 +45,9 @@ fs.writeFileSync("./dist/package.json", JSON.stringify(npmPackageJson, null, 2)) //Use a fully qualified path to pre-gyp binary for Windows support const cwd = shell.pwd().toString(); -shell.exec(`${cwd}/node_modules/@mapbox/node-pre-gyp/bin/node-pre-gyp package`); +const replacementArch = process.env.PRE_GYP_ARCH ? `--target_arch=${process.env.PRE_GYP_ARCH}` : ""; +const replacementPlatform = process.env.PRE_GYP_PLATFORM ? `--target_platform=${process.env.PRE_GYP_PLATFORM}` : ""; +shell.exec(`${cwd}/node_modules/@mapbox/node-pre-gyp/bin/node-pre-gyp package ${replacementArch} ${replacementPlatform}`); var tgz = shell.exec("find ./build -name *.tar.gz"); shell.cp(tgz, "./bin-package/"); shell.pushd("./dist");