forked from Asana/python-asana
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeploy.py
executable file
·54 lines (45 loc) · 1.76 KB
/
deploy.py
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/usr/bin/env python
"""
Script for deploying a new version of the python-asana library.
"""
from __future__ import print_function
import argparse
import subprocess
if __name__ == '__main__':
# Setup parser for command line arguments
parser = argparse.ArgumentParser()
parser.add_argument(
'part',
choices=['major', 'minor', 'patch'],
help='The part of the version to be bumped'
)
args = parser.parse_args()
# Get the current version from asana/version.py
current_version = {}
with open('asana/version.py') as fp:
exec(fp.read(), current_version)
major, minor, patch = current_version['__version__'].split('.')
# Bump version part based on argument provided
if args.part == 'major':
major = str(int(major) + 1)
minor = 0
patch = 0
if args.part == 'minor':
minor = str(int(minor) + 1)
patch = 0
if args.part == 'patch':
patch = str(int(patch) + 1)
# Overwrite the version in VERSION and asana/version.py
updated_version = "{}.{}.{}".format(major, minor, patch)
with open('VERSION', 'w') as version_file:
version_file.write("{}".format(updated_version))
with open('asana/version.py', 'w') as version_file:
version_file.write("__version__ = '{}'\n".format(updated_version))
# Add, commit and push version changes to GitHub and tag release
subprocess.call('git add VERSION asana/version.py', shell=True)
subprocess.call(
'git commit -m "Releasing version {}"'.format(updated_version), shell=True
)
subprocess.call('git tag v{}'.format(updated_version), shell=True)
subprocess.call('git push --tags origin master:master', shell=True)
print('Successfully deployed version {}'.format(updated_version))