name: CI

on:
  push:
  pull_request:
    branches: [master]

permissions:
  id-token: write
  contents: read

env:
  FORCE_COLOR: 1

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v5
      - uses: actions/setup-node@v6
        with:
          node-version: 24
          registry-url: https://registry.npmjs.org/
      - run: npm install
      - run: npm run lint
      - run: npm test
      - run: npm pack --dry-run
      - run: npm publish
        if: startsWith(github.ref, 'refs/tags/') && github.event_name != 'pull_request'
      - uses: actions/upload-artifact@v4
        if: ${{ failure() }}
        with:
          name: test-screenshots
          path: shots/
