Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Make release script write correct no-op changelog #12127

Merged
merged 2 commits into from
Mar 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/12127.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Update release script to insert the previous version when writing "No significant changes" line in the changelog.
30 changes: 28 additions & 2 deletions scripts-dev/release.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
"""An interactive script for doing a release. See `cli()` below.
"""

import glob
import os
import re
import subprocess
import sys
Expand Down Expand Up @@ -209,8 +211,8 @@ def prepare():
with open("synapse/__init__.py", "w") as f:
f.write(parsed_synapse_ast.dumps())

# Generate changelogs
run_until_successful("python3 -m towncrier", shell=True)
# Generate changelogs.
generate_and_write_changelog(current_version)

# Generate debian changelogs
if parsed_new_version.pre is not None:
Expand Down Expand Up @@ -523,5 +525,29 @@ class VersionSection:
return "\n".join(version_changelog)


def generate_and_write_changelog(current_version: version.Version):
# We do this by getting a draft so that we can edit it before writing to the
# changelog.
result = run_until_successful(
"python3 -m towncrier --draft", shell=True, capture_output=True
)
new_changes = result.stdout.decode("utf-8")
new_changes = new_changes.replace(
"No significant changes.", f"No significant changes since {current_version}."
)

# Prepend changes to changelog
with open("CHANGES.md", "r+") as f:
existing_content = f.read()
f.seek(0, 0)
f.write(new_changes)
f.write("\n")
f.write(existing_content)

# Remove all the news fragments
for f in glob.iglob("changelog.d/*.*"):
os.remove(f)
anoadragon453 marked this conversation as resolved.
Show resolved Hide resolved


if __name__ == "__main__":
cli()