Skip to content

Commit 7eedaf6

Browse files
author
Fernando Álvarez
committed
Add release script for CI
1 parent 8413dd9 commit 7eedaf6

3 files changed

Lines changed: 48 additions & 0 deletions

File tree

‎.gitignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
cctrl.egg-info/
2+
dotcloudng.egg-info/
23
htmlcov/
34
.cache/

‎ci/release.py‎

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import os
2+
import sys
3+
import xmlrpclib
4+
5+
from shutil import rmtree
6+
from subprocess import call, check_call
7+
8+
TEMP_DIR='tmp'
9+
PROJECT_NAME='cctrl'
10+
DIST_DIR=os.path.join(TEMP_DIR, 'dist')
11+
12+
13+
def main():
14+
if is_current_version():
15+
sys.exit("Version is not updated. Aborting release.")
16+
17+
generate_dist()
18+
upload_dist()
19+
cleanup()
20+
21+
22+
def is_current_version():
23+
pypi = xmlrpclib.ServerProxy('http://pypi.python.org/pypi')
24+
return pypi.package_releases('cctrl')[0] == __version__
25+
26+
27+
def generate_dist():
28+
check_call(['python',
29+
'setup.py',
30+
'sdist',
31+
'--dist-dir={0}'.format(DIST_DIR),
32+
'--formats=gztar'])
33+
34+
35+
def upload_dist():
36+
try:
37+
call('twine upload {}'.format(os.path.join(DIST_DIR, '*')), shell=True) # TODO Sign files to upload using gpg
38+
except OSError as e:
39+
print e
40+
41+
def cleanup():
42+
rmtree(TEMP_DIR)
43+
44+
if __name__ == '__main__':
45+
execfile(os.path.join(PROJECT_NAME, 'version.py'))
46+
main()

‎requirements.txt‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
pycclib>=1.5.2
22
argparse>=1.1
3+
twine

0 commit comments

Comments
 (0)