name: Publish Release On NPMJS
 
# Controls when the action will run.
# In this case, I'm saying on each release event when it's specifically a new release publish, the types: [published] is required here,
# since releases could also be updated or deleted, we only want to publish to npm when a new release is created (published).
on:
  release:
   types: [published]
 
jobs:
  build:
   runs-on: ubuntu-latest
   steps:
   # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
   - uses: actions/checkout@v3
   #Install Node.js, with the version 12 and using the registry URL of npm, this could be changed to a custom registry or the GitHub registry.
   - uses: actions/setup-node@v3
     with:
       node-version: 16
       registry-url: https://registry.npmjs.org/
 
   # Command to install the package dependencies
   - run: yarn install
   
   # Publish to npm
   - run: npm publish --access public
     env:
       NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
