name: Publish Package

on:
  push:
    tags:
      - v*

jobs:
  publish-npm:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v3
        with:
          fetch-depth: 0

      - name: Install pnpm
        uses: pnpm/action-setup@v2

      - name: Use Node.js ${{ matrix.node-version }}
        uses: actions/setup-node@v3
        with:
          node-version: ${{ matrix.node-version }}
          registry-url: https://registry.npmjs.org/
          cache: pnpm

      - run: pnpm install

      - run: npx changelogithub --no-group
        continue-on-error: true
        env:
          GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}

      - run: pnpm run publish:ci
        env:
          NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
          NODE_OPTIONS: --max-old-space-size=6144
