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 --frozen-lockfile --ignore-engines --ignore-scripts
      - name: lint code
        run: yarn run lint
        env:
          CI: true
      - name: run tests
        run: yarn run test
        env:
          CI: true
      - name: coverage
        uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f # v7.0.0
        with:
          fail_ci_if_error: true
          verbose: false
        env:
          CODECOV_TOKEN: ${{secrets.CODECOV_TOKEN}}
          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
    if: github.event_name == 'push' && github.ref == 'refs/heads/master'
    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 --frozen-lockfile --ignore-engines --ignore-scripts
      - name: release
        run: yarn run semantic-release
        env:
          GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
          NPM_TOKEN: ${{secrets.NPM_TOKEN}}
