Skip to content

[gh] Furhter Impove Changelog Workflow #2655

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 27 additions & 22 deletions .github/autolabeler-config.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,5 @@

{
"breaking change": [
{
"fileStatus": "renamed",
"includeGlobs": ["ct/**", "install/**", "misc/**", "turnkey/**", "vm/**"],
"excludeGlobs": []
},
{
"fileStatus": "removed",
"includeGlobs": ["ct/**", "install/**", "misc/**", "turnkey/**", "vm/**"],
"excludeGlobs": []
}
],
"new script": [
{
"fileStatus": "added",
Expand All @@ -33,10 +21,17 @@
"excludeGlobs": []
}
],
"rename script": [
"maintenance": [
{
"fileStatus": "renamed",
"includeGlobs": ["ct/**", "install/**", "misc/**", "turnkey/**", "vm/**"],
"fileStatus": null,
"includeGlobs": ["*.md", ".github/**", "misc/*.func", "ct/create_lxc.sh", "api/**"],
"excludeGlobs": []
}
],
"core": [
{
"fileStatus": null,
"includeGlobs": ["misc/*.func", "ct/create_lxc.sh"],
"excludeGlobs": []
}
],
Expand All @@ -47,25 +42,35 @@
"excludeGlobs": []
}
],
"maintenance": [
"api": [
{
"fileStatus": null,
"includeGlobs": ["*.md", ".github/**", "misc/*.func", "ct/create_lxc.sh"],
"excludeGlobs": ["misc/api.func"]
"includeGlobs": ["api/**", "misc/api.func"],
"excludeGlobs": []
}
],
"api": [
"github": [
{
"fileStatus": null,
"includeGlobs": ["api/**", "misc/api.func"],
"includeGlobs": [".github/**"],
"excludeGlobs": []
}
],
"json": [
{
"fileStatus": "modified",
"includeGlobs": ["json/**"],
"excludeGlobs": []
}
],

"high risk": [
{
"fileStatus": null,
"includeGlobs": ["misc/build.func", "misc/install.func", "ct/create_lxc.sh"],
"excludeGlobs": []
}
]
}
]


}
88 changes: 69 additions & 19 deletions .github/changelog-pr-config.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,8 @@
[
{
"title": "💥 Breaking Changes",
"labels": ["breaking change"]
},
{
"title": "🆕 New Scripts",
"labels": ["new script"]
},
{
"title": "✨ New Features",
"labels": ["feature"]
},
{
"title": "🚀 Updated Scripts",
"labels": ["update script"],
Expand All @@ -21,27 +13,85 @@
"notes" : []
},
{
"title": "General Updates",
"labels": ["general"],
"title": "✨ New Features",
"labels": ["feature"],
"notes" : []
},
{
"title": "💥 Breaking Changes",
"labels": ["breaking change"],
"notes" : []
}
]
},

{
"title": "🌐 Website",
"labels": ["website"]
},
{
"title": "📡 API",
"labels": ["api"]
"title": "🧰 Maintenance",
"labels": ["maintenance"],
"subCategories": [
{
"title": "🐞 Bug Fixes",
"labels": ["bugfix"],
"notes" : []
},
{
"title": "✨ New Features",
"labels": ["feature"],
"notes" : []
},
{
"title": "💥 Breaking Changes",
"labels": ["breaking change"],
"notes" : []
},
{
"title": "📡 API",
"labels": ["api"],
"notes" : []
},
{
"title": "💾 Core",
"labels": ["core"],
"notes" : []
},
{
"title": "📂 Github",
"labels": ["github"],
"notes" : []
}
]
},
{
"title": "🧰 Maintenance",
"labels": ["maintenance"]
"title": "🌐 Website",
"labels": ["website"],
"subCategories": [
{
"title": "🐞 Bug Fixes",
"labels": ["bugfix"],
"notes" : []
},
{
"title": "✨ New Features",
"labels": ["feature"],
"notes" : []
},
{
"title": "💥 Breaking Changes",
"labels": ["breaking change"],
"notes" : []
},
{
"title": "📝 Script Information",
"labels": ["json"],
"notes" : []
}
]
},
{
"title": "❔ Unlabelled",
"labels": []
},
{
"title": "💥 Breaking Changes",
"labels": ["breaking change"]
}
]
18 changes: 9 additions & 9 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
## ✍️ Description
<!-- Provide a clear and concise description of your changes. -->


## 🔗 Related PR / Discussion / Issue
Link: #


Link: #

## ✅ Prerequisites

Before this PR can be reviewed, the following must be completed:

- [] **Self-review performed** – Code follows established patterns and conventions.
- [] **Testing performed** – Changes have been thoroughly tested and verified.


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

Select all that apply:

- [] 🆕 **New script** – A fully functional and tested script or script set.
- [] 🐞 **Bug fix** – Resolves an issue without breaking functionality.
- [] ✨ **New feature** – Adds new, non-breaking functionality.
- [] 💥 **Breaking change** – Alters existing functionality in a way that may require updates.

## 📋 Additional Information (optional)
<!-- Provide extra context, screenshots, or references if needed. -->
39 changes: 18 additions & 21 deletions .github/workflows/autolabeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
permissions:
pull-requests: write
env:
CONFIG_PATH: .github/autolabeler-config.json
CONFIG_PATH: .github/autolabeler-config_new.json
steps:
- name: Checkout repository
uses: actions/checkout@v4
Expand Down Expand Up @@ -43,26 +43,8 @@ jobs:
});
const prFiles = prListFilesResponse.data;

const templateLabelMappings = {
"🐞 **bug fix**": "bugfix",
"✨ **new feature**": "feature",
"💥 **breaking change**": "breaking change",
"🆕 **new script**": "new script"
};

for (const [checkbox, label] of Object.entries(templateLabelMappings)) {
const escapedCheckbox = checkbox.replace(/([.*+?^=!:${}()|\[\]\/\\])/g, "\\$1");
const regex = new RegExp(`- \\[(x|X)\\]\\s*.*${escapedCheckbox}`, "i");
const match = prBody.match(regex);
if (match) {
console.log(`Match: ${match}`);
labelsToAdd.add(label);
}
}
if (labelsToAdd.size === 0) {
labelsToAdd.add("general");
}


// Apply labels based on file changes
for (const [label, rules] of Object.entries(autolabelerConfig)) {
const shouldAddLabel = prFiles.some((prFile) => {
Expand All @@ -79,6 +61,21 @@ jobs:
labelsToAdd.add(label);
}
}
const templateLabelMappings = {
"🐞 **Bug fix**": "bugfix",
"✨ **New feature**": "feature",
"💥 **Breaking change**": "breaking change",
};

for (const [checkbox, label] of Object.entries(templateLabelMappings)) {
const escapedCheckbox = checkbox.replace(/([.*+?^=!:${}()|\[\]\/\\])/g, "\\$1");
const regex = new RegExp(`- \\[(x|X)\\]\\s*.*${escapedCheckbox}`, "i");
const match = prBody.match(regex);
if (match) {
console.log(`Match: ${match}`);
labelsToAdd.add(label);
}
}

console.log(`Labels to add: ${Array.from(labelsToAdd).join(", ")}`);

Expand All @@ -90,4 +87,4 @@ jobs:
issue_number: prNumber,
labels: Array.from(labelsToAdd),
});
}
}
41 changes: 29 additions & 12 deletions .github/workflows/changelog-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,26 @@ jobs:
const categorizedPRs = changelogConfig.map(obj => ({
...obj,
notes: [],
subCategories: obj.subCategories ?? (obj.labels.includes("update script") ? [
{ title: "🐞 Bug Fixes", labels: ["bugfix"] },
{ title: "✨ Feature Updates", labels: ["feature"] }
] : [])
subCategories: obj.subCategories ?? (
obj.labels.includes("update script") ? [
{ title: "🐞 Bug Fixes", labels: ["bugfix"], notes: [] },
{ title: "✨ New Features", labels: ["feature"], notes: [] },
{ title: "💥 Breaking Changes", labels: ["breaking change"], notes: [] }
] :
obj.labels.includes("maintenance") ? [
{ title: "🐞 Bug Fixes", labels: ["bugfix"], notes: [] },
{ title: "✨ New Features", labels: ["feature"], notes: [] },
{ title: "💥 Breaking Changes", labels: ["breaking change"], notes: [] },
{ title: "📡 API", labels: ["api"], notes: [] },
{ title: "Github", labels: ["github"], notes: [] }
] :
obj.labels.includes("website") ? [
{ title: "🐞 Bug Fixes", labels: ["bugfix"], notes: [] },
{ title: "✨ New Features", labels: ["feature"], notes: [] },
{ title: "💥 Breaking Changes", labels: ["breaking change"], notes: [] },
{ title: "Script Information", labels: ["json"], notes: [] }
] : []
)
}));

const latestDateInChangelog = new Date(process.env.LATEST_DATE);
Expand Down Expand Up @@ -110,6 +126,7 @@ jobs:

return categorizedPRs;


- name: Update CHANGELOG.md
uses: actions/github-script@v7
with:
Expand All @@ -124,7 +141,8 @@ jobs:

console.log(JSON.stringify(categorizedPRs, null, 2));

let newReleaseNotes = `## ${today}\n\n### Changes\n\n`;

let newReleaseNotes = `## ${today}\n\n`;
for (const { title, notes, subCategories } of categorizedPRs) {
const hasSubcategories = subCategories && subCategories.length > 0;
const hasMainNotes = notes.length > 0;
Expand All @@ -133,17 +151,16 @@ jobs:

if (hasMainNotes || hasSubNotes) {
newReleaseNotes += `### ${title}\n\n`;
}
}

if (hasMainNotes) {
newReleaseNotes += `${notes.join("\n")}\n\n`;
}

newReleaseNotes += ` ${notes.join("\n")}\n\n`;
}
if (hasSubcategories) {
for (const { title: subTitle, notes: subNotes } of subCategories) {
if (subNotes && subNotes.length > 0) {
newReleaseNotes += ` #### ${subTitle}\n\n`;
newReleaseNotes += ` ${subNotes.join("\n ")}\n\n`;
newReleaseNotes += ` - #### ${subTitle}\n\n`;
newReleaseNotes += ` ${subNotes.join("\n ")}\n\n`;
}
}
}
Expand Down Expand Up @@ -206,4 +223,4 @@ jobs:
PR_NUMBER=$(gh pr list --head "${BRANCH_NAME}" --json number --jq '.[].number')
if [ -n "$PR_NUMBER" ]; then
gh pr review $PR_NUMBER --approve
fi
fi