30
30
31
31
- name : Get latest dates in changelog
32
32
run : |
33
+ # Extrahiere die neuesten zwei Daten aus dem Changelog
33
34
DATES=$(grep -E '^## [0-9]{4}-[0-9]{2}-[0-9]{2}' CHANGELOG.md | head -n 2 | awk '{print $2}')
34
35
35
36
LATEST_DATE=$(echo "$DATES" | sed -n '1p')
54
55
const configPath = path.resolve(process.env.CONFIG_PATH);
55
56
const fileContent = await fs.readFile(configPath, 'utf-8');
56
57
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: [] }));
66
59
67
60
const latestDateInChangelog = new Date(process.env.LATEST_DATE);
68
61
latestDateInChangelog.setUTCHours(23, 59, 59, 999);
@@ -77,33 +70,29 @@ jobs:
77
70
per_page: 100,
78
71
});
79
72
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()))
86
77
).forEach(pr => {
87
-
88
78
const prLabels = pr.labels.map(label => label.name.toLowerCase());
89
79
const prNote = `- ${pr.title} [@${pr.user.login}](https://github.com/${pr.user.login}) ([#${pr.number}](${pr.html_url}))`;
90
80
81
+ let isCategorized = false;
91
82
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
+ }
106
90
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;
107
96
}
108
97
}
109
98
@@ -115,12 +104,9 @@ jobs:
115
104
}
116
105
}
117
106
});
118
-
119
- console.log(JSON.stringify(categorizedPRs, null, 2));
120
107
121
108
return categorizedPRs;
122
109
123
-
124
110
- name : Update CHANGELOG.md
125
111
uses : actions/github-script@v7
126
112
with :
@@ -133,32 +119,13 @@ jobs:
133
119
const changelogPath = path.resolve('CHANGELOG.md');
134
120
const categorizedPRs = ${{ steps.get-categorized-prs.outputs.result }};
135
121
136
- console.log(JSON.stringify(categorizedPRs, null, 2));
137
-
138
122
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`;
159
126
}
160
- }
161
-
127
+ }
128
+
162
129
const changelogContent = await fs.readFile(changelogPath, 'utf-8');
163
130
const changelogIncludesTodaysReleaseNotes = changelogContent.includes(`\n## ${today}`);
164
131
0 commit comments