-
Notifications
You must be signed in to change notification settings - Fork 246
/
deploy.py
29 lines (21 loc) · 918 Bytes
/
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
""" File unrelated to the package, except for convenience in deploying """
import re
import sh
import os
commit_count = sh.git('rev-list', ['--all']).count('\n')
with open('setup.py') as f:
setup = f.read()
setup = re.sub("MICRO_VERSION = '[0-9]+'", "MICRO_VERSION = '{}'".format(commit_count), setup)
major = re.search("MAJOR_VERSION = '([0-9]+)'", setup).groups()[0]
minor = re.search("MINOR_VERSION = '([0-9]+)'", setup).groups()[0]
micro = re.search("MICRO_VERSION = '([0-9]+)'", setup).groups()[0]
version = '{}.{}.{}'.format(major, minor, micro)
with open('setup.py', 'w') as f:
f.write(setup)
with open('whereami/__init__.py') as f:
init = f.read()
with open('whereami/__init__.py', 'w') as f:
f.write(re.sub('__version__ = "[0-9.]+"', '__version__ = "{}"'.format(version), init))
os.system("rm -rf dist/")
os.system("python setup.py sdist bdist_wheel")
os.system("twine upload dist/*")