name: Publish

on:
  push:
    tags:
      - '[0-9]+.[0-9]+.[0-9]+*'     # Semver-Tag

permissions:
  id-token: write                   # Required for OIDC
  contents: read

jobs:
  Publish:
    runs-on: ubuntu-latest
    steps:

      # Checkout
      - uses: actions/checkout@v4

      # Node
      - uses: actions/setup-node@v4
        with:
          node-version: '20'
          registry-url: 'https://registry.npmjs.org'

      # Update
      - name: Update
        run: npm install npm -g
      
      # Install
      - name: Build
        run: npm install

      # Build
      - name: Build
        run: npm run build

      # Publish
      - name: Publish
        run: npm publish sinclair-typebox-*.tgz --provenance --access public
        working-directory: target/build