-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathrelease_version.py
executable file
·58 lines (48 loc) · 2.01 KB
/
release_version.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
55
56
57
58
#!/usr/bin/env python3
from django_mako_plus.version import __version__
from django_mako_plus.command import run_command
import sys
import os
import re
import shutil
import json
# set the version number in package.json
print('Updating the version in package.json...')
PACKAGE_JSON = 'django_mako_plus/webroot/package.json'
with open(PACKAGE_JSON) as fin:
data = json.load(fin)
data['version'] = __version__
with open(PACKAGE_JSON, 'w') as fout:
json.dump(data, fout, sort_keys=True, indent=4)
# set the version number in dmp-common.src.js
print('Updating the version in JS...')
VERSION_PATTERN = re.compile("__version__\ = '\w+\.\w+\.\w+'")
DMP_COMMON = 'django_mako_plus/webroot/dmp-common.src.js'
with open(DMP_COMMON) as fin:
content = fin.read()
match = VERSION_PATTERN.search(content)
if not match:
raise RuntimeError('Version pattern did not match. Aborting because the version number cannot be updated in dmp-common.src.js.')
content = VERSION_PATTERN.sub("__version__ = '{}'".format(__version__), content)
with open(DMP_COMMON, 'w') as fout:
fout.write(content)
# backport and minify dmp-common.src.js
print('Backporting and minifying JS...')
run_command('npm', 'run', 'build', cwd='./django_mako_plus/webroot/')
# update the archives
print('Creating the archives...')
shutil.make_archive('app_template', 'zip', root_dir='./django_mako_plus/app_template')
shutil.make_archive('project_template', 'zip', root_dir='./django_mako_plus/project_template')
# make the documentation, since GitHub Pages reads it as static HTML
print('Making the documentation...')
run_command('make', 'html', cwd='./docs-src')
# run the setup and upload
print()
if input('Ready to upload to PyPi. Continue? ')[:1].lower() == 'y':
ret = run_command('python3', 'setup.py', 'sdist')
print(ret.stdout)
ret = run_command('twine', 'upload', 'dist/*')
print(ret.stdout)
run_command('rm', '-rf', 'dist/', 'django_mako_plus.egg-info/')
ret = run_command('npm', 'publish', cwd='./django_mako_plus/webroot/')
print(ret.stdout)