fix: enable npm publishing in CI workflow #3
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
| name: CI | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| branches: [main] | |
| jobs: | |
| test: | |
| runs-on: macos-latest | |
| strategy: | |
| matrix: | |
| node-version: [18, 20] | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup Bun | |
| uses: oven-sh/setup-bun@v1 | |
| with: | |
| bun-version: latest | |
| - name: Install dependencies | |
| run: bun install --frozen-lockfile | |
| - name: Check macOS version (for info only) | |
| run: sw_vers | |
| - name: Validate pre-built native binaries exist | |
| run: bun run validate-binaries | |
| - name: Build TypeScript only | |
| run: bun run build:ts | |
| - name: Run tests | |
| run: bun test | |
| - name: Test package contents | |
| run: | | |
| npm pack --dry-run | |
| echo "Checking if native binaries will be included in package..." | |
| npm pack --dry-run 2>&1 | grep -E "\.(node|dylib)$" || echo "⚠️ No native binaries found in package" | |
| publish: | |
| needs: test | |
| runs-on: macos-latest | |
| if: github.ref == 'refs/heads/main' | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup Bun | |
| uses: oven-sh/setup-bun@v1 | |
| with: | |
| bun-version: latest | |
| - name: Install dependencies | |
| run: bun install --frozen-lockfile | |
| - name: Validate pre-built binaries | |
| run: bun run validate-binaries | |
| - name: Build TypeScript | |
| run: bun run build:ts | |
| - name: Setup Node.js for npm | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: "20" | |
| registry-url: "https://registry.npmjs.org" | |
| - name: Publish to npm (dry run) | |
| run: npm publish --dry-run --access public | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| - name: Publish to npm | |
| run: npm publish --access public | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |