version: 2
jobs:
  release-snapshot:
    docker:
      - image: circleci/node:lts
    steps:
      - checkout
      - run: yarn install --frozen-lockfile --non-interactive
      - run:
          name: Deploy
          command: |
            export NPM_TOKEN=${SNAPSHOT_NPM_TOKEN}
            npm config set ${NPM_PACKAGE_SCOPE}:registry ${NPM_SNAPSHOT_REPO}
            npx semantic-release
  release:
    docker:
      - image: circleci/node:lts
    steps:
      - checkout
      - run: yarn install --frozen-lockfile --non-interactive
      - run: echo "Running release job"
      - run:
          name: Deploy
          command: npx semantic-release

workflows:
  version: 2
  release:
    jobs:
      - release-snapshot:
          context: Dreamworld
          filters:
            branches:
              only:
                - /^feature\/.+$/
      - release:
          context: Dreamworld
          filters:
            branches:
              only:
                - master