@@ -13,12 +13,14 @@ DEFAULT_BRANCH=${DEFAULT_BRANCH?error}
1313# TODO: Make sure to also update cliff.toml:footer to includes those archived changelogs as well
1414START_COMMIT=${START_COMMIT:- $(git rev-list --max-parents=0 HEAD)}
1515RELEASE_CUSTOM_HOOK=" ${RELEASE_CUSTOM_HOOK?error} "
16+ VERSION_TAG_PREFIX_MODE=" ${VERSION_TAG_PREFIX_MODE:- require} "
1617
1718check_typos
1819check_git_cliff
1920check_semver
2021check_gh
2122
23+ log_warning " Using VERSION_TAG_PREFIX_MODE=${VERSION_TAG_PREFIX_MODE} "
2224echo " Generating GITHUB_TOKEN using gh (Used by git-cliff)"
2325GITHUB_TOKEN=" $( gh auth token) "
2426export GITHUB_TOKEN
@@ -43,7 +45,25 @@ echo "Existing tags:"
4345git for-each-ref --sort=-creatordate --format ' - %(refname:short)' refs/tags | head -n 10
4446echo
4547
46- read -rp " Enter new version tag (e.g. v1.2.3, v1.2.3-dev0): " version_tag
48+ default_version=" $1 "
49+ # Decide prompt message based on VERSION_TAG_PREFIX_MODE
50+ case " $VERSION_TAG_PREFIX_MODE " in
51+ require)
52+ prompt_msg=" Enter new version tag (must start with 'v', e.g. v1.2.3): "
53+ ;;
54+ forbid)
55+ prompt_msg=" Enter new version tag (must NOT start with 'v', e.g. 1.2.3): "
56+ ;;
57+ ignore)
58+ prompt_msg=" Enter new version tag (e.g. v1.2.3, v1.2.3-dev0): "
59+ ;;
60+ * )
61+ log_error " Invalid VERSION_TAG_PREFIX_MODE: ${VERSION_TAG_PREFIX_MODE} . Should be require|forbid|ignore"
62+ exit 1
63+ ;;
64+ esac
65+
66+ read -e -i " $default_version " -rp " $prompt_msg " version_tag
4767
4868# Trim leading/trailing whitespace
4969version_tag=$( echo " $version_tag " | xargs)
6080 exit 1
6181fi
6282
83+ case " ${VERSION_TAG_PREFIX_MODE} " in
84+ require)
85+ if [[ " ${version_tag} " != v* ]]; then
86+ log_error " Error: version_tag must start with 'v' (got: ${version_tag} )"
87+ exit 1
88+ fi
89+ ;;
90+ forbid)
91+ if [[ " ${version_tag} " == v* ]]; then
92+ log_error " Error: version_tag must NOT start with 'v' (got: ${version_tag} )"
93+ exit 1
94+ fi
95+ ;;
96+ ignore | " " )
97+ # do nothing
98+ ;;
99+ # NOTE: Invalid option is already checked during version prompt
100+ esac
101+
63102# Define your cleanup or final function
64103exit_message () {
65104 log_warning " -----------------"
0 commit comments