version: 2
jobs:
  build:
    docker:
      - image: circleci/node:latest
    steps:
      - checkout
      - restore_cache:
          keys:
            - gatsby-source-moltin-{{ checksum "package.json" }}
            # fallback to using the latest cache if no exact match is found
            - gatsby-source-moltin-
      - run: yarn
      - save_cache:
          paths:
            - node_modules
          key: gatsby-source-moltin-{{ checksum "package.json" }}
  release:
    docker:
      - image: circleci/node:latest
    steps:
      - checkout
      - restore_cache:
          keys:
            - gatsby-source-moltin-{{ checksum "package.json" }}
      - run: npx semantic-release
workflows:
  version: 2
  build_release:
    jobs:
      - build
      - release:
          filters:
            branches:
              only: master
          requires:
            - build
