version: 2
jobs:
  build:
    docker:
      - image: circleci/node:4.8.2
    steps:
      - checkout
      - run:
          name: install
          command: npm install
      - run:
          name: test
          command: npm test

---
version: 2

buildSteps: &buildSteps
  - checkout
  - run:
      name: install-npm
      command: npm install
  - run:
      name: test
      command: npm test
  - persist_to_workspace:
      # Persist all job output, so we can (potentially) use it for deploys
      root: ../
      paths:
        - ./node-*

jobs:
  "node-6":
    docker:
      - image: circleci/node:6
    working_directory: ~/node-6
    steps: *buildSteps

  "node-8":
    docker:
      - image: circleci/node:8
    working_directory: ~/node-8
    steps: *buildSteps

  deploy:
    # For this to work NPM_TOKEN must be set for the account used for publishing
    docker:
      - image: circleci/node:8
    steps:
      - attach_workspace:
          at: .
      - run:
          name: install-npm-4
          command: sudo npm install -g npm@4
      - run:
          name: Login to npm
          command: |
            echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
            npm whoami
      - deploy:
          name: Deploy to npm
          # Output used for publish is from node 8 build
          command: cd node-8 && npm publish

workflows:
  version: 2
  build:
    jobs:
      - "node-6":
          # Run for all tags (required to allow the deploy to trigger on version tags)
          filters:
            tags:
              only: /.*/
      - "node-8":
          # Run for all tags (required to allow the deploy to trigger on version tags)
          filters:
            tags:
              only: /.*/
      - deploy:
          # Deploy passing builds if they're tagged with a version
          requires:
            - "node-6"
            - "node-8"
          filters:
            tags:
              only: /^v\d+\.\d+\.\d+$/
            branches:
              ignore: /.*/

Add circleci auto-deploy to npm
Add circleci auto-deploy to npm

Change-type: minor
Signed-off-by: Cameron Diver <1d572acbfa68c7c6e541c7b840d6b622e5c0dc91@resin.io>
