Skip to content

Commit

Permalink
Fix: regex for auto changelog (#594)
Browse files Browse the repository at this point in the history
  • Loading branch information
dleviminzi authored Oct 7, 2024
1 parent 0df03a3 commit 800f82d
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions .github/workflows/release-changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,25 +37,21 @@ jobs:
}
const release = context.payload.release;
// TODO: remove this when after first real release
console.log("release", release);
const lines = release.body.split('\n');
const feats = [];
const fixes = [];
for (const line of lines) {
if (line.startsWith('*')) {
const m = line.match(/^\*\s*(Feat|Fix):\s*(.*)$/);
const m = line.match(/^\*\s*([fF]eat|[fF]ix):\s*(.*)\s*/);
if (m) {
const [_, type, description] = m;
const byIndex = description.indexOf('by');
if (type === 'Feat') {
if (type.toLowerCase() === 'feat') {
const cleanedDesc = description.slice(0, byIndex).trim();
feats.push(cleanedDesc);
} else if (type === 'Fix') {
} else if (type.toLowerCase() === 'fix') {
const cleanedDesc = description.slice(0, byIndex).trim();
fixes.push(cleanedDesc);
}
Expand All @@ -71,7 +67,7 @@ jobs:
}
const featsString = feats.map(feat => `- ${feat}`).join('\n');
const fixesString = fixes.map(fix => `- ${fix}`).join('\n');
const fixesString = fixes.map(fix => `- fix ${fix}`).join('\n');
core.setOutput('name', release.name.replace(/\s+/g, '-'));
core.setOutput('feats', featsString);
Expand Down

0 comments on commit 800f82d

Please sign in to comment.