Provide npm package for 32-bit Windows x86 (#1141)

This commit is contained in:
Fangjun Kuang
2024-07-17 12:33:15 +08:00
committed by GitHub
parent 5b1fa8750f
commit 9e448d03bc
12 changed files with 383 additions and 66 deletions

View File

@@ -108,6 +108,12 @@ jobs:
shell: bash
run: |
ls -lh ./sherpa-onnx-node
tar cjvf ./sherpa-onnx-node.tar.bz2 ./sherpa-onnx-node
- uses: actions/upload-artifact@v4
with:
name: sherpa-onnx-linux-x64
path: ./sherpa-onnx-node.tar.bz2
- name: Publish
shell: bash

View File

@@ -102,6 +102,12 @@ jobs:
shell: bash
run: |
ls -lh ./sherpa-onnx-node
tar cjvf ./sherpa-onnx-node.tar.bz2 ./sherpa-onnx-node
- uses: actions/upload-artifact@v4
with:
name: sherpa-onnx-${{ matrix.os }}
path: ./sherpa-onnx-node.tar.bz2
- name: Publish
shell: bash

View File

@@ -20,7 +20,7 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [windows-latest]
os: [windows-2019]
python-version: ["3.8"]
steps:
@@ -54,6 +54,8 @@ jobs:
-DSHERPA_ONNX_ENABLE_WEBSOCKET=OFF \
-DSHERPA_ONNX_ENABLE_PORTAUDIO=OFF \
-DSHERPA_ONNX_ENABLE_BINARY=OFF \
-DBUILD_ESPEAK_NG_EXE=OFF \
-DSHERPA_ONNX_BUILD_C_API_EXAMPLES=OFF \
..
ls -lh _deps/onnxruntime-src/lib/
@@ -65,6 +67,7 @@ jobs:
echo "----------"
cp -v _deps/onnxruntime-src/lib/*.lib ./install/lib
cp -v _deps/onnxruntime-src/lib/*.dll ./install/lib
echo "----------"
@@ -100,6 +103,12 @@ jobs:
shell: bash
run: |
ls -lh ./sherpa-onnx-node
tar cjvf ./sherpa-onnx-node.tar.bz2 ./sherpa-onnx-node
- uses: actions/upload-artifact@v4
with:
name: sherpa-onnx-win-x64
path: ./sherpa-onnx-node.tar.bz2
- name: Publish
shell: bash

176
.github/workflows/npm-addon-win-x86.yaml vendored Normal file
View File

@@ -0,0 +1,176 @@
name: npm-addon-win-x86
on:
push:
branches:
- node-addon
workflow_dispatch:
concurrency:
group: npm-addon-win-x86-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
id-token: write
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [windows-2019]
python-version: ["3.8"]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- uses: actions/setup-node@v4
with:
registry-url: 'https://registry.npmjs.org'
architecture: 'x86'
node-version: 16
- name: Display node version
shell: bash
run: |
node --version
- name: Show node-addon
shell: bash
run: |
cd scripts/node-addon-api/
npm i || true
cat node_modules/node-addon-api/package.json
cd node_modules/
tar cjf node-addon-api.tar.bz2 ./node-addon-api
- uses: actions/upload-artifact@v4
with:
name: node-addon-api
path: ./scripts/node-addon-api/node_modules/node-addon-api.tar.bz2
- name: Build sherpa-onnx
shell: bash
run: |
mkdir build
cd build
cmake \
-A Win32 \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=./install \
-DBUILD_SHARED_LIBS=ON \
-DSHERPA_ONNX_ENABLE_WEBSOCKET=OFF \
-DSHERPA_ONNX_ENABLE_PORTAUDIO=OFF \
-DSHERPA_ONNX_ENABLE_BINARY=OFF \
-DBUILD_ESPEAK_NG_EXE=OFF \
-DSHERPA_ONNX_BUILD_C_API_EXAMPLES=OFF \
..
ls -lh _deps/onnxruntime-src/lib/
cmake --build . --config Release --target install -- -m:6
ls -lh install/lib
echo "----------"
cp -v _deps/onnxruntime-src/lib/*.lib ./install/lib
cp -v _deps/onnxruntime-src/lib/*.dll ./install/lib
echo "----------"
ls -lh install/lib
- name: Build sherpa-onnx node-addon
shell: bash
run: |
d=$PWD
export SHERPA_ONNX_INSTALL_DIR=$d/build/install
cd scripts/node-addon-api/
npm i
npm config set cmake_js_A "Win32"
./node_modules/.bin/cmake-js compile -A Win32 --log-level verbose
- name: Prepare for publish
shell: bash
run: |
owner=${{ github.repository_owner }}
export owner
echo "---"
ls -lh build/install/lib/
echo "---"
ls -lh build/install/lib/
echo "---"
.github/scripts/node-addon/run.sh
- name: Display files to be published
shell: bash
run: |
ls -lh ./sherpa-onnx-node
tar cjvf ./sherpa-onnx-node.tar.bz2 ./sherpa-onnx-node
- uses: actions/upload-artifact@v4
with:
name: sherpa-onnx-win-ia32
path: ./sherpa-onnx-node.tar.bz2
upload:
needs: [build]
name: upload
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [macos-latest]
python-version: ["3.8"]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-node@v4
with:
registry-url: 'https://registry.npmjs.org'
- name: Display node version
shell: bash
run: |
node --version
- name: Retrieve artifact
uses: actions/download-artifact@v4
with:
name: sherpa-onnx-win-ia32
path: /tmp/files/
- name: Unzip
shell: bash
run: |
cd /tmp/files
tar xvf sherpa-onnx-node.tar.bz2
- name: Publish
shell: bash
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN2 }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN2 }}
token: ${{ secrets.NPM_TOKEN2 }}
run: |
cd /tmp/files/sherpa-onnx-node
npm publish --access public

View File

@@ -55,7 +55,7 @@ jobs:
SHERPA_ONNX_VERSION=$(grep "SHERPA_ONNX_VERSION" ./CMakeLists.txt | cut -d " " -f 2 | cut -d '"' -f 2)
echo "SHERPA_ONNX_VERSION $SHERPA_ONNX_VERSION"
# SHERPA_ONNX_VERSION=1.0.28
# SHERPA_ONNX_VERSION=1.0.30
src_dir=.github/scripts/node-addon
sed -i.bak s/SHERPA_ONNX_VERSION/$SHERPA_ONNX_VERSION/g $src_dir/package.json
@@ -71,6 +71,12 @@ jobs:
shell: bash
run: |
ls -lh ./sherpa-onnx-node
tar cjvf ./sherpa-onnx-node.tar.bz2 ./sherpa-onnx-node
- uses: actions/upload-artifact@v4
with:
name: sherpa-onnx-node
path: ./sherpa-onnx-node.tar.bz2
- name: Publish
shell: bash

View File

@@ -0,0 +1,86 @@
name: test-node-addon-npm-win-x86
on:
push:
branches:
- master
paths:
- '.github/workflows/test-nodejs-addon-npm-win-x86.yaml'
- 'CMakeLists.txt'
- 'cmake/**'
- 'sherpa-onnx/csrc/*'
- 'sherpa-onnx/c-api/*'
- 'scripts/node-addon-api/**'
- 'scripts/node-addon-api/*.js'
- 'nodejs-addon-examples/package.json'
- '.github/scripts/test-nodejs-addon-npm.sh'
pull_request:
branches:
- master
paths:
- '.github/workflows/test-nodejs-addon-npm-win-x86.yaml'
- 'CMakeLists.txt'
- 'cmake/**'
- 'sherpa-onnx/csrc/*'
- 'sherpa-onnx/c-api/*'
- 'scripts/node-addon-api/*.js'
- 'nodejs-addon-examples/package.json'
- '.github/scripts/test-nodejs-addon-npm.sh'
workflow_dispatch:
concurrency:
group: test-node-addon-npm-win-x86-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
jobs:
test-node-addon-npm-win-x86:
name: ${{ matrix.os }} node v${{ matrix.node-version }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [windows-latest]
node-version: ["16", "17", "18", "19", "21", "22"]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-node@v4
with:
registry-url: 'https://registry.npmjs.org'
node-version: ${{ matrix.node-version }}
architecture: 'x86'
- name: Display node version
shell: bash
run: |
node --version
- name: Run tests
shell: bash
run: |
d=nodejs-addon-examples
echo "dir: $d"
cd $d
npm install --verbose
git status
ls -lh
ls -lh node_modules
export DYLD_LIBRARY_PATH=$PWD/node_modules/sherpa-onnx-darwin-x64:$DYLD_LIBRARY_PATH
export DYLD_LIBRARY_PATH=$PWD/node_modules/sherpa-onnx-darwin-arm64:$DYLD_LIBRARY_PATH
export LD_LIBRARY_PATH=$PWD/node_modules/sherpa-onnx-darwin-x64:$DYLD_LIBRARY_PATH
export LD_LIBRARY_PATH=$PWD/node_modules/sherpa-onnx-darwin-arm64:$DYLD_LIBRARY_PATH
export LD_LIBRARY_PATH=$PWD/node_modules/sherpa-onnx-linux-x64:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH=$PWD/node_modules/sherpa-onnx-linux-arm64:$LD_LIBRARY_PATH
cd ../
.github/scripts/test-nodejs-addon-npm.sh