Skip to content

Commit b636162

Browse files
committed
revert tag when abort publishing
1 parent 87a62e3 commit b636162

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

utils/up_version.sh

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
set -euo pipefail
33
unalias -a
44

5-
current_script_dir="$( cd "$( dirname "${0}" )" &> /dev/null && pwd )"
6-
project_root_dir="$(dirname ${current_script_dir})"
7-
version_file=${project_root_dir}/src/icoco/VERSION
5+
readonly current_script_dir="$( cd "$( dirname "${0}" )" &> /dev/null && pwd )"
6+
readonly project_root_dir="$(dirname ${current_script_dir})"
7+
readonly version_file=${project_root_dir}/src/icoco/VERSION
88

99
########################
1010
# Cli
@@ -13,7 +13,7 @@ if (( $# != 1 )); then
1313
echo "ERROR: You must provide exactly 1 argument: version number as x.y.z"
1414
exit 1
1515
fi
16-
version_name=$1
16+
readonly version_name=$1
1717

1818
########################
1919
# Main
@@ -66,6 +66,10 @@ read -p "Do you want to push version '${version_name}' ? (yes/[no]) " answer
6666
if [[ "${answer}" == "y"* ]]; then
6767
git push origin
6868
git push origin ${version_name}
69+
else
70+
git reset --hard HEAD^
71+
git tag -d ${version_name}
72+
exit 0
6973
fi
7074

7175
# Publish on pypi
@@ -77,4 +81,7 @@ if [[ "${answer}" == "y"* ]]; then
7781
python3 -m pip install --upgrade build twine
7882
python3 -m build
7983
python3 -m twine upload --repository pypi dist/*
84+
else
85+
echo "You pushed a version tag but this version has not been published!"
86+
exit 1
8087
fi

0 commit comments

Comments
 (0)