name: Node.js Package
on: [push, pull_request]

jobs:
  build:
    runs-on: ubuntu-latest
    if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
    steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-node@v3
        with:
          node-version: 16
          registry-url: https://registry.npmjs.org/
      - name: test
        run: |
          npm i node-gyp -g
          node-gyp configure
          node-gyp build
          node test.js
      - run: npm publish
        env:
          NODE_AUTH_TOKEN: ${{secrets.npm_token}}
