name: Publish to NPM

# Controls when the workflow will run
on:
  # Triggers the workflow on push or pull request events but only for the stable branch
  push:
    branches: [ stable ]
  pull_request:
    branches: [ stable ]

  # Allows you to run this workflow manually from the Actions tab
  workflow_dispatch:

jobs:
  build:
    runs-on: ubuntu-latest

    strategy:
      matrix:
        node-version: [20.x]

    steps:
      - uses: actions/checkout@v4

      - name: Tag from package version
        uses: suceda/tag-from-version@v0.1.0

      - name: Setup Node.js ${{ matrix.node-version }}
        uses: actions/setup-node@v4
        with:
          node-version: ${{ matrix.node-version }}
          cache: yarn

      - name: Install dependencies
        run: yarn install --frozen-lockfile

      - name: NPM Publish
        uses: mmarchini-oss/npm-otp-publish@v0 #JS-DevTools/npm-publish@v1
        with:
          npm_token: ${{secrets.NPM_TOKEN}}
          github_token: ${{secrets.GITHUB_TOKEN}}
