Completed
Pull Request — master (#161)
by Denis
03:18
created

release.py (2 issues)

1
import re
2
import os
3
4
5
def bump_version():
6
    with open("setup.py") as f:
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable f does not seem to be defined.
Loading history...
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
    ans = input(newv)
14
    if ans:
15
        newv = ans
16
    s = s.replace(oldv, newv)
17
    with open("setup.py", "w") as f:
18
        f.write(s)
19
    return newv
20
21
22
def release():
23
    v = bump_version()
24
    ans = input("version bumped, commiting?(Y/n)")
25
    if ans in ("", "y", "yes"):
26
        os.system("git add setup.py")
27
        os.system("git commit -m 'new release'")
28
        os.system("git tag {}".format(v))
29
        ans = input("change committed, push to server?(Y/n)")
30
        if ans in ("", "y", "yes"):
31
            os.system("git push")
32
            os.system("git push --tags")
33
        ans = input("upload to pip?(Y/n)")
34
        if ans in ("", "y", "yes"):
35
            os.system("python setup.py sdist upload")
36
37
38
if __name__ == "__main__":
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable __name__ does not seem to be defined.
Loading history...
39
    release()
40