Skip to content

Commit

Permalink
Merge pull request #509 from chinapandaman/PPF-508
Browse files Browse the repository at this point in the history
PPF-508: add bump version script
  • Loading branch information
chinapandaman authored Feb 17, 2024
2 parents fe28357 + c3b0190 commit aec93b0
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 2 deletions.
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,8 @@ compare-pdf-diffs:
deploy:
bash ./scripts/create_release.sh

bump-version:
bash ./scripts/bump_version.sh

serve-docs:
bash ./scripts/serve_docs.sh
2 changes: 1 addition & 1 deletion PyPDFForm/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
"""Contains any object users might need."""

__version__ = "1.4.9"
__version__ = "1.4.10"

from .wrapper import PdfWrapper, PyPDFForm
2 changes: 1 addition & 1 deletion mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ theme:
name: readthedocs
logo: img/logo.png
extra:
version: v1.4.9
version: v1.4.10
27 changes: 27 additions & 0 deletions scripts/bump_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# -*- coding: utf-8 -*-
"""Bumps a minor version."""

import os
import re

if __name__ == "__main__":
with open("PyPDFForm/__init__.py", encoding="utf8") as f:
version = re.search(r'__version__ = "(.*?)"', f.read()).group(1)

new_version = ".".join(
version.split(".")[:-1] + [str(int(version.split(".")[-1]) + 1)]
)

with open("PyPDFForm/__init__.py", encoding="utf8") as f:
content = f.read().replace(version, new_version)

os.remove("PyPDFForm/__init__.py")
with open("PyPDFForm/__init__.py", mode="w", encoding="utf8") as f:
f.write(content)

with open("mkdocs.yml", encoding="utf8") as f:
content = f.read().replace(version, new_version)

os.remove("mkdocs.yml")
with open("mkdocs.yml", mode="w", encoding="utf8") as f:
f.write(content)
11 changes: 11 additions & 0 deletions scripts/bump_version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,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}

0 comments on commit aec93b0

Please sign in to comment.