diff --git a/scripts/bump_version.py b/scripts/bump_version.py index bfcd345c..89fb9ae3 100644 --- a/scripts/bump_version.py +++ b/scripts/bump_version.py @@ -3,8 +3,14 @@ import os import re +import sys if __name__ == "__main__": + branch = sys.argv[1] + if not branch.startswith("PPF-"): + print("Bump version cannot be done on a non-issue branch.") + sys.exit(1) + with open("PyPDFForm/__init__.py", encoding="utf8") as f: version = re.search(r'__version__ = "(.*?)"', f.read()).group(1) diff --git a/scripts/bump_version.sh b/scripts/bump_version.sh index 94305050..e99934c3 100644 --- a/scripts/bump_version.sh +++ b/scripts/bump_version.sh @@ -2,10 +2,11 @@ if [[ "$VIRTUAL_ENV" == "" ]]; then source "./venv/bin/activate" fi -python ./scripts/bump_version.py - -git add ./PyPDFForm/__init__.py mkdocs.yml BRANCH=$(git symbolic-ref HEAD 2>/dev/null) BRANCH=${BRANCH##refs/heads/} -git commit -m "${BRANCH}: bump version" -git push --set-upstream origin ${BRANCH} + +if python ./scripts/bump_version.py ${BRANCH} ; then + git add ./PyPDFForm/__init__.py mkdocs.yml + git commit -m "${BRANCH}: bump version" + git push --set-upstream origin ${BRANCH} +fi