---
find-next-release:
   stage: .pre
   image: node
   script:
      - npm install -g semantic-release @semantic-release/gitlab @semantic-release/git @semantic-release/changelog @semantic-release/exec
      - NEXT_RELEASE_VERSION=$(semantic-release --dry-run --no-ci | grep -oP 'The next release version is \K[0-9]+\.[0-9]+\.[0-9]+') || true
      - |
         if [ -z ${NEXT_RELEASE_VERSION+x} ]; then
            echo "Next release: ${NEXT_RELEASE_VERSION}"
            echo NEXT_RELEASE_VERSION="${NEXT_RELEASE_VERSION}" > $CI_PROJECT_DIR/variables.env
         else
            echo "[!] Release will not be bumped"
         fi
   artifacts:
      reports:
         dotenv: variables.env
   only:
      variables:
         - $GL_TOKEN
