From dcd08a10b738bb5606088d05f277bf175b661fee Mon Sep 17 00:00:00 2001 From: chinapandaman Date: Fri, 16 Feb 2024 22:06:26 -0600 Subject: [PATCH] PPF-511: only allowed on PPF branches --- scripts/bump_version.py | 6 ++++++ scripts/bump_version.sh | 11 ++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) 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