image: viewdo/devops-cli

options:
  docker: true

clone:
  depth: full

caches: &caches
  caches:
    - node
    - docker

npm-build: &npm-build
  step:
    name: NPM Build
    <<: *caches
    script:
    - &get-vars pipe get-vars && source ~/.bashrc
    - npm install
    #- npm test

pipelines:
  default:
  - <<: *npm-build

  branches:
    master:
    - <<: *npm-build
    - step:
        name: NPM Build, Tag & Publish
        <<: *caches
        script:
        - *get-vars
        - npm version "$VERSION" -f --no-git-tag-version
        - pipe: atlassian/npm-publish:0.2.0
          variables:
            NPM_TOKEN: $NPM_TOKEN
    - step:
        name: Publish to Docker
        script:
        - *get-vars
        - pipe docker-publish
        - pipe git-tag
        - pipe jira-release CLI
        - pipe slack 'DXP Story CLI version $VERSION was released.'
