Skip to content

Commit 029332f

Browse files
Revert "[gh] Update Changelog Workflow (#2621)" (#2630)
This reverts commit 893bff1.
1 parent aba73bd commit 029332f

File tree

4 files changed

+31
-99
lines changed

4 files changed

+31
-99
lines changed

.github/autolabeler-config.json

-1
Original file line numberDiff line numberDiff line change
@@ -68,5 +68,4 @@
6868
"excludeGlobs": []
6969
}
7070
]
71-
7271
}

.github/changelog-pr-config.json

+4-16
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,14 @@
77
"title": "🆕 New Scripts",
88
"labels": ["new script"]
99
},
10+
{
11+
"title": "🐞 Bug Fixes",
12+
"labels": ["bugfix"]
13+
},
1014
{
1115
"title": "✨ New Features",
1216
"labels": ["feature"]
1317
},
14-
{
15-
"title": "🚀 Updated Scripts",
16-
"labels": ["update script"],
17-
"subCategories": [
18-
{
19-
"title": "🐞 Bug Fixes",
20-
"labels": ["bugfix"],
21-
"notes" : []
22-
},
23-
{
24-
"title": "General Updates",
25-
"labels": ["general"],
26-
"notes" : []
27-
}
28-
]
29-
},
3018
{
3119
"title": "🌐 Website",
3220
"labels": ["website"]

.github/workflows/autolabeler.yml

+3-25
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,8 @@ jobs:
3232
const autolabelerConfig = JSON.parse(fileContent);
3333
3434
const prNumber = context.payload.pull_request.number;
35-
36-
const prBody = context.payload.pull_request.body.toLowerCase();
37-
35+
const prBody = context.payload.pull_request.body;
36+
3837
let labelsToAdd = new Set();
3938
4039
const prListFilesResponse = await github.rest.pulls.listFiles({
@@ -43,35 +42,14 @@ jobs:
4342
pull_number: prNumber,
4443
});
4544
const prFiles = prListFilesResponse.data;
46-
47-
const templateLabelMappings = {
48-
"🐞 **bug fix**": "bugfix",
49-
"✨ **new feature**": "feature",
50-
"💥 **breaking change**": "breaking change",
51-
"🆕 **new script**": "new script"
52-
};
53-
54-
for (const [checkbox, label] of Object.entries(templateLabelMappings)) {
55-
const escapedCheckbox = checkbox.replace(/([.*+?^=!:${}()|\[\]\/\\])/g, "\\$1");
56-
const regex = new RegExp(`- \\[(x|X)\\]\\s*.*${escapedCheckbox}`, "i");
57-
const match = prBody.match(regex);
58-
if (match) {
59-
console.log(`Match: ${match}`);
60-
labelsToAdd.add(label);
61-
}
62-
}
63-
if (labelsToAdd.size === 0) {
64-
labelsToAdd.add("general");
65-
}
6645
67-
// Apply labels based on file changes
6846
for (const [label, rules] of Object.entries(autolabelerConfig)) {
6947
const shouldAddLabel = prFiles.some((prFile) => {
7048
return rules.some((rule) => {
7149
const isFileStatusMatch = rule.fileStatus ? rule.fileStatus === prFile.status : true;
7250
const isIncludeGlobMatch = rule.includeGlobs.some((glob) => minimatch(prFile.filename, glob));
7351
const isExcludeGlobMatch = rule.excludeGlobs.some((glob) => minimatch(prFile.filename, glob));
74-
52+
7553
return isFileStatusMatch && isIncludeGlobMatch && !isExcludeGlobMatch;
7654
});
7755
});

.github/workflows/changelog-pr.yml

+24-57
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ jobs:
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')
@@ -54,15 +55,7 @@ jobs:
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

Comments
 (0)