11import re
22import os
33
4+ # Constants to package __init__.py to update version of package
45file_location = "./kepconfig/__init__.py"
56version_re_string = "([0-9]+)\.([0-9]+)\.([0-9]+(?:[ab][0-9])?)"
67version_search = re .compile (r'__version__ = "' + version_re_string + '"' )
78version_check = re .compile (version_re_string )
89
10+ # Updates the version of package via __init__.py file
911def bump_version ():
1012 with open (file_location ) as f :
1113 s = f .read ()
1214 m = version_search .search (s )
1315 v1 , v2 , v3 = m .groups ()
1416 oldv = "{0}.{1}.{2}" .format (v1 , v2 , v3 )
17+
18+ # Need to provide version explicitly before building and releasing
1519 ans = input ("Current version of kepconfig is: {} \n Update new version to? (ctrl-c to exit): " .format (oldv ))
1620 if ans :
1721 m = version_check .search (ans )
@@ -30,28 +34,40 @@ def bump_version():
3034
3135
3236def release ():
37+ # Update/confirm version of package
3338 v = bump_version ()
39+
40+ # Commit changes to git
3441 ans = input ("Version updated, commit changes?(y/n)" )
3542 if ans .lower () in ("y" , "yes" ):
3643 os .system ("git add " + file_location )
3744 os .system ('git commit -m \" {} Release\" ' .format (v ))
3845 os .system ("git tag {0}" .format (v ))
39- ans = input ("Change committed, push to server? (Y/n)" )
46+
47+ # This will push the committed changes and tag to Github for release
48+ ans = input ("Change committed, push to Github server? (Y/n)" )
4049 if ans .lower () in ("y" , "yes" ):
4150 os .system ("git push --tags" )
4251 # os.system("git push --follow-tags")
52+
53+ # Build Distribution packages for external distribution
4354 ans = input ("Build dist packages?(Y/n)" )
4455 if ans .lower () in ("y" , "yes" ):
4556 # os.system("rm -rf dist/*") #Linux
4657 os .system ("RMDIR /S /Q dist" ) #Windows
4758 os .system ("python -m build" )
48- ans = input ("Upload to pip?(Y/n)" )
59+
60+ # Upload to pypi. Initially test with pypi test environment at test.pypi.org. Final release to pypi production
61+ # You'll be asked for credentials to authentice updating
62+ ans = input ("Upload to pypi?(Y/n)" )
4963 if ans .lower () in ("y" , "yes" ):
5064 ans = input ("Push to production?(Y=production pypi/n=test pypi)" )
5165 if ans .lower () in ("y" , "yes" ):
66+
5267 #Production PyPi Server
5368 os .system ("python -m twine upload dist/*" )
5469 else :
70+
5571 # Test PyPi Server
5672 os .system ("python -m twine upload --repository testpypi dist/*" )
5773
0 commit comments