version: 2.1

jobs:
  publish:
    docker:
      - image: cimg/node:18.19
        auth:
            username: $DOCKERHUB_USER
            password: $DOCKERHUB_PASS
    steps:
        - checkout
        - run:
            name: Publish to NPM
            command: |
              git config --global user.email "code@kanopi.com"
              git config --global user.name "Kanopi Code"
              npm set //registry.npmjs.org/:_authToken=$NPM_TOKEN
              npm version $CIRCLE_TAG
              npm publish --access public

workflows:
  tagged-build:
    jobs:
        - publish:
            context:
              - kanopi-code
            filters:
              branches:
                ignore: /.*/
              tags:
                only: /[0-9]+(\.[0-9]+)*/
