diff --git a/RELEASE_DESCR.md b/RELEASE_DESCR.md index 09496874..38029e8b 100644 --- a/RELEASE_DESCR.md +++ b/RELEASE_DESCR.md @@ -40,3 +40,5 @@ This version based on finschia-sdk v0.46.0-rc2 ## [v0.1.0] - 2021-11-01 This is the first release of the Finschia blockchain. It is based on [gaia v4.0.4](https://github.com/cosmos/gaia/releases/tag/v4.0.4). + + diff --git a/scripts/release-note.py b/scripts/release-note.py index 2178f286..52da64d4 100644 --- a/scripts/release-note.py +++ b/scripts/release-note.py @@ -28,8 +28,12 @@ def get_prev_gittag(target_tag: str) -> str: ) -def extract_package_version(document: str, package_name: str): - pattern = rf"{re.escape(package_name)} (v[^\s]+)" +def extract_package_version( + document: str, package_name: str, version_suffix: bool +) -> str: + suffix_pattern = r"\/v\d+" if version_suffix else "" + pattern = rf"{re.escape(package_name)}{suffix_pattern} (v[^\s]+)" + match = re.search(pattern, document) if match: return match.group(1) @@ -37,7 +41,7 @@ def extract_package_version(document: str, package_name: str): raise ValueError(f"Package {package_name} not found in the document.") -def extract_go_version(document: str): +def extract_go_version(document: str) -> str: pattern = r"go ([^\s]+)" match = re.search(pattern, document) if match: @@ -52,25 +56,29 @@ def extract_release_contents(target: str, cur_tag: str, prev_tag: str) -> str: with open(target, "r") as f: document = f.read() - start_marker = f"## [{cur_tag}]" - start_pos = document.find(start_marker) + len(start_marker) + len(" - YYYY-MM-DD") - if start_pos != -1: - if prev_tag is None: - end_pos = document.find("") - if end_pos == -1: - match = re.search(r"## \[v\d+\.\d+\.\d+] - \d{4}-\d{2}-\d{2}", document[start_pos:]) - if match is None: - end_pos = -1 - else: - end_pos = start_pos + match.start() - 1 - else: - end_marker = f"## [{prev_tag}]" - end_pos = document.find(end_marker) - if end_pos == -1: - match = re.search(r"## \[v\d+\.\d+\.\d+] - \d{4}-\d{2}-\d{2}", document[start_pos:]) - end_pos = start_pos + match.start() - 1 + + start_marker = f"## [{cur_tag}] - " + start_pos = document.find(start_marker) + + if start_pos == -1: + raise ValueError(f"Start marker for tag '{cur_tag}' not found in the document.") + + start_pos += len(start_marker) + len("YYYY-MM-DD") + + if prev_tag: + end_marker = f"## [{prev_tag}]" + end_pos = document.find(end_marker, start_pos) + if end_pos == -1: + raise ValueError( + f"End marker for previous tag '{prev_tag}' not found in the document." + ) else: - raise ValueError("Content not found between the specified markers.") + end_pos = document.find("", start_pos) + if end_pos == -1: + raise ValueError( + "End marker '' not found in the document." + ) + return document[start_pos:end_pos].strip() @@ -85,10 +93,12 @@ def extract_release_contents(target: str, cur_tag: str, prev_tag: str) -> str: TAG = args[0] PREV_TAG = get_prev_gittag(TAG) GO_VERSION = extract_go_version(gomod) -OSTRACON_VERSION = extract_package_version(gomod, "github.com/Finschia/ostracon") -FNSASDK_VERSION = extract_package_version(gomod, "github.com/Finschia/finschia-sdk") -WASMD_VERSION = extract_package_version(gomod, "github.com/Finschia/wasmd") -IBC_VERSION = extract_package_version(gomod, "github.com/cosmos/ibc-go/v4") +OSTRACON_VERSION = extract_package_version(gomod, "github.com/Finschia/ostracon", False) +FNSASDK_VERSION = extract_package_version( + gomod, "github.com/Finschia/finschia-sdk", False +) +WASMD_VERSION = extract_package_version(gomod, "github.com/Finschia/wasmd", False) +IBC_VERSION = extract_package_version(gomod, "github.com/cosmos/ibc-go", True) release_note = f"""# Finschia {TAG} Release Note