1
0
mirror of https://github.com/cydrobolt/polr.git synced 2024-09-19 15:11:40 +02:00

Update doc badges in versioning script

This commit is contained in:
Chaoyi Zha 2017-02-04 00:06:17 -05:00
parent 1a4e11627b
commit 2bd5cfd612

View File

@ -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!"