name: Build

# This workflow is called by the main CI workflow
# No direct triggers - only invoked by ci.yml
on:
  workflow_call:

jobs:
  build:
    runs-on: ubuntu-latest
    env:
      ROLLUP_FORCE_JS: 1
    
    steps:
      - name: Checkout code
        uses: actions/checkout@v4
      
      - name: Setup Node.js
        uses: actions/setup-node@v4
        with:
          node-version: '22'
          cache: 'npm'
      
      - name: Install dependencies
        run: npm ci
      
      - name: Build project
        run: npm run build
      
      - name: Check build artifacts
        run: |
          if [ ! -f dist/index.js ]; then
            echo "Build failed: dist/index.js not found"
            exit 1
          fi
          if [ ! -f dist/cli.js ]; then
            echo "Build failed: dist/cli.js not found"
            exit 1
          fi
          echo "Build successful!"

