This is an automated email from the ASF dual-hosted git repository.

suyanhanx pushed a commit to branch nodejs-aarch64
in repository https://gitbox.apache.org/repos/asf/incubator-opendal.git

commit dd36fd740279b8fe67b8cb6bb8e2116d0a830470
Author: suyanhanx <[email protected]>
AuthorDate: Sun Nov 12 21:29:54 2023 +0800

    ci(bindings/nodejs): add aarch64 build support
    
    Signed-off-by: suyanhanx <[email protected]>
---
 .github/workflows/bindings_nodejs.yml | 79 ++++++++++++++++++++++++++++-------
 bindings/nodejs/package.json          |  5 ++-
 2 files changed, 67 insertions(+), 17 deletions(-)

diff --git a/.github/workflows/bindings_nodejs.yml 
b/.github/workflows/bindings_nodejs.yml
index 942758dc7..e474c0da9 100644
--- a/.github/workflows/bindings_nodejs.yml
+++ b/.github/workflows/bindings_nodejs.yml
@@ -73,19 +73,61 @@ jobs:
 
   linux:
     runs-on: ubuntu-latest
-    if: "startsWith(github.ref, 'refs/tags/')"
+    #    if: "startsWith(github.ref, 'refs/tags/')"
+    strategy:
+      matrix:
+        settings:
+          - target: x86_64-unknown-linux-gnu
+            build: |
+              docker run \
+              -v ${{ github.workspace }}:/build \
+              -e NAPI_TARGET=x86_64-unknown-linux-gnu \
+              -w /build/bindings/nodejs \
+              ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-debian \
+              bash -c "yarn build"
+              # change owner to current user
+              sudo chown -R 1001:121 *.node
+          - target: aarch64-unknown-linux-gnu
+            build: |
+              docker run \
+              -v ${{ github.workspace }}:/build \
+              -e NAPI_TARGET=aarch64-unknown-linux-gnu \
+              -w /build/bindings/nodejs \
+              ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-debian-aarch64 \
+              bash -c "set -e &&
+              rustup target add aarch64-unknown-linux-gnu &&
+              yarn build --target aarch64-unknown-linux-gnu &&
+              aarch64-unknown-linux-gnu-strip *.node"
+              # change owner to current user
+              sudo chown -R 1001:121 *.node
+
+          - target: aarch64-unknown-linux-musl
+            build: |
+              docker run \
+              -v ${{ github.workspace }}:/build \
+              -e NAPI_TARGET=aarch64-unknown-linux-musl \
+              -w /build/bindings/nodejs \
+              ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine \
+              bash -c "set -e &&
+              rustup target add aarch64-unknown-linux-musl &&
+              yarn build --target aarch64-unknown-linux-musl &&
+              /aarch64-linux-musl-cross/bin/aarch64-linux-musl-strip *.node"
+              # change owner to current user
+              sudo chown -R 1001:121 *.node
 
     # Notes: this defaults only apply on run tasks.
     defaults:
       run:
         working-directory: "bindings/nodejs"
 
+    name: linux - ${{ matrix.settings.target }}
+
     steps:
       - uses: actions/checkout@v4
       - name: Setup node
         uses: actions/setup-node@v4
         with:
-          node-version: 18
+          node-version: '18'
           cache: yarn
           cache-dependency-path: "bindings/nodejs/yarn.lock"
       - name: Corepack
@@ -93,29 +135,35 @@ jobs:
       - name: Install dependencies
         run: yarn install --immutable
       - name: Build
-        run: |
-          docker run \
-            -v ${{ github.workspace }}:/build \
-            -e NAPI_TARGET=x86_64-unknown-linux-gnu \
-            -w /build/bindings/nodejs \
-            ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-debian \
-            bash -c "yarn build"
-          # change owner to current user
-          sudo chown -R 1001:121 *.node
+        shell: bash
+        run: ${{ matrix.settings.build }}
       - uses: actions/upload-artifact@v3
         with:
-          name: bindings-linux
+          name: bindings-linux-${{ matrix.settings.target }}
           path: bindings/nodejs/*.node
 
   windows:
     runs-on: windows-latest
-    if: "startsWith(github.ref, 'refs/tags/')"
+    #    if: "startsWith(github.ref, 'refs/tags/')"
+    strategy:
+      matrix:
+        settings:
+          - target: x86_64-pc-windows-msvc
+            build: yarn build
+          - target: aarch64-pc-windows-msvc
+            build: |
+              rustup target add aarch64-pc-windows-msvc;
+              export NAPI_TARGET=aarch64-pc-windows-msvc;
+              yarn build
+
 
     # Notes: this defaults only apply on run tasks.
     defaults:
       run:
         working-directory: "bindings/nodejs"
 
+    name: windows - ${{ matrix.settings.target }}
+
     steps:
       - uses: actions/checkout@v4
       - name: Setup node
@@ -129,7 +177,7 @@ jobs:
       - name: Install dependencies
         run: yarn install --immutable
       - name: Build
-        run: yarn build
+        run: ${{ matrix.settings.build }}}
       - uses: actions/upload-artifact@v3
         with:
           name: bindings-windows
@@ -137,12 +185,11 @@ jobs:
 
   macos:
     runs-on: macos-latest
-    if: "startsWith(github.ref, 'refs/tags/')"
+    #    if: "startsWith(github.ref, 'refs/tags/')"
     strategy:
       matrix:
         settings:
           - target: x86_64-apple-darwin
-            test: yarn test
             build: |
               yarn build
               strip -x *.node
diff --git a/bindings/nodejs/package.json b/bindings/nodejs/package.json
index 7416b6e86..366172015 100644
--- a/bindings/nodejs/package.json
+++ b/bindings/nodejs/package.json
@@ -15,7 +15,10 @@
     "triples": {
       "defaults": true,
       "additional": [
-        "aarch64-apple-darwin"
+        "aarch64-apple-darwin",
+        "aarch64-unknown-linux-gnu",
+        "aarch64-unknown-linux-musl",
+        "aarch64-pc-windows-msvc"
       ]
     }
   },

Reply via email to