8000 Automating python deployment · sangsiri/twilio-python@d43a867 · GitHub
[go: up one dir, main page]

Skip to content

Commit d43a867

Browse files
author
matt
committed
Automating python deployment
1 parent c155c17 commit d43a867

File tree

4 files changed

+79
-4
lines changed

4 files changed

+79
-4
lines changed

Makefile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
.PHONY: clean venv install analysis test test-install develop docs docs-install
1+
.PHONY: clean install analysis test test-install develop docs docs-install
22

33
venv:
44
virtualenv venv
55

66
install: venv
7-
. venv/bin/activate; pip install . --use-mirrors
7+
. venv/bin/activate; pip install .
88

99
test-install: install
1010
. venv/bin/activate; pip install -r tests/requirements.txt
@@ -46,3 +46,6 @@ build: test-install
4646

4747
clean:
4848
rm -rf venv
49+
50+
deploy:
51+
. venv/bin/activate; python deploy.py

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ documentation.][documentation]
1212
Install from PyPi using [pip](http://www.pip-installer.org/en/latest/), a
1313
package manager for Python.
1414

15-
pip install twilio==6.0rc4
15+
pip install twilio==6.0.0rc9
1616

1717
Don't have pip installed? Try installing it, by running this from the command
1818
line:

deploy.py

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
from __future__ import print_function
2+
3+
import os
4+
import re
5+
from argparse import ArgumentParser
6+
from twilio import __version_info__, __version__
7+
8+
def main(version):
9+
current_version = __version__
10+
11+
if version is None:
12+
match = re.search(r'(\d+)$', __version_info__[-1])
13+
if not match or match.group() is None:
14+
exit('Unable to auto bump version')
15+
16+
patch = int(match.group())
17+
patch += 1
18+
19+
prefix = __version_info__[-1][:(-1 * len(match.group()))]
20+
21+
new_patch = '{}{}'.format(prefix, patch)
22+
23+
version = '.'.join(__version_info__[:-1] + (new_patch, ))
24+
25+
print('Deploying {} -> {}'.format(current_version, version))
26+
27+
info = version.split('.')
28+
29+
init_src = ("__version_info__ = ({version_info})\n"
30+
"__version__ = '.'.join(__version_info__)")
31+
init_src = init_src.format(version_info=', '.join(["'{}'".format(i) for i in info]))
32+
33+
print('Updating twilio/__init__.py ... ', end="")
34+
with open('twilio/__init__.py', 'w') as init_file:
35+
init_file.write(init_src)
36+
print('Done')
37+
38+
new_readme = []
39+
40+
print('Updating README.md ... ', end="")
41+
with open('README.md', 'r') as readme:
42+
for line in readme.readlines():
43+
if current_version in line:
44+
line = line.replace(current_version, version)
45+
new_readme.append(line)
46+
47+
with open('README.md', 'w') as readme:
48+
readme.writelines(new_readme)
49+
print('Done')
50+
51+
print('git commit version bump')
52+
os.system('git commit -am "Bumping version to {}"'.format(version))
53+
os.system('git push')
54+
print('Done')
55+
56+
print('Pushing to pypi')
57+
os.system('make release')
58+
print('Done')
59+
60+
print('Adding git tag')
61+
os.system('git tag {}'.format(version))
62+
os.system('git push --tags')
63+
print('Done')
64+
65+
print('Deploy complete')
66+
67+
if __name__ == '__main__':
68+
parser = ArgumentParser()
69+
parser.add_argument('version', nargs='?')
70+
args = parser.parse_args()
71+
72+
main(args.version)

twilio/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
__version_info__ = ('6', '0rc9')
1+
__version_info__ = ('6', '0', '0rc9')
22
__version__ = '.'.join(__version_info__)

0 commit comments

Comments
 (0)
0