From c62efc82814b2df918a128a437070f8de4a26240 Mon Sep 17 00:00:00 2001 From: Jaeseung Lee <41176085+tkxkd0159@users.noreply.github.com> Date: Fri, 14 Jun 2024 19:00:39 +0900 Subject: [PATCH] feat: Force user to follow the rule of release note generation (#385) * force user to follow release note rule * Add CHANGELOG * chore * chore --- CHANGELOG.md | 1 + RELEASE_DESCR.md | 2 ++ scripts/release-note.py | 57 ++++++++++++++++++++++------------------- 3 files changed, 34 insertions(+), 26 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7e5d54ee..3759b9e4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -48,6 +48,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ * (fswap, fbridge) [\#380](https://github.com/Finschia/finschia/pull/380) Bump github.com/Finschia/finschia-sdk from v0.49.0-rc6 to v0.49.0-rc7 ### Improvements +* (ci) [\#385](https://github.com/Finschia/finschia/pull/385) Force user to follow the rule of release note generation ### Bug Fixes 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..d3991c7e 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,24 @@ 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 - else: - raise ValueError("Content not found between the specified markers.") + + 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 {target}") + + start_pos += len(start_marker) + len("YYYY-MM-DD") + end_marker = f"## [{prev_tag}]" if prev_tag else "" + 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 {target}" + if prev_tag + else f"End marker '{end_marker}' not found in {target}" + ) + return document[start_pos:end_pos].strip() @@ -85,10 +88,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