version: 2
jobs:
  build:
    docker:
      - image: 'circleci/node:lts'
    steps:
      - checkout
      - run: yarn clean-install
      - save_cache:
          paths:
            - node_modules
          key: import-moltin-to-algolia-{{ checksum "package.json" }}
  test:
    docker:
      - image: 'circleci/node:lts'
    steps:
      - checkout
      - restore_cache:
          keys:
            - import-moltin-to-algolia-{{ checksum "package.json" }}
      - run: yarn clean-install
      - run: yarn test
  release:
    docker:
      - image: 'circleci/node:lts'
    steps:
      - checkout
      - restore_cache:
          keys:
            - import-moltin-to-algolia-{{ checksum "package.json" }}
      - run: yarn clean-install
      - run: npx semantic-release
workflows:
  version: 2
  build_test_release:
    jobs:
      - build
      - test:
          requires:
            - build
      - release:
          filters:
            branches:
              only:
                - master
          requires:
            - test
