Repository navigation
Availability of 0.2.4 #3
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # npm Publishing Workflow for OxiRS WASM bindings | |
| # Builds and publishes @cooljapan/oxirs to npm using wasm-pack | |
| name: npm Publish | |
| on: | |
| # Manual trigger for publishing | |
| workflow_dispatch: | |
| inputs: | |
| publish_target: | |
| description: 'Publish target' | |
| required: true | |
| default: 'dry-run' | |
| type: choice | |
| options: | |
| - dry-run | |
| - npm | |
| npm_tag: | |
| description: 'npm dist-tag (e.g., latest, beta, next)' | |
| required: false | |
| default: 'latest' | |
| type: string | |
| # Trigger on release tags | |
| push: | |
| tags: | |
| - 'v*' | |
| env: | |
| CARGO_TERM_COLOR: always | |
| WASM_PACK_VERSION: "0.13.1" | |
| SCOPE: "cooljapan" | |
| NPM_PACKAGE: "@cooljapan/oxirs" | |
| WASM_CRATE_DIR: "platforms/oxirs-wasm" | |
| jobs: | |
| build: | |
| name: Build WASM packages | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install Rust toolchain | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| targets: wasm32-unknown-unknown | |
| - name: Cache cargo registry & build | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.cargo/registry | |
| ~/.cargo/git | |
| target | |
| key: wasm-build-${{ hashFiles('**/Cargo.lock') }} | |
| restore-keys: wasm-build- | |
| - name: Install wasm-pack | |
| run: cargo install wasm-pack --version ${{ env.WASM_PACK_VERSION }} --locked || true | |
| - name: Build for bundler target | |
| working-directory: ${{ env.WASM_CRATE_DIR }} | |
| run: wasm-pack build --scope ${{ env.SCOPE }} --target bundler --out-dir pkg-bundler --release | |
| - name: Build for web target | |
| working-directory: ${{ env.WASM_CRATE_DIR }} | |
| run: wasm-pack build --scope ${{ env.SCOPE }} --target web --out-dir pkg-web --release | |
| - name: Build for Node.js target | |
| working-directory: ${{ env.WASM_CRATE_DIR }} | |
| run: wasm-pack build --scope ${{ env.SCOPE }} --target nodejs --out-dir pkg-node --release | |
| - name: Rename packages to @cooljapan/oxirs | |
| working-directory: ${{ env.WASM_CRATE_DIR }} | |
| run: | | |
| for dir in pkg-bundler pkg-web pkg-node; do | |
| if [ -f "${dir}/package.json" ]; then | |
| sed -i "s|\"@${SCOPE}/oxirs-wasm\"|\"${NPM_PACKAGE}\"|g" "${dir}/package.json" | |
| echo "Updated ${dir}/package.json → ${NPM_PACKAGE}" | |
| fi | |
| done | |
| - name: Show package info | |
| working-directory: ${{ env.WASM_CRATE_DIR }} | |
| run: | | |
| echo "=== bundler ===" | |
| cat pkg-bundler/package.json | |
| echo "" | |
| echo "=== web ===" | |
| cat pkg-web/package.json | |
| echo "" | |
| echo "=== node ===" | |
| cat pkg-node/package.json | |
| echo "" | |
| echo "=== WASM size ===" | |
| ls -lh pkg-bundler/*.wasm | |
| - name: Upload bundler package | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: npm-pkg-bundler | |
| path: ${{ env.WASM_CRATE_DIR }}/pkg-bundler/ | |
| - name: Upload web package | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: npm-pkg-web | |
| path: ${{ env.WASM_CRATE_DIR }}/pkg-web/ | |
| - name: Upload node package | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: npm-pkg-node | |
| path: ${{ env.WASM_CRATE_DIR }}/pkg-node/ | |
| publish: | |
| name: Publish to npm | |
| runs-on: ubuntu-latest | |
| needs: [build] | |
| if: github.event_name == 'workflow_dispatch' || startsWith(github.ref, 'refs/tags/') | |
| permissions: | |
| contents: read | |
| steps: | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '22' | |
| registry-url: 'https://registry.npmjs.org' | |
| - name: Download bundler package | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: npm-pkg-bundler | |
| path: pkg-bundler | |
| - name: Show package contents | |
| run: | | |
| echo "=== package.json ===" | |
| cat pkg-bundler/package.json | |
| echo "" | |
| echo "=== Files ===" | |
| ls -la pkg-bundler/ | |
| # Dry run (default for workflow_dispatch, or RC tags) | |
| - name: Publish (dry-run) | |
| if: >- | |
| github.event.inputs.publish_target == 'dry-run' || | |
| (github.event_name == 'push' && contains(github.ref, 'rc')) | |
| working-directory: pkg-bundler | |
| run: npm publish --access public --dry-run | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| # Publish to npm | |
| - name: Publish to npm | |
| if: >- | |
| github.event.inputs.publish_target == 'npm' || | |
| (github.event_name == 'push' && !contains(github.ref, 'rc')) | |
| working-directory: pkg-bundler | |
| run: | | |
| NPM_TAG="${{ github.event.inputs.npm_tag || 'latest' }}" | |
| echo "Publishing ${NPM_PACKAGE} with tag: ${NPM_TAG}" | |
| npm publish --access public --tag "${NPM_TAG}" | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| - name: Verify published package | |
| if: github.event.inputs.publish_target == 'npm' || (github.event_name == 'push' && !contains(github.ref, 'rc')) | |
| run: | | |
| sleep 10 | |
| npm view ${{ env.NPM_PACKAGE }} version |