version: 2

defaults: &defaults
  working_directory: ~/repo
  docker:
    - image: node
jobs:
  deploy:
    <<: *defaults  
    steps:
      - checkout
      
      - restore_cache:
          name: Restore Yarn Package Cache
          keys:
            - yarn-packages-{{ checksum "yarn.lock" }}
      - run: yarn --pure-lockfile
      - run: yarn bootstrap
      - run:
          name: Run linter and tests 
          command: yarn lint && yarn test
      # - run:
      #     name: Authenticate with registry
      #     command: echo "//registry.npmjs.org/:_authToken=$npm_TOKEN" > ~/repo/.npmrc
      # - run:
      #     name: Publish packages
      #     command: yarn publish-ci
      - save_cache:
          name: Save Yarn Package Cache
          key: yarn-packages-{{ checksum "yarn.lock" }}
          paths:
            - ~/.cache/yarn
      - persist_to_workspace:
          root: ~/repo
          paths: .

workflows:
  version: 2
  build-and-deploy:
    jobs:
      - deploy:
          filters:
            tags:
              only: /^v.*/
            branches:
              ignore: /.*/


Establish automatic build, lint and test via circle-ci
chore: Establish automatic build, lint and test via circle-ci
