version: 2.1

defaults: &defaults
  working_directory: ~/repo

orbs:
  node: circleci/node@2.0.3

jobs:
  test:
    docker:
      - image: "cimg/base:stable"
    steps:
      - checkout
      - node/install:
          install-yarn: true
          node-version: latest
      - run: node --version
      - run: yarn test
  deploy:
    executor:
      name: node/default
    steps:
      - attach_workspace:
          at: ~/repo
      - run:
          name: Authenticate with registry
          command: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ~/repo/.npmrc
      - run:
          name: Publish Package
          command: npm publish

workflows:
  test-and-deploy:
    jobs:
      - test
      - deploy:
          requires:
            - test
          filters:
            tags:
              only: /^v.*/
            branches:
              ignore: /.*/

version: 2.1

defaults: &defaults
  working_directory: ~/repo

orbs:
  node: circleci/node@2.0.3

jobs:
  test:
    <<: *defaults
    executor:
      name: node/default
      tag: "13"
    steps:
      - checkout
      - node/install-packages:
          pkg-manager: yarn
          cache-key: yarn.lock
      - run: yarn test
  deploy:
    <<: *defaults
    executor:
      name: node/default
      tag: "13"
    steps:
      - attach_workspace:
          at: ~/repo
      - run:
          name: Authenticate with registry
          command: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ~/repo/.npmrc
      - run:
          name: Publish Package
          command: npm publish

workflows:
  test-and-deploy:
    jobs:
      - test
      - deploy:
          requires:
            - test
          filters:
            tags:
              only: /^v.*/
            branches:
              ignore: /.*/

Use node installed with orb
Use node installed with orb
