version: 2
jobs:
  test:
    working_directory: /srv
    docker:
      - image: node:16
    steps:
      - checkout
      - run: npm install
#      - run:
#          name: "Jest"
#          command: node_modules/.bin/jest --ci --testResultsProcessor="jest-junit"
#          environment:
#            JEST_JUNIT_OUTPUT: "/tmp/junit/jest.xml"
#      - store_test_results:
#          path: /tmp/junit
#      - run: npm run build
#      - persist_to_workspace:
#          root: /srv
#          paths:
#            - dist

  publish:
    working_directory: /srv
    docker:
      - image: node:8
    steps:
      - checkout
      - run: echo "//registry.npmjs.org/:_authToken=$NPM_PUBLISH_TOKEN" >> ~/.npmrc
      - run: npm version --no-git-tag-version $CIRCLE_TAG
      - run: npm publish

workflows:
  version: 2
  test:
    jobs:
      - test
  publish:
    jobs:
      - publish:
          filters:
            tags:
              only: /.*/
            branches:
              ignore: /.*/
          context: org-global
