Skip to content

Commit

Permalink
added update_package_version and append_histoical_log to update_relea…
Browse files Browse the repository at this point in the history
…se.py
  • Loading branch information
kreczko committed Jul 25, 2018
1 parent 218afd7 commit a195231
Showing 1 changed file with 34 additions and 1 deletion.
35 changes: 34 additions & 1 deletion update_release.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def update_readme(release):
break

content = ''.join(content)
with open('README.md', 'w+') as f:
with open(input_file, 'w+') as f:
f.write(content)


Expand All @@ -29,7 +29,40 @@ def update_changelog(release):
with open(input_file, 'w+') as f:
f.write(content)


def update_package_version(release):
input_file = 'cmsl1t/__init__.py'
with open(input_file) as f:
content = f.readlines()

for i, line in enumerate(content):
pattern = "(\d+\.)?(\d+\.)?(\*|\d+)"
if '__version__' in line:
line = re.sub(pattern, 'v' + release, line)
content[i] = line
break

content = ''.join(content)
with open(input_file, 'w+') as f:
f.write(content)


def append_histoical_log():
input_file = 'CHANGELOG.md'
with open(input_file) as f:
content = f.readlines()
historical_changelog = 'docs/initial_changelog.md'
with open(historical_changelog) as f:
historical_content = f.readlines()

content.insert(-2, ''.join(historical_content))
content = ''.join(content)
with open(input_file, 'w+') as f:
f.write(content)

if __name__ == '__main__':
release = os.environ.get('RELEASE', 'unreleased')
update_readme(release)
update_changelog(release)
update_package_version(release)
append_histoical_log()

0 comments on commit a195231

Please sign in to comment.