# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
# For more information see: https://help.github.com/actions/language-and-framework-guides/publishing-nodejs-packages

name: Node.js Package

on:
  push:
    branches:
      - master

jobs:
  auto_release_npm_package:
    if: "!contains(github.event.head_commit.message, 'skip ci')"
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-node@v1
        with:
          node-version: 12
      - run: |
          git config --local user.email "action@github.com"
          git config --local user.name "GitHub Action"
          git checkout $CI_COMMIT_REF_NAME
          npm config set //registry.npmjs.org/:_authToken=$NODE_AUTH_TOKEN
          npm config set scope "@pawgame"
          npm config list
          SPACE_CHAR=" "
          npx standard-version --releaseCommitMessageFormat "chore(release):${SPACE_CHAR}{{currentTag}} [skip ci]"
          git push --follow-tags origin $CI_COMMIT_REF_NAME
          npm publish --access public
        env:
            NODE_AUTH_TOKEN: ${{secrets.NPM_NODE_AUTH_TOKEN}}
