Completed
Push — master ( 511cc1...efb5e4 )
by Olivier
02:31 queued 24s
created

release()   A

Complexity

Conditions 1

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %
Metric Value
cc 1
dl 0
loc 7
rs 9.4286
1
import re
2
import os
3
4
5
def bump_version():
6
    with open("setup.py") as f:
7
        s = f.read()
8
    m = re.search(r'version="(.*)\.(.*)\.(.*)",', s)
9
    v1, v2, v3 = m.groups()
10
    oldv = "{}.{}.{}".format(v1, v2, v3)
11
    newv = "{}.{}.{}".format(v1, v2, str(int(v3) + 1))
12
    print("Current version is: {}, write new version, ctrl-c to exit".format(oldv))
13
    print(newv, end="")
14
    ans = input()
15
    if ans:
16
        newv = ans 
17
    s = s.replace(oldv, newv)
18
    with open("setup.py", "w") as f:
19
        f.write(s)
20
    return newv
21
22
23
def release():
24
    v = bump_version()
25
    os.system("git add setup.py")
26
    os.system("git commit -m 'new release'")
27
    os.system("git tag {}".format(v))
28
    os.system("git push --tags")
29
    os.system("python setup.py sdist upload")
30
31
32
if __name__ == "__main__":
33
    release()
34