name: CI
on:
  push:
    branches:
      - main
  pull_request:

concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}

jobs:
  build-lint-test:
    name: Build, lint, test, release
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: pnpm/action-setup@v2
      - uses: actions/setup-node@v4
        with:
          node-version-file: .nvmrc
          cache: pnpm
      - run: pnpm install
      - run: pnpm run build
      - run: pnpm run lint
      - run: pnpm run --if-present test
      # - if: ${{ github.ref == 'refs/heads/main' }}
      #   uses: changesets/action@v1
      #   with:
      #     publish: pnpm exec changeset publish
      #     commit: "chore: release"
      #     title: "chore: release"
      #   env:
      #     GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      #     NPM_TOKEN: ${{ secrets.NPM_TOKEN }}