diff --git a/changelog.d/19962.misc b/changelog.d/19962.misc new file mode 100644 index 0000000000..2f47794a67 --- /dev/null +++ b/changelog.d/19962.misc @@ -0,0 +1 @@ +Update release script JSON schema find/replace task to be compatible with macOS. diff --git a/scripts-dev/release.py b/scripts-dev/release.py index 68e0b3c772..d1ba2e5822 100755 --- a/scripts-dev/release.py +++ b/scripts-dev/release.py @@ -31,6 +31,7 @@ import sys import time import urllib.request from os import path +from pathlib import Path from tempfile import TemporaryDirectory from typing import Any @@ -257,10 +258,16 @@ def _prepare() -> None: subprocess.check_output(["poetry", "version", new_version]) # Update config schema $id. - schema_file = "schema/synapse-config.schema.yaml" + schema_file_path = Path("schema/synapse-config.schema.yaml") major_minor_version = ".".join(new_version.split(".")[:2]) url = f"https://element-hq.github.io/synapse/schema/synapse/v{major_minor_version}/synapse-config.schema.json" - subprocess.check_output(["sed", "-i", f"0,/^\\$id: .*/s||$id: {url}|", schema_file]) + # Find/replace the `$id: ...` line in `schema/synapse-config.schema.yaml` with a new + # unique identifier for this release + schema_file_content = schema_file_path.read_text() + new_schema_file_content = re.sub( + r"^\$id: .*", f"$id: {url}", schema_file_content, count=1, flags=re.MULTILINE + ) + schema_file_path.write_text(new_schema_file_content) # Generate changelogs. generate_and_write_changelog(synapse_repo, current_version, new_version)