version: 2

jobs:
  publish:
    docker:
      - image: circleci/node
    working_directory: ~/repo

    steps:
      - checkout
      - run:
          name: Authenticate with registry
          command: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ~/repo/.npmrc
      - run:
          name: Publish package
          command: if [[ `npm show tinymce-i18n version` != `date +%y.%-m.%-d` ]]; then npm publish; else echo Already published; fi

workflows:
  version: 2
  approval-deploy:
    jobs:
      - deploy:
          type: approval
      - publish:
          requires:
            - deploy
