version: 2.1
orbs:
  rn: react-native-community/react-native@3.0.0

jobs:
  checkout_code:
    executor: rn/linux_js
    steps:
      - checkout
      - persist_to_workspace:
          root: .
          paths: .

  analyse_js:
    executor: rn/linux_js
    steps:
      - attach_workspace:
          at: .
      - rn/yarn_install
      - run:
          name: Run ESLint
          command: yarn lint

  type_check:
    executor: rn/linux_js
    steps:
      - attach_workspace:
          at: .
      - rn/yarn_install
      - run:
          name: Check for Typings
          command: yarn type-check


  release:
    executor: rn/linux_js
    steps:
      - attach_workspace:
          at: .
      - rn/yarn_install
      - run:
            name: Publish to NPM
            command: yarn semantic-release || true

workflows:
  ci:
    jobs:
    - checkout_code
    - analyse_js:
        requires:
        - checkout_code
    - type_check:
        requires:
        - checkout_code
    - release:
        requires:
        - analyse_js
        - type_check
        filters:
            branches:
              only: master
