# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions

name: NPM Publish

on:
  push:
    branches: [ main, v*.* ]
    paths:
      - src/**
      - package.json

jobs:
  build:

    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v2
    - name: Use Node.js 16.7
      uses: actions/setup-node@v1
      with:
        always-auth: true
        node-version: '16.7'
        registry-url: https://npm.pkg.github.com/
        scope: '@juzibot'

    - name: Install
      run: npm install
      env:
        NODE_AUTH_TOKEN: ${{secrets.JUZI_NPM_TOKEN}}

    - name: Compile
      run: npm run tsc

    - name: Publish
      run: npm publish
      env:
        NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
