# 在创建 release 后自动发布 npm 包


name: Node.js Package

on:
  release:
    types: [created]

jobs:
  build:
    name: 编译文件
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-node@v1
        with:
          node-version: 12
      - run: npm i
      - run: npm run lint
      - run: npm run build
      - run: npm run dev

  publish-npm:
    name: 发布到 npm
    needs: build
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-node@v1
        with:
          node-version: 12
          registry-url: https://registry.npmjs.org/
      - run: npm publish
        env:
          NODE_AUTH_TOKEN: ${{secrets.npm_token}}
