stages:
  - test
  - publish

####
# Template: GitLab runner tags
####
.dev-tags:
  tags:
    - development

####
# Template: Run Node
####
.node:
  image: node:12
  extends: .dev-tags
  only:
    - branches
    - merge_requests
    - master@ghsc/nshmp/disagg-d3
  before_script:
    - npm ci

####
# Stage: test
####

Build Angular:
  stage: test
  extends: .node
  script:
    - cd example
    - npm i
    - npm run build

Lint:
  stage: test
  extends: .node
  script:
    - npm run tslint

####
# Stage: publish
####

Publish npm:
  stage: publish
  image: node:12
  extends: .dev-tags
  only:
    - tags@ghsc/nshmp/disagg-d3
  before_script:
    - npm ci
    - npm run npm-cli-login -- -u ${NPM_USER} -p ${NPM_PASSWORD} -e ${NPM_EMAIL}
    - git config user.email "${GITLAB_USER_EMAIL}"
    - git config user.name "${GITLAB_USER_NAME}"
  script:
    - npx standard-version --release-as ${CI_COMMIT_TAG} --skip.commit --skip.changelog
    - npm publish --access public
