diff options
author | Chaoyi Zha <summermontreal@gmail.com> | 2017-02-04 08:06:17 +0300 |
---|---|---|
committer | Chaoyi Zha <summermontreal@gmail.com> | 2017-02-04 08:06:17 +0300 |
commit | 2bd5cfd6122b6f29ad5b250c7145af07ceb1272d (patch) | |
tree | f3acde000f3961514d5a99a410801406d0378d92 | |
parent | 1a4e11627ba383b3114ffc7e7218018e7ea5ee81 (diff) |
Update doc badges in versioning script
-rw-r--r-- | util/version.py | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/util/version.py b/util/version.py index 9ee8f1c..36f4c5a 100644 --- a/util/version.py +++ b/util/version.py @@ -1,8 +1,11 @@ import re, datetime, string, random -print "New version name (e.g 2.0.0):" +print "> New version name (e.g 2.0.0):" new_version = raw_input() +print "> Is this a stable release? [y, n]" +is_stable = raw_input() + with open('.env.setup', 'r+') as setup_env: setup_env_lines = setup_env.read() now = datetime.datetime.now() @@ -12,7 +15,7 @@ with open('.env.setup', 'r+') as setup_env: # Update setup key setup_env_lines = re.sub(r'(?is)APP_KEY=[^\n]+', 'APP_KEY={}'.format(new_setup_key), setup_env_lines) # Update date and release in setup env - setup_env_lines = re.sub(r'(?is)VERSION=[0-9a-zA-Z\.]+', 'VERSION={}'.format(new_version), setup_env_lines) + setup_env_lines = re.sub(r'cVERSION=[0-9a-zA-Z\.]+', 'VERSION={}'.format(new_version), setup_env_lines) setup_env_lines = re.sub(r'(?is)VERSION_RELMONTH=\w+', 'VERSION_RELMONTH={}'.format(now.strftime('%B')), setup_env_lines) setup_env_lines = re.sub(r'(?is)VERSION_RELDAY=\w+', 'VERSION_RELDAY={}'.format(now.day), setup_env_lines) setup_env_lines = re.sub(r'(?is)VERSION_RELYEAR=\w+', 'VERSION_RELYEAR={}'.format(now.year), setup_env_lines) @@ -22,4 +25,14 @@ with open('.env.setup', 'r+') as setup_env: setup_env.write(setup_env_lines) setup_env.truncate() +if is_stable == 'y': + with open('docs/index.md', 'r+') as index_md: + index_md_lines = index_md.read() + index_md_lines = re.sub(r'(?is)stable-[0-9\.]+-green.svg', 'stable-{}-green.svg'.format(new_version), index_md_lines) + + # Overwite existing file + index_md.seek(0) + index_md.write(index_md_lines) + index_md.truncate() + print "Done!" |