|
2 | 2 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
3 | 3 |
|
4 | 4 | # get the last release tag from git, and use it to find all merged PRs since |
5 | | -# that tag. extract their titles, labels and PR numbers and classify them into |
6 | | -# break changes, new # features, enhancements, bug fixes, and others based on |
7 | | -# their labels. |
| 5 | +# that tag. Since their titles might not following the same format, we use |
| 6 | +# gh cli to search merged PR by commit SHA. |
| 7 | +# |
| 8 | +# Once having those PRs' information, extract their titles, labels and PR |
| 9 | +# numbers and classify them into break changes, new features, enhancements, |
| 10 | +# bug fixes, and others based on their labels. |
8 | 11 | # |
9 | 12 | # The release version is generated based on the last release tag. The tag |
10 | 13 | # should be in the format of "WAMR-major.minor.patch", where major, minor, |
@@ -56,25 +59,25 @@ def get_last_release_tag(): |
56 | 59 |
|
57 | 60 | def get_merged_prs_since(tag): |
58 | 61 | # Get commits since the last release tag |
59 | | - log_cmd = f'git log {tag}..HEAD --pretty=format:"%s"' |
| 62 | + log_cmd = f'git log {tag}..HEAD --pretty=format:"%s %H"' |
60 | 63 | logs = run_cmd(log_cmd).splitlines() |
61 | 64 |
|
62 | 65 | print(f"Found {len(logs)} merge commits since last tag '{tag}'.") |
63 | 66 |
|
64 | 67 | pr_numbers = [] |
65 | 68 | for line in logs: |
66 | | - # assume the commit message ends with "(#PR_NUMBER)" |
67 | | - if not line.endswith(")"): |
68 | | - continue |
69 | | - |
70 | | - # Extract PR number |
71 | | - parts = line.split("(#") |
72 | | - if len(parts) < 2: |
73 | | - continue |
74 | | - |
75 | | - # PR_NUMBER) -> PR_NUMBER |
76 | | - pr_num = parts[1][:-1] |
77 | | - pr_numbers.append(pr_num) |
| 69 | + _, sha = line.rsplit(" ", 1) |
| 70 | + # Use SHA to find merged PRs |
| 71 | + pr_cmd = f"gh pr list --search {sha} --state merged --json number,title" |
| 72 | + pr_json = run_cmd(pr_cmd) |
| 73 | + pr_data = json.loads(pr_json) |
| 74 | + |
| 75 | + for pr in pr_data: |
| 76 | + pr_number = pr.get("number") |
| 77 | + print(f"Found PR #{pr_number} {pr['title']}") |
| 78 | + if pr_number and pr_number not in pr_numbers: |
| 79 | + pr_numbers.append(f"{pr_number}") |
| 80 | + |
78 | 81 | return pr_numbers |
79 | 82 |
|
80 | 83 |
|
@@ -145,7 +148,7 @@ def format_release_notes(version, sections): |
145 | 148 | else: |
146 | 149 | notes.append("") |
147 | 150 | notes.append("") |
148 | | - return "\n".join(notes) |
| 151 | + return "\n".join(notes) + "\n" |
149 | 152 |
|
150 | 153 |
|
151 | 154 | def insert_release_notes(notes, RELEASE_NOTES_FILE): |
|
0 commit comments