From a88b156e5fdbf4ddc0a0feab122dcf8f47e911e9 Mon Sep 17 00:00:00 2001 From: Rahul Patni Date: Thu, 6 Feb 2025 13:46:49 -0800 Subject: [PATCH] ci: Publish Rust WASM package to npm (#5721) Adds GitHub Actions workflow to build, test and publish the ironfish-rust-wasm package to npm. Includes Firefox and Chrome headless testing and supports dry-run mode for validation before actual publishing. --- .../deploy-npm-ironfish-rust-wasm.yml | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 .github/workflows/deploy-npm-ironfish-rust-wasm.yml diff --git a/.github/workflows/deploy-npm-ironfish-rust-wasm.yml b/.github/workflows/deploy-npm-ironfish-rust-wasm.yml new file mode 100644 index 0000000000..b162c82787 --- /dev/null +++ b/.github/workflows/deploy-npm-ironfish-rust-wasm.yml @@ -0,0 +1,55 @@ +name: Deploy NPM Ironfish Rust Wasm + +on: + workflow_dispatch: + inputs: + dry-run: + description: 'Run the publish command in dry-run mode' + required: false + default: 'false' + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Use Node.js + uses: actions/setup-node@v4 + with: + node-version: 20 + registry-url: 'https://registry.npmjs.org' + cache: yarn + + - name: Cache Rust + uses: Swatinem/rust-cache@v2 + with: + shared-key: wasm + + - name: Install wasm-pack + run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh + + - name: Generate package + working-directory: ./ironfish-rust-wasm + run: wasm-pack build --release --target=web + + - name: Test in Firefox + working-directory: ./ironfish-rust-wasm + run: wasm-pack test --headless --firefox + + - name: Test in Chrome + working-directory: ./ironfish-rust-wasm + run: wasm-pack test --headless --chrome + + - name: Publish + working-directory: ./ironfish-rust-wasm/pkg + run: | + if [ ${{ github.event.inputs.dry-run }} = "true" ]; then + npm publish --access public --dry-run + else + npm publish --access public + fi + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}