3030
3131 - name : Get latest dates in changelog
3232 run : |
33+ # Extrahiere die neuesten zwei Daten aus dem Changelog
3334 DATES=$(grep -E '^## [0-9]{4}-[0-9]{2}-[0-9]{2}' CHANGELOG.md | head -n 2 | awk '{print $2}')
3435
3536 LATEST_DATE=$(echo "$DATES" | sed -n '1p')
5455 const configPath = path.resolve(process.env.CONFIG_PATH);
5556 const fileContent = await fs.readFile(configPath, 'utf-8');
5657 const changelogConfig = JSON.parse(fileContent);
57-
58- const categorizedPRs = changelogConfig.map(obj => ({
59- ...obj,
60- notes: [],
61- subCategories: obj.subCategories ?? (obj.labels.includes("update script") ? [
62- { title: "🐞 Bug Fixes", labels: ["bugfix"] },
63- { title: "✨ Feature Updates", labels: ["feature"] }
64- ] : [])
65- }));
58+ const categorizedPRs = changelogConfig.map(obj => ({ ...obj, notes: [] }));
6659
6760 const latestDateInChangelog = new Date(process.env.LATEST_DATE);
6861 latestDateInChangelog.setUTCHours(23, 59, 59, 999);
@@ -77,33 +70,29 @@ jobs:
7770 per_page: 100,
7871 });
7972
80- pulls.filter(pr =>
81- pr.merged_at &&
82- new Date(pr.merged_at) > latestDateInChangelog &&
83- !pr.labels.some(label =>
84- ["invalid", "wontdo", process.env.AUTOMATED_PR_LABEL].includes(label.name.toLowerCase())
85- )
73+ pulls.filter(pr =>
74+ pr.merged_at &&
75+ new Date(pr.merged_at) > latestDateInChangelog &&
76+ !pr.labels.some(label => ["invalid", "wontdo", process.env.AUTOMATED_PR_LABEL].includes(label.name.toLowerCase()))
8677 ).forEach(pr => {
87-
8878 const prLabels = pr.labels.map(label => label.name.toLowerCase());
8979 const prNote = `- ${pr.title} [@${pr.user.login}](https://github.com/${pr.user.login}) ([#${pr.number}](${pr.html_url}))`;
9080
81+ let isCategorized = false;
9182
92- const updateScriptsCategory = categorizedPRs.find(category =>
93- category.labels.some(label => prLabels.includes(label))
94- );
95-
96- if (updateScriptsCategory) {
97-
98- const subCategory = updateScriptsCategory.subCategories.find(sub =>
99- sub.labels.some(label => prLabels.includes(label))
100- );
101-
102- if (subCategory) {
103- subCategory.notes.push(prNote);
104- } else {
105- updateScriptsCategory.notes.push(prNote);
83+ for (const { labels, notes } of categorizedPRs) {
84+ // If no labels are specified (e.g., "Unlabelled"), assign to this category
85+ if (labels.length === 0 && prLabels.length === 0) {
86+ notes.push(prNote);
87+ isCategorized = true;
88+ break;
89+ }
10690
91+ // If labels are specified, check if PR has ALL required labels
92+ if (labels.length > 0 && labels.every(label => prLabels.includes(label.toLowerCase()))) {
93+ notes.push(prNote);
94+ isCategorized = true;
95+ break;
10796 }
10897 }
10998
@@ -115,12 +104,9 @@ jobs:
115104 }
116105 }
117106 });
118-
119- console.log(JSON.stringify(categorizedPRs, null, 2));
120107
121108 return categorizedPRs;
122109
123-
124110 - name : Update CHANGELOG.md
125111 uses : actions/github-script@v7
126112 with :
@@ -133,32 +119,13 @@ jobs:
133119 const changelogPath = path.resolve('CHANGELOG.md');
134120 const categorizedPRs = ${{ steps.get-categorized-prs.outputs.result }};
135121
136- console.log(JSON.stringify(categorizedPRs, null, 2));
137-
138122 let newReleaseNotes = `## ${today}\n\n### Changes\n\n`;
139- for (const { title, notes, subCategories } of categorizedPRs) {
140- const hasSubcategories = subCategories && subCategories.length > 0;
141- const hasMainNotes = notes.length > 0;
142- const hasSubNotes = hasSubcategories && subCategories.some(sub => sub.notes && sub.notes.length > 0);
143-
144- if (hasMainNotes || hasSubNotes) {
145- newReleaseNotes += `### ${title}\n\n`;
146- }
147-
148- if (hasMainNotes) {
149- newReleaseNotes += `${notes.join("\n")}\n\n`;
150- }
151-
152- if (hasSubcategories) {
153- for (const { title : subTitle, notes: subNotes } of subCategories) {
154- if (subNotes && subNotes.length > 0) {
155- newReleaseNotes += ` # ### ${subTitle}\n\n`;
156- newReleaseNotes += ` ${subNotes.join("\n ")}\n\n`;
157- }
158- }
123+ for (const { title, notes } of categorizedPRs) {
124+ if (notes.length > 0) {
125+ newReleaseNotes += `### ${title}\n\n${notes.join("\n")}\n\n`;
159126 }
160- }
161-
127+ }
128+
162129 const changelogContent = await fs.readFile(changelogPath, 'utf-8');
163130 const changelogIncludesTodaysReleaseNotes = changelogContent.includes(`\n## ${today}`);
164131
0 commit comments