# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
# For more information see: https://help.github.com/actions/language-and-framework-guides/publishing-nodejs-packages

name: Node.js Package

on:
  push:
    tags:
      - v[0-9]+.[0-9]+.[0-9]+*

jobs:
  publish-npm:
    runs-on: ubuntu-latest
    permissions:
      contents: read
      id-token: write
    steps:
      - name: Checkout repository
        uses: actions/checkout@v6
      - name: Use Node.js
        uses: actions/setup-node@v6
        with:
          node-version: 24
          registry-url: https://registry.npmjs.org/
      - name: Install dependencies
        run: npm ci
      - name: Build TypeScript (first pass)
        run: npm run build
        continue-on-error: true
      - name: Generate Typings
        run: npm run generate
      - name: Build TypeScript (second pass)
        run: npm run build
      - name: Lint
        run: npm run lint
      - name: Check code formatting
        run: npm run format:check
      - name: Test schema validity
        run: npm test
      - name: Publish to npm
        run: npm publish --provenance --access public
