File: release.py

package info (click to toggle)
flask-restful 0.3.10-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,312 kB
  • sloc: python: 3,945; makefile: 277; pascal: 26; sh: 20
file content (31 lines) | stat: -rw-r--r-- 880 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import argparse
import subprocess


def point_release(version):
    parts = version.split('.')
    parts[-1] = str(int(parts[-1]) + 1)
    return '.'.join(parts)


def main():
    parser = argparse.ArgumentParser(description='Bump version number')
    parser.add_argument('version')
    args = parser.parse_args()

    branch = subprocess.check_output(['git', 'branch']).strip()

    if not "* master" in branch:
        raise Exception("Must be on master branch to release")

    if len(subprocess.check_output(["git", "status", "-s"]).strip()) > 0:
        raise Exception("Uncommitted changes, please commit or stash")

    subprocess.call(["git", "tag", args.version])
    subprocess.call(["git", "push", "origin", "master"])
    subprocess.call(["git", "push", "--tags"])
    subprocess.call(["python", "setup.py", "sdist", "upload"])


if __name__ == "__main__":
    main()