---
# https://pypi.org/project/tbump/
variables:
  TBUMP_DEFAULT_ARGS: --only-patch --non-interactive

tbump:
  image:
    name: registry.gitlab.com/just-ci/images/python:slim
    entrypoint: [""]
  stage: build
  script:
    - |
      if [ ! "${TBUMP_NEXT_VERSION}" = "" ]; then
        pip3 install tbump
        tbump --version
        tbump ${TBUMP_NEXT_VERSION} ${TBUMP_DEFAULT_ARGS}
        echo "BUMPED_FILES=$(git diff --name-only | tr '\n' ' ')" | tee ${CI_PROJECT_DIR}/bumped_files.env
      else
        echo "[-] No new version released."
      fi
  artifacts:
    paths:
      - ./*
    exclude:
      - bumped_files.env
      - .git/**/*
      - .git
    reports:
      dotenv: bumped_files.env
