name: npm
on:
push:
tags: ['v*']
permissions:
contents: read
jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: dtolnay/rust-toolchain@stable
with:
targets: wasm32-unknown-unknown
- uses: jetli/wasm-pack-action@v0.4.0
- name: Install Binaryen (wasm-opt)
run: |
BINARYEN_VERSION=119
curl -sSL "https://github.com/WebAssembly/binaryen/releases/download/version_${BINARYEN_VERSION}/binaryen-version_${BINARYEN_VERSION}-x86_64-linux.tar.gz" | tar -xz
sudo mv binaryen-version_${BINARYEN_VERSION}/bin/wasm-opt /usr/local/bin/
- uses: actions/setup-node@v6
with:
node-version: 22
registry-url: 'https://registry.npmjs.org'
- name: Build WASM
run: |
wasm-pack build --release --target bundler --no-default-features --out-dir npm/pkg
wasm-opt -O --enable-bulk-memory npm/pkg/idb_bg.wasm -o npm/pkg/idb_bg.wasm
rm -f npm/pkg/.gitignore
- name: Set version from tag
run: |
VERSION="${GITHUB_REF#refs/tags/v}"
cd npm && npm version --no-git-tag-version "$VERSION"
- name: Publish to npm
run: cd npm && npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}