1
1
import re
2
2
import os
3
3
4
+ # Constants to package __init__.py to update version of package
4
5
file_location = "./kepconfig/__init__.py"
5
6
version_re_string = "([0-9]+)\.([0-9]+)\.([0-9]+(?:[ab][0-9])?)"
6
7
version_search = re .compile (r'__version__ = "' + version_re_string + '"' )
7
8
version_check = re .compile (version_re_string )
8
9
10
+ # Updates the version of package via __init__.py file
9
11
def bump_version ():
10
12
with open (file_location ) as f :
11
13
s = f .read ()
12
14
m = version_search .search (s )
13
15
v1 , v2 , v3 = m .groups ()
14
16
oldv = "{0}.{1}.{2}" .format (v1 , v2 , v3 )
17
+
18
+ # Need to provide version explicitly before building and releasing
15
19
ans = input ("Current version of kepconfig is: {} \n Update new version to? (ctrl-c to exit): " .format (oldv ))
16
20
if ans :
17
21
m = version_check .search (ans )
@@ -30,28 +34,40 @@ def bump_version():
30
34
31
35
32
36
def release ():
37
+ # Update/confirm version of package
33
38
v = bump_version ()
39
+
40
+ # Commit changes to git
34
41
ans = input ("Version updated, commit changes?(y/n)" )
35
42
if ans .lower () in ("y" , "yes" ):
36
43
os .system ("git add " + file_location )
37
44
os .system ('git commit -m \" {} Release\" ' .format (v ))
38
45
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)" )
40
49
if ans .lower () in ("y" , "yes" ):
41
50
os .system ("git push --tags" )
42
51
# os.system("git push --follow-tags")
52
+
53
+ # Build Distribution packages for external distribution
43
54
ans = input ("Build dist packages?(Y/n)" )
44
55
if ans .lower () in ("y" , "yes" ):
45
56
# os.system("rm -rf dist/*") #Linux
46
57
os .system ("RMDIR /S /Q dist" ) #Windows
47
58
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)" )
49
63
if ans .lower () in ("y" , "yes" ):
50
64
ans = input ("Push to production?(Y=production pypi/n=test pypi)" )
51
65
if ans .lower () in ("y" , "yes" ):
66
+
52
67
#Production PyPi Server
53
68
os .system ("python -m twine upload dist/*" )
54
69
else :
70
+
55
71
# Test PyPi Server
56
72
os .system ("python -m twine upload --repository testpypi dist/*" )
57
73
0 commit comments