Skip to content

Commit

Permalink
Merge pull request #512 from chinapandaman/PPF-511
Browse files Browse the repository at this point in the history
PPF-511: protect master branch from bump version directly
  • Loading branch information
chinapandaman authored Feb 17, 2024
2 parents e8ab397 + dcd08a1 commit d89ca3b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
6 changes: 6 additions & 0 deletions scripts/bump_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
11 changes: 6 additions & 5 deletions scripts/bump_version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit d89ca3b

Please sign in to comment.