Skip to content

Commit 46462a7

Browse files
[gh] Furhter Impove Changelog Workflow (#2655)
* Impove Workflow * Impove Workflow
1 parent a971ced commit 46462a7

File tree

5 files changed

+152
-83
lines changed

5 files changed

+152
-83
lines changed

.github/autolabeler-config.json

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,5 @@
11

22
{
3-
"breaking change": [
4-
{
5-
"fileStatus": "renamed",
6-
"includeGlobs": ["ct/**", "install/**", "misc/**", "turnkey/**", "vm/**"],
7-
"excludeGlobs": []
8-
},
9-
{
10-
"fileStatus": "removed",
11-
"includeGlobs": ["ct/**", "install/**", "misc/**", "turnkey/**", "vm/**"],
12-
"excludeGlobs": []
13-
}
14-
],
153
"new script": [
164
{
175
"fileStatus": "added",
@@ -33,10 +21,17 @@
3321
"excludeGlobs": []
3422
}
3523
],
36-
"rename script": [
24+
"maintenance": [
3725
{
38-
"fileStatus": "renamed",
39-
"includeGlobs": ["ct/**", "install/**", "misc/**", "turnkey/**", "vm/**"],
26+
"fileStatus": null,
27+
"includeGlobs": ["*.md", ".github/**", "misc/*.func", "ct/create_lxc.sh", "api/**"],
28+
"excludeGlobs": []
29+
}
30+
],
31+
"core": [
32+
{
33+
"fileStatus": null,
34+
"includeGlobs": ["misc/*.func", "ct/create_lxc.sh"],
4035
"excludeGlobs": []
4136
}
4237
],
@@ -47,25 +42,35 @@
4742
"excludeGlobs": []
4843
}
4944
],
50-
"maintenance": [
45+
"api": [
5146
{
5247
"fileStatus": null,
53-
"includeGlobs": ["*.md", ".github/**", "misc/*.func", "ct/create_lxc.sh"],
54-
"excludeGlobs": ["misc/api.func"]
48+
"includeGlobs": ["api/**", "misc/api.func"],
49+
"excludeGlobs": []
5550
}
5651
],
57-
"api": [
52+
"github": [
5853
{
5954
"fileStatus": null,
60-
"includeGlobs": ["api/**", "misc/api.func"],
55+
"includeGlobs": [".github/**"],
6156
"excludeGlobs": []
6257
}
6358
],
59+
"json": [
60+
{
61+
"fileStatus": "modified",
62+
"includeGlobs": ["json/**"],
63+
"excludeGlobs": []
64+
}
65+
],
66+
6467
"high risk": [
6568
{
6669
"fileStatus": null,
6770
"includeGlobs": ["misc/build.func", "misc/install.func", "ct/create_lxc.sh"],
6871
"excludeGlobs": []
6972
}
70-
]
71-
}
73+
]
74+
75+
76+
}

.github/changelog-pr-config.json

Lines changed: 69 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,8 @@
11
[
2-
{
3-
"title": "💥 Breaking Changes",
4-
"labels": ["breaking change"]
5-
},
62
{
73
"title": "🆕 New Scripts",
84
"labels": ["new script"]
95
},
10-
{
11-
"title": "✨ New Features",
12-
"labels": ["feature"]
13-
},
146
{
157
"title": "🚀 Updated Scripts",
168
"labels": ["update script"],
@@ -21,27 +13,85 @@
2113
"notes" : []
2214
},
2315
{
24-
"title": "General Updates",
25-
"labels": ["general"],
16+
"title": "✨ New Features",
17+
"labels": ["feature"],
18+
"notes" : []
19+
},
20+
{
21+
"title": "💥 Breaking Changes",
22+
"labels": ["breaking change"],
2623
"notes" : []
2724
}
2825
]
2926
},
30-
31-
{
32-
"title": "🌐 Website",
33-
"labels": ["website"]
34-
},
3527
{
36-
"title": "📡 API",
37-
"labels": ["api"]
28+
"title": "🧰 Maintenance",
29+
"labels": ["maintenance"],
30+
"subCategories": [
31+
{
32+
"title": "🐞 Bug Fixes",
33+
"labels": ["bugfix"],
34+
"notes" : []
35+
},
36+
{
37+
"title": "✨ New Features",
38+
"labels": ["feature"],
39+
"notes" : []
40+
},
41+
{
42+
"title": "💥 Breaking Changes",
43+
"labels": ["breaking change"],
44+
"notes" : []
45+
},
46+
{
47+
"title": "📡 API",
48+
"labels": ["api"],
49+
"notes" : []
50+
},
51+
{
52+
"title": "💾 Core",
53+
"labels": ["core"],
54+
"notes" : []
55+
},
56+
{
57+
"title": "📂 Github",
58+
"labels": ["github"],
59+
"notes" : []
60+
}
61+
]
3862
},
3963
{
40-
"title": "🧰 Maintenance",
41-
"labels": ["maintenance"]
64+
"title": "🌐 Website",
65+
"labels": ["website"],
66+
"subCategories": [
67+
{
68+
"title": "🐞 Bug Fixes",
69+
"labels": ["bugfix"],
70+
"notes" : []
71+
},
72+
{
73+
"title": "✨ New Features",
74+
"labels": ["feature"],
75+
"notes" : []
76+
},
77+
{
78+
"title": "💥 Breaking Changes",
79+
"labels": ["breaking change"],
80+
"notes" : []
81+
},
82+
{
83+
"title": "📝 Script Information",
84+
"labels": ["json"],
85+
"notes" : []
86+
}
87+
]
4288
},
4389
{
4490
"title": "❔ Unlabelled",
4591
"labels": []
92+
},
93+
{
94+
"title": "💥 Breaking Changes",
95+
"labels": ["breaking change"]
4696
}
4797
]

.github/pull_request_template.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
## ✍️ Description
22
<!-- Provide a clear and concise description of your changes. -->
33

4-
54
## 🔗 Related PR / Discussion / Issue
6-
Link: #
7-
85

6+
Link: #
97

108
## ✅ Prerequisites
9+
1110
Before this PR can be reviewed, the following must be completed:
11+
1212
- [] **Self-review performed** – Code follows established patterns and conventions.
1313
- [] **Testing performed** – Changes have been thoroughly tested and verified.
1414

15-
1615
## 🛠️ Type of Change
17-
Select all that apply:
18-
- [] 🐞 **Bug fix** – Resolves an issue without breaking functionality.
19-
- []**New feature** – Adds new, non-breaking functionality.
20-
- [] 💥 **Breaking change** – Alters existing functionality in a way that may require updates.
21-
- [] 🆕 **New script** – A fully functional and tested script or script set.
2216

17+
Select all that apply:
18+
19+
- [] 🆕 **New script** – A fully functional and tested script or script set.
20+
- [] 🐞 **Bug fix** – Resolves an issue without breaking functionality.
21+
- []**New feature** – Adds new, non-breaking functionality.
22+
- [] 💥 **Breaking change** – Alters existing functionality in a way that may require updates.
2323

2424
## 📋 Additional Information (optional)
2525
<!-- Provide extra context, screenshots, or references if needed. -->

.github/workflows/autolabeler.yml

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
permissions:
1212
pull-requests: write
1313
env:
14-
CONFIG_PATH: .github/autolabeler-config.json
14+
CONFIG_PATH: .github/autolabeler-config_new.json
1515
steps:
1616
- name: Checkout repository
1717
uses: actions/checkout@v4
@@ -43,26 +43,8 @@ jobs:
4343
});
4444
const prFiles = prListFilesResponse.data;
4545
46-
const templateLabelMappings = {
47-
"🐞 **bug fix**": "bugfix",
48-
"✨ **new feature**": "feature",
49-
"💥 **breaking change**": "breaking change",
50-
"🆕 **new script**": "new script"
51-
};
52-
53-
for (const [checkbox, label] of Object.entries(templateLabelMappings)) {
54-
const escapedCheckbox = checkbox.replace(/([.*+?^=!:${}()|\[\]\/\\])/g, "\\$1");
55-
const regex = new RegExp(`- \\[(x|X)\\]\\s*.*${escapedCheckbox}`, "i");
56-
const match = prBody.match(regex);
57-
if (match) {
58-
console.log(`Match: ${match}`);
59-
labelsToAdd.add(label);
60-
}
61-
}
62-
if (labelsToAdd.size === 0) {
63-
labelsToAdd.add("general");
64-
}
6546
47+
6648
// Apply labels based on file changes
6749
for (const [label, rules] of Object.entries(autolabelerConfig)) {
6850
const shouldAddLabel = prFiles.some((prFile) => {
@@ -79,6 +61,21 @@ jobs:
7961
labelsToAdd.add(label);
8062
}
8163
}
64+
const templateLabelMappings = {
65+
"🐞 **Bug fix**": "bugfix",
66+
"✨ **New feature**": "feature",
67+
"💥 **Breaking change**": "breaking change",
68+
};
69+
70+
for (const [checkbox, label] of Object.entries(templateLabelMappings)) {
71+
const escapedCheckbox = checkbox.replace(/([.*+?^=!:${}()|\[\]\/\\])/g, "\\$1");
72+
const regex = new RegExp(`- \\[(x|X)\\]\\s*.*${escapedCheckbox}`, "i");
73+
const match = prBody.match(regex);
74+
if (match) {
75+
console.log(`Match: ${match}`);
76+
labelsToAdd.add(label);
77+
}
78+
}
8279
8380
console.log(`Labels to add: ${Array.from(labelsToAdd).join(", ")}`);
8481
@@ -90,4 +87,4 @@ jobs:
9087
issue_number: prNumber,
9188
labels: Array.from(labelsToAdd),
9289
});
93-
}
90+
}

.github/workflows/changelog-pr.yml

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,26 @@ jobs:
5858
const categorizedPRs = changelogConfig.map(obj => ({
5959
...obj,
6060
notes: [],
61-
subCategories: obj.subCategories ?? (obj.labels.includes("update script") ? [
62-
{ title: "🐞 Bug Fixes", labels: ["bugfix"] },
63-
{ title: "✨ Feature Updates", labels: ["feature"] }
64-
] : [])
61+
subCategories: obj.subCategories ?? (
62+
obj.labels.includes("update script") ? [
63+
{ title: "🐞 Bug Fixes", labels: ["bugfix"], notes: [] },
64+
{ title: "✨ New Features", labels: ["feature"], notes: [] },
65+
{ title: "💥 Breaking Changes", labels: ["breaking change"], notes: [] }
66+
] :
67+
obj.labels.includes("maintenance") ? [
68+
{ title: "🐞 Bug Fixes", labels: ["bugfix"], notes: [] },
69+
{ title: "✨ New Features", labels: ["feature"], notes: [] },
70+
{ title: "💥 Breaking Changes", labels: ["breaking change"], notes: [] },
71+
{ title: "📡 API", labels: ["api"], notes: [] },
72+
{ title: "Github", labels: ["github"], notes: [] }
73+
] :
74+
obj.labels.includes("website") ? [
75+
{ title: "🐞 Bug Fixes", labels: ["bugfix"], notes: [] },
76+
{ title: "✨ New Features", labels: ["feature"], notes: [] },
77+
{ title: "💥 Breaking Changes", labels: ["breaking change"], notes: [] },
78+
{ title: "Script Information", labels: ["json"], notes: [] }
79+
] : []
80+
)
6581
}));
6682
6783
const latestDateInChangelog = new Date(process.env.LATEST_DATE);
@@ -110,6 +126,7 @@ jobs:
110126
111127
return categorizedPRs;
112128
129+
113130
- name: Update CHANGELOG.md
114131
uses: actions/github-script@v7
115132
with:
@@ -124,7 +141,8 @@ jobs:
124141
125142
console.log(JSON.stringify(categorizedPRs, null, 2));
126143
127-
let newReleaseNotes = `## ${today}\n\n### Changes\n\n`;
144+
145+
let newReleaseNotes = `## ${today}\n\n`;
128146
for (const { title, notes, subCategories } of categorizedPRs) {
129147
const hasSubcategories = subCategories && subCategories.length > 0;
130148
const hasMainNotes = notes.length > 0;
@@ -133,17 +151,16 @@ jobs:
133151

134152
if (hasMainNotes || hasSubNotes) {
135153
newReleaseNotes += `### ${title}\n\n`;
136-
}
154+
}
137155

138156
if (hasMainNotes) {
139-
newReleaseNotes += `${notes.join("\n")}\n\n`;
140-
}
141-
157+
newReleaseNotes += ` ${notes.join("\n")}\n\n`;
158+
}
142159
if (hasSubcategories) {
143160
for (const { title: subTitle, notes: subNotes } of subCategories) {
144161
if (subNotes && subNotes.length > 0) {
145-
newReleaseNotes += ` #### ${subTitle}\n\n`;
146-
newReleaseNotes += ` ${subNotes.join("\n ")}\n\n`;
162+
newReleaseNotes += ` - #### ${subTitle}\n\n`;
163+
newReleaseNotes += ` ${subNotes.join("\n ")}\n\n`;
147164
}
148165
}
149166
}
@@ -206,4 +223,4 @@ jobs:
206223
PR_NUMBER=$(gh pr list --head "${BRANCH_NAME}" --json number --jq '.[].number')
207224
if [ -n "$PR_NUMBER" ]; then
208225
gh pr review $PR_NUMBER --approve
209-
fi
226+
fi

0 commit comments

Comments
 (0)