Skip to content

Commit 5337092

Browse files
committed
feat: add test feature for final release workflow (#38)
Signed-off-by: Nick Chung <nick.chung@suse.com>
1 parent 534bbba commit 5337092

File tree

4 files changed

+16
-6
lines changed

4 files changed

+16
-6
lines changed

.github/workflows/draft-release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
- name: Install dependencies
2525
run: yarn add -D conventional-changelog-cli
2626

27-
- name: Generate changelog
27+
- name: Generate changelog
2828
run: npx conventional-changelog -p angular -i CHANGELOG.md -s -r 0
2929

3030
- name: Add original authors

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* test release workflow final ([#39](https://github.com/NickChungSUSE/harvester-ui-extension/pull/39)) - Author: PR not found (merged by mergify[bot]) ([a876910](https://github.com/NickChungSUSE/harvester-ui-extension/commit/a8769109c41292405d3eeaa175090ab152b14815)), closes [#413](https://github.com/NickChungSUSE/harvester-ui-extension/issues/413)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Test feature for final release workflow

scripts/add-original-authors.js

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,16 +69,23 @@ async function getPRAuthor(prNumber) {
6969
function extractPRNumbers(changelogContent) {
7070
const prNumbers = new Set();
7171

72-
// Match patterns like (#123) in the changelog
72+
// Match patterns like [#123] in the changelog, but only the main PR references
7373
// Handle different formats:
7474
// - (#PR_NUMBER) (COMMIT_HASH)
7575
// - (#PR_NUMBER) (COMMIT_HASH), closes
7676
// - (#PR_NUMBER) (COMMIT_HASH), closes #OTHER_PR
77-
const prRegex = /\(#(\d+)\)\s*\([a-f0-9]+\)/g;
77+
// - ([#PR_NUMBER](link)) (COMMIT_HASH), closes
78+
// We want to match the main PR reference, not the "closes #PR" part
79+
// Look for the first [#PR_NUMBER] that's not in the "closes" part
80+
// This is a simpler approach - just find the first PR number
81+
const prRegex = /\[#(\d+)\]/g;
7882
let match;
7983

8084
while ((match = prRegex.exec(changelogContent)) !== null) {
81-
prNumbers.add(parseInt(match[1]));
85+
// Only add the first PR number (main PR), ignore "closes" references
86+
if (prNumbers.size === 0) {
87+
prNumbers.add(parseInt(match[1]));
88+
}
8289
}
8390

8491
return prNumbers;
@@ -100,9 +107,10 @@ async function addOriginalAuthors(changelogContent) {
100107
const originalAuthor = await getPRAuthor(prNumber);
101108

102109
// Handle the full pattern including any trailing text like ", closes"
103-
const pattern = new RegExp(`\\(#${ prNumber }\\)\\s*\\(([a-f0-9]+)\\)([^\\n]*)`, 'g');
110+
// Format: ([#PR_NUMBER](link)) (COMMIT_HASH), closes
111+
const pattern = new RegExp(`\\(\\[#${ prNumber }\\]\\([^)]+\\)\\)`, 'g');
104112

105-
updatedContent = updatedContent.replace(pattern, `(#${ prNumber }) - Author: ${ originalAuthor } (merged by mergify[bot]) ($1)$2`);
113+
updatedContent = updatedContent.replace(pattern, `([#${ prNumber }](https://github.com/NickChungSUSE/harvester-ui-extension/pull/${ prNumber })) - Author: ${ originalAuthor } (merged by mergify[bot])`);
106114
}
107115

108116
return updatedContent;

0 commit comments

Comments
 (0)