Publish node-addon-api wrapper for sherpa-onnx as npm packages (#829)
This commit is contained in:
122
.github/workflows/npm-addon-linux-x64.yaml
vendored
Normal file
122
.github/workflows/npm-addon-linux-x64.yaml
vendored
Normal file
@@ -0,0 +1,122 @@
|
||||
name: npm-addon-linux-x64
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
|
||||
concurrency:
|
||||
group: npm-addon-linux-x64-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
id-token: write
|
||||
|
||||
jobs:
|
||||
npm-addon-linux-x64:
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [ubuntu-latest]
|
||||
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'
|
||||
|
||||
- name: Display node version
|
||||
shell: bash
|
||||
run: |
|
||||
node --version
|
||||
|
||||
- name: Build sherpa-onnx
|
||||
uses: addnab/docker-run-action@v3
|
||||
with:
|
||||
image: quay.io/pypa/manylinux2014_x86_64
|
||||
options: |
|
||||
--volume ${{ github.workspace }}/:/shared/
|
||||
shell: bash
|
||||
run: |
|
||||
uname -a
|
||||
gcc --version
|
||||
cmake --version
|
||||
cd /shared
|
||||
|
||||
mkdir build
|
||||
cd build
|
||||
cmake \
|
||||
-DCMAKE_INSTALL_PREFIX=./install \
|
||||
-DBUILD_SHARED_LIBS=ON \
|
||||
-DSHERPA_ONNX_ENABLE_WEBSOCKET=OFF \
|
||||
-DSHERPA_ONNX_ENABLE_PORTAUDIO=OFF \
|
||||
-DSHERPA_ONNX_ENABLE_BINARY=OFF \
|
||||
..
|
||||
make -j install
|
||||
|
||||
- name: Build sherpa-onnx node-addon
|
||||
shell: bash
|
||||
run: |
|
||||
export PKG_CONFIG_PATH=$PWD/build/install:$PKG_CONFIG_PATH
|
||||
sudo mkdir /shared
|
||||
sudo ln -s $PWD/build /shared/
|
||||
|
||||
ls -lh /shared/build
|
||||
|
||||
pkg-config --cflags sherpa-onnx
|
||||
pkg-config --libs sherpa-onnx
|
||||
|
||||
cd scripts/node-addon-api/
|
||||
|
||||
npm i
|
||||
|
||||
./node_modules/.bin/node-gyp configure build --verbose
|
||||
|
||||
- name: Prepare for publish
|
||||
shell: bash
|
||||
run: |
|
||||
export PKG_CONFIG_PATH=$PWD/build/install:$PKG_CONFIG_PATH
|
||||
|
||||
owner=${{ github.repository_owner }}
|
||||
export owner
|
||||
|
||||
|
||||
echo "---"
|
||||
ls -lh build/install/lib/
|
||||
sudo chown -R runner ./build
|
||||
echo "---"
|
||||
ls -lh build/install/lib/
|
||||
echo "---"
|
||||
|
||||
# find build/install/lib/ -maxdepth 1 -type l
|
||||
# find build/install/lib/ -maxdepth 1 -type l -delete
|
||||
#
|
||||
# echo "---"
|
||||
# ls -lh build/install/lib/
|
||||
|
||||
.github/scripts/node-addon/run.sh
|
||||
|
||||
- name: Display files to be published
|
||||
shell: bash
|
||||
run: |
|
||||
ls -lh ./sherpa-onnx-node
|
||||
|
||||
- name: Publish
|
||||
shell: bash
|
||||
env:
|
||||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||
run: |
|
||||
cd ./sherpa-onnx-node
|
||||
npm install
|
||||
npm ci
|
||||
# see https://docs.npmjs.com/generating-provenance-statements
|
||||
npm publish --provenance --access public
|
||||
114
.github/workflows/npm-addon-macos.yaml
vendored
Normal file
114
.github/workflows/npm-addon-macos.yaml
vendored
Normal file
@@ -0,0 +1,114 @@
|
||||
name: npm-addon-macos
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
|
||||
concurrency:
|
||||
group: npm-addon-macos-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
id-token: write
|
||||
|
||||
jobs:
|
||||
npm-addon-macos:
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [macos-11, macos-14]
|
||||
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'
|
||||
|
||||
- name: Display node version
|
||||
shell: bash
|
||||
run: |
|
||||
node --version
|
||||
|
||||
- name: ccache
|
||||
uses: hendrikmuhs/ccache-action@v1.2
|
||||
with:
|
||||
key: ${{ matrix.os }}-release-shared
|
||||
|
||||
- name: Build sherpa-onnx
|
||||
shell: bash
|
||||
run: |
|
||||
export CMAKE_CXX_COMPILER_LAUNCHER=ccache
|
||||
export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
|
||||
|
||||
mkdir build
|
||||
cd build
|
||||
cmake \
|
||||
-DCMAKE_INSTALL_PREFIX=./install \
|
||||
-DBUILD_SHARED_LIBS=ON \
|
||||
-DSHERPA_ONNX_ENABLE_WEBSOCKET=OFF \
|
||||
-DSHERPA_ONNX_ENABLE_PORTAUDIO=OFF \
|
||||
-DSHERPA_ONNX_ENABLE_BINARY=OFF \
|
||||
..
|
||||
make -j install
|
||||
|
||||
|
||||
|
||||
- name: Build sherpa-onnx node-addon
|
||||
shell: bash
|
||||
run: |
|
||||
export PKG_CONFIG_PATH=$PWD/build/install:$PKG_CONFIG_PATH
|
||||
|
||||
pkg-config --cflags sherpa-onnx
|
||||
pkg-config --libs sherpa-onnx
|
||||
|
||||
cd scripts/node-addon-api/
|
||||
|
||||
npm i
|
||||
|
||||
./node_modules/.bin/node-gyp configure build --verbose
|
||||
|
||||
- name: Prepare for publish
|
||||
shell: bash
|
||||
run: |
|
||||
export PKG_CONFIG_PATH=$PWD/build/install:$PKG_CONFIG_PATH
|
||||
|
||||
owner=${{ github.repository_owner }}
|
||||
export owner
|
||||
|
||||
|
||||
ls -lh build/install/lib/
|
||||
echo "---"
|
||||
|
||||
# find build/install/lib/ -maxdepth 1 -type l
|
||||
# find build/install/lib/ -maxdepth 1 -type l -delete
|
||||
|
||||
# echo "---"
|
||||
# ls -lh build/install/lib/
|
||||
|
||||
.github/scripts/node-addon/run.sh
|
||||
|
||||
- name: Display files to be published
|
||||
shell: bash
|
||||
run: |
|
||||
ls -lh ./sherpa-onnx-node
|
||||
|
||||
- name: Publish
|
||||
shell: bash
|
||||
env:
|
||||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||
run: |
|
||||
cd ./sherpa-onnx-node
|
||||
npm install
|
||||
npm ci
|
||||
# see https://docs.npmjs.com/generating-provenance-statements
|
||||
npm publish --provenance --access public
|
||||
80
.github/workflows/npm-addon.yaml
vendored
Normal file
80
.github/workflows/npm-addon.yaml
vendored
Normal file
@@ -0,0 +1,80 @@
|
||||
name: npm-addon
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
|
||||
concurrency:
|
||||
group: npm-addon-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
id-token: write
|
||||
|
||||
jobs:
|
||||
npm-addon:
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [ubuntu-latest]
|
||||
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'
|
||||
|
||||
- name: Display node version
|
||||
shell: bash
|
||||
run: |
|
||||
node --version
|
||||
|
||||
- name: ccache
|
||||
uses: hendrikmuhs/ccache-action@v1.2
|
||||
with:
|
||||
key: ${{ matrix.os }}-release-shared
|
||||
|
||||
- name: Prepare for publish
|
||||
shell: bash
|
||||
run: |
|
||||
owner=${{ github.repository_owner }}
|
||||
export owner
|
||||
|
||||
SHERPA_ONNX_VERSION=$(grep "SHERPA_ONNX_VERSION" ./CMakeLists.txt | cut -d " " -f 2 | cut -d '"' -f 2)
|
||||
echo "SHERPA_ONNX_VERSION $SHERPA_ONNX_VERSION"
|
||||
|
||||
src_dir=.github/scripts/node-addon
|
||||
sed -i.bak s/SHERPA_ONNX_VERSION/$SHERPA_ONNX_VERSION/g $src_dir/package.json
|
||||
sed -i.bak s/k2-fsa/$owner/g $src_dir/package.json
|
||||
|
||||
dst=sherpa-onnx-node
|
||||
mkdir $dst
|
||||
cp $src_dir/package.json $dst/
|
||||
cp $src_dir/README.md $dst/
|
||||
cp scripts/node-addon-api/lib/*.js $dst/
|
||||
|
||||
- name: Display files to be published
|
||||
shell: bash
|
||||
run: |
|
||||
ls -lh ./sherpa-onnx-node
|
||||
|
||||
- name: Publish
|
||||
shell: bash
|
||||
env:
|
||||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||
run: |
|
||||
cd ./sherpa-onnx-node
|
||||
npm install
|
||||
npm ci
|
||||
# see https://docs.npmjs.com/generating-provenance-statements
|
||||
npm publish --provenance --access public
|
||||
23
.github/workflows/test-nodejs-addon-api.yaml
vendored
23
.github/workflows/test-nodejs-addon-api.yaml
vendored
@@ -5,7 +5,7 @@ on:
|
||||
branches:
|
||||
- master
|
||||
paths:
|
||||
- '.github/workflows/test-node-addon-api.yaml'
|
||||
- '.github/workflows/test-nodejs-addon-api.yaml'
|
||||
- 'CMakeLists.txt'
|
||||
- 'cmake/**'
|
||||
- 'sherpa-onnx/csrc/*'
|
||||
@@ -16,7 +16,7 @@ on:
|
||||
branches:
|
||||
- master
|
||||
paths:
|
||||
- '.github/workflows/test-node-addon-api.yaml'
|
||||
- '.github/workflows/test-nodejs-addon-api.yaml'
|
||||
- 'CMakeLists.txt'
|
||||
- 'cmake/**'
|
||||
- 'sherpa-onnx/csrc/*'
|
||||
@@ -34,12 +34,13 @@ permissions:
|
||||
|
||||
jobs:
|
||||
test-node-addon-api:
|
||||
name: ${{ matrix.os }}
|
||||
name: ${{ matrix.os }} ${{ matrix.node-version }}
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [macos-latest, macos-14]
|
||||
os: [macos-11, macos-14, ubuntu-20.04, ubuntu-22.04]
|
||||
node-version: ["16", "17", "18", "19", "21", "22"]
|
||||
python-version: ["3.8"]
|
||||
|
||||
steps:
|
||||
@@ -55,6 +56,7 @@ jobs:
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
registry-url: 'https://registry.npmjs.org'
|
||||
node-version: ${{ matrix.node-version }}
|
||||
|
||||
- name: Display node version
|
||||
shell: bash
|
||||
@@ -69,9 +71,18 @@ jobs:
|
||||
- name: Build sherpa-onnx
|
||||
shell: bash
|
||||
run: |
|
||||
export CMAKE_CXX_COMPILER_LAUNCHER=ccache
|
||||
export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
|
||||
|
||||
mkdir build
|
||||
cd build
|
||||
cmake -DCMAKE_INSTALL_PREFIX=/tmp/sherpa-onnx -DBUILD_SHARED_LIBS=ON ..
|
||||
cmake \
|
||||
-DCMAKE_INSTALL_PREFIX=/tmp/sherpa-onnx \
|
||||
-DBUILD_SHARED_LIBS=ON \
|
||||
-DSHERPA_ONNX_ENABLE_WEBSOCKET=OFF \
|
||||
-DSHERPA_ONNX_ENABLE_PORTAUDIO=OFF \
|
||||
-DSHERPA_ONNX_ENABLE_BINARY=OFF \
|
||||
..
|
||||
make -j
|
||||
make install
|
||||
|
||||
@@ -87,8 +98,6 @@ jobs:
|
||||
pkg-config --cflags sherpa-onnx
|
||||
pkg-config --libs sherpa-onnx
|
||||
|
||||
a=$(pkg-config --cflags sherpa-onnx);a=${a:2};echo $a
|
||||
|
||||
npm i
|
||||
|
||||
./node_modules/.bin/node-gyp configure build --verbose
|
||||
|
||||
66
.github/workflows/test-nodejs-addon-npm.yaml
vendored
Normal file
66
.github/workflows/test-nodejs-addon-npm.yaml
vendored
Normal file
@@ -0,0 +1,66 @@
|
||||
name: test-node-addon-npm
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
paths:
|
||||
- '.github/workflows/test-nodejs-addon-npm.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'
|
||||
|
||||
pull_request:
|
||||
branches:
|
||||
- master
|
||||
paths:
|
||||
- '.github/workflows/test-nodejs-addon-npm.yaml'
|
||||
- 'CMakeLists.txt'
|
||||
- 'cmake/**'
|
||||
- 'sherpa-onnx/csrc/*'
|
||||
- 'sherpa-onnx/c-api/*'
|
||||
- 'scripts/node-addon-api/*.js'
|
||||
- 'nodejs-addon-examples/package.json'
|
||||
|
||||
workflow_dispatch:
|
||||
|
||||
concurrency:
|
||||
group: test-node-addon-npm-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
test-node-addon-npm:
|
||||
name: ${{ matrix.os }} node v${{ matrix.node-version }}
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [macos-11, macos-14, ubuntu-20.04, ubuntu-22.04]
|
||||
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 }}
|
||||
|
||||
- name: Display node version
|
||||
shell: bash
|
||||
run: |
|
||||
node --version
|
||||
|
||||
- name: Run tests
|
||||
shell: bash
|
||||
run: |
|
||||
.github/scripts/test-nodejs-addon-npm.sh
|
||||
Reference in New Issue
Block a user