name: CI

on: [push, pull_request]

permissions: {}

jobs:
  build:
    permissions:
      contents: read
    strategy:
      matrix:
        platform: [ubuntu-latest]
        node: ['24.x']
    name: Node ${{ matrix.node }} (${{ matrix.platform }})
    runs-on: ${{ matrix.platform }}
    steps:
      - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
      - uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
        with:
          node-version: ${{ matrix.node }}
      - name: install dependencies
        run: yarn install --ignore-engines
      - name: run tests
        run: yarn run test:coverage
      - name: coverage
        uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f # v7.0.0
        if: github.actor != 'dependabot[bot]'
        with:
          fail_ci_if_error: true
          verbose: false
          token: ${{ secrets.CODECOV_TOKEN }}
        env:
          CI: true

  release:
    name: do semantic release
    runs-on: 'ubuntu-latest'
    needs: build
    permissions:
      contents: write # to be able to publish a GitHub release
      issues: write # to be able to comment on released issues
      pull-requests: write # to be able to comment on released pull requests
      id-token: write # to enable use of OIDC for npm provenance
      packages: write # to be able to publish to GitHub Packages
    steps:
      - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
      - uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
        with:
          node-version: '24.x'
      - name: install dependencies
        run: yarn install --ignore-engines
      - name: release
        run: yarn run semantic-release
        env:
          GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
          NPM_CONFIG_PROVENANCE: true
          NPM_TOKEN: ''
        if: github.event_name == 'push' && github.ref == 'refs/heads/master'
