version: 2.0
jobs:
  build:
    docker:
      - image: circleci/node
    steps:
      - checkout
      - restore_cache:
          keys:
            - v1-npm-deps-{{ checksum "package-lock.json" }}
            # Find the most recently generated cache used from any branch
            - v1-npm-deps-
      - run:
          name: Install npm
          command: npm install
      - run:
          name: Build
          command: npm run build
      - run:
          name: Auth With NPM
          command: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > .npmrc
      - run:
          name: Publish to NPM
          command: npm publish
