diff --git a/templates/gitlab-ci-python.yml b/templates/gitlab-ci-python.yml index f8967140c273b8d2696ec414fc9fe4074f861f5b..4661bb75ddc67e8adb165f910b216d885a4b2454 100644 --- a/templates/gitlab-ci-python.yml +++ b/templates/gitlab-ci-python.yml @@ -873,12 +873,19 @@ variables: # create cfg in case it doesn't exist - will be updated by bumpversion if [[ ! "$py_cur_version" && ! -f ".bumpversion.cfg" && ! -f ".bumpversion.toml" && ! -f "pyproject.toml" && ! -f "setup.cfg" ]] then - log_error "Current version not defined and not version file found, set initial version at least in .bumpversion.toml or pyproject.toml" + log_warn "Current version not defined and no version file found: please set initial version in .bumpversion.toml, .bumpversion.cfg, setup.cfg or pyproject.toml ([tool.bumpversion] section)" fi bump-my-version bump ${TRACE+--verbose} --current-version "${py_cur_version:-${PYTHON_RELEASE_START_VERSION:-0.0.0}}" --new-version "$py_next_version" --commit ${PYTHON_RELEASE_COMMIT_MESSAGE:+--message "$PYTHON_RELEASE_COMMIT_MESSAGE"} --tag --tag-name "{new_version}" "$py_release_part" - elif [[ -f ".bumpversion.cfg" ]] + elif [[ -f ".bumpversion.cfg" || -f ".bumpversion.toml" || -f "pyproject.toml" || -f "setup.cfg" ]] then - # current version shall be set in .bumpversion.cfg + if [[ ! -f ".bumpversion.cfg" && ! -f ".bumpversion.toml" && ! -f "setup.cfg" ]] # pyproject.toml case + then + if ! grep -q '^[[:space:]]*\[tool\.bumpversion\]' "pyproject.toml" + then + log_warn "Current version not defined and no version file found: please set initial version in pyproject.toml ([tool.bumpversion] section)" + fi + fi + # current version shall be set in bump-my-version config file py_release_part="$PYTHON_RELEASE_NEXT" log_info "[bump-my-version bump] increase \\e[1;94m${py_release_part}\\e[0m" bump-my-version bump ${TRACE+--verbose} --commit ${PYTHON_RELEASE_COMMIT_MESSAGE:+--message "$PYTHON_RELEASE_COMMIT_MESSAGE"} --tag --tag-name "{new_version}" "$py_release_part" @@ -890,7 +897,7 @@ variables: log_info "[bump-my-version] increase \\e[1;94m${py_release_part}\\e[0m (from current \\e[1;94m${py_cur_version}\\e[0m)" bump-my-version bump ${TRACE+--verbose} --current-version "$py_cur_version" --commit ${PYTHON_RELEASE_COMMIT_MESSAGE:+--message "$PYTHON_RELEASE_COMMIT_MESSAGE"} --tag --tag-name "{new_version}" "$py_release_part" setup.py else - log_error "--- setup.py or .bumpversion.cfg file required to retrieve current version: cannot perform release" + log_error "--- setup.py, .bumpversion.toml, pyproject.toml, .bumpversion.cfg(deprecated) or setup.cfg(deprecated) file required to retrieve current version: cannot perform release" exit 1 fi fi