name: smoke-published

# Manually-triggered: pulls `otoji@<version>` from npm on each supported
# platform and verifies the native binding loads + exposes the expected
# API. Use this after `release-npm` to confirm cross-platform compat.

on:
  workflow_dispatch:
    inputs:
      version:
        description: "npm dist-tag or version (default: latest)"
        required: false
        default: "latest"

env:
  FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: "true"

jobs:
  smoke:
    name: ${{ matrix.os }}
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        os: [macos-latest, ubuntu-latest, windows-latest]
    steps:
      - uses: oven-sh/setup-bun@v2

      - name: Install otoji@${{ inputs.version }}
        shell: bash
        run: |
          set -euxo pipefail
          mkdir -p smoke && cd smoke
          bun init -y
          bun add otoji@${{ inputs.version }}
          ls node_modules | grep otoji

      - name: Require + sanity-check API
        shell: bash
        working-directory: smoke
        run: |
          bun -e '
            const m = require("otoji");
            const want = ["polishText", "transcribePcm"];
            console.log("loaded:", Object.keys(m));
            for (const k of want) {
              if (typeof m[k] !== "function") {
                console.error("missing export:", k);
                process.exit(1);
              }
            }
            console.log("ok");
          '
