# This is a basic workflow to help you get started with Actions

name: escpos-template
on: push

jobs:
  style-check:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v1
      - uses: actions/setup-node@v1
        with:
          node-version: '16.x'
      - run: yarn
      - run: yarn style:check

  lint:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v1
      - uses: actions/setup-node@v1
        with:
          node-version: '16.x'
      - run: yarn
      - run: yarn lint

  test:
    needs: [style-check, lint]
    runs-on: ubuntu-latest
    strategy:
      matrix:
        node: [ '14', '16', '18' ]
    steps:
      - uses: actions/checkout@v1
      - uses: actions/setup-node@v1
        with:
          node-version: ${{ matrix.node }}
      - run: yarn
      - run: yarn test

  publish:
    needs: test
    runs-on: ubuntu-latest
    if: startsWith(github.ref, 'refs/tags/v')
    steps:
      - uses: actions/checkout@v1
      - uses: actions/setup-node@v1
        with:
          node-version: '16.x'
      - run: yarn
      - run: yarn build
      - uses: JS-DevTools/npm-publish@v1
        with:
          token: ${{ secrets.NPM_TOKEN }}
