name: Publish Package

on:
  push:
    tags:
      - "create-nova*" # # Push events to matching create-nova*, i.e. create-nova@1.0.0

jobs:
  publish:
    # prevents this action from running on forks
    if: github.repository == 'littlekie/create-nova'
    runs-on: ubuntu-latest
    environment: Release
    steps:
      - name: Checkout
        uses: actions/checkout@v3

      - name: Install pnpm
        uses: pnpm/action-setup@v2.2.4
        with:
          version: 7
          
      - name: Set node version to 16.x
        uses: actions/setup-node@v3
        with:
          node-version: 16.x
          registry-url: https://registry.npmjs.org/
          cache: "pnpm"

      - name: Install deps
        run: pnpm install
        env:
          PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: "1"

      - name: Publish package
        run: pnpm run publish-npm
        env:
          NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}