---
# https://github.com/semantic-release/semantic-release#commit-message-format
# https://levelup.gitconnected.com/semantic-versioning-and-release-automation-on-gitlab-9ba16af0c21

variables:
  BADGE_semantic_release: "version-${CI_COMMIT_TAG}-informational"
  BADGE_semantic_release_URL: "${CI_PROJECT_URL}/tags/${CI_COMMIT_TAG}"

semantic-release:
  image: registry.gitlab.com/notno/ci/images/node:latest
  stage: .post
  variables:
    EXTRA_ARGS: ""
    SEMANTIC_RELEASE_CONFIG: "./releaserc"
  script:
    - |
      if [[ ! -f ${SEMANTIC_RELEASE_CONFIG} ]]
      then
        echo "No $SEMANTIC_RELEASE_CONFIG file found in the root of your project."
        echo "See https://gitlab.com/notno/ci-templates/-/blob/master/.releaserc for an example."
        echo "See https://semantic-release.gitbook.io/semantic-release/usage/configuration on how to configure semantic-release."
        echo "Will use default configuration @semantic-release/gitlab-config"
      fi
    - npm install -g semantic-release @semantic-release/gitlab @semantic-release/gitlab-config @semantic-release/git @semantic-release/changelog @semantic-release/exec
    - semantic-release ${EXTRA_ARGS}
  only:
    variables:
      - $GL_TOKEN
