Merge pull request #7598 from pfmoore/release_fix

Fix invalid assumption that version file contains just a version number
This commit is contained in:
Paul Moore 2020-01-15 10:26:58 +00:00 committed by GitHub
commit 87a2bedc17
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 1 deletions

View File

@ -86,8 +86,20 @@ def generate_news(session: Session, version: str) -> None:
def update_version_file(version: str, filepath: str) -> None:
with open(filepath, "r", encoding="utf-8") as f:
content = list(f)
file_modified = False
with open(filepath, "w", encoding="utf-8") as f:
f.write('__version__ = "{}"\n'.format(version))
for line in content:
if line.startswith("__version__ ="):
f.write('__version__ = "{}"\n'.format(version))
file_modified = True
else:
f.write(line)
assert file_modified, \
"Version file {} did not get modified".format(filepath)
def create_git_tag(session: Session, tag_name: str, *, message: str) -> None: