Skip to content

Commit

Permalink
feat: Add custom release notes
Browse files Browse the repository at this point in the history
  • Loading branch information
shdwmtr committed Dec 10, 2024
1 parent ffa572f commit 330495e
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .releaserc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"branches": ["main"],
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
"./scripts/release.js",
"@semantic-release/changelog",
"@semantic-release/git",
{
Expand Down
32 changes: 32 additions & 0 deletions scripts/release.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
const { execSync } = require('child_process');
const path = require('path');
const fs = require('fs');

module.exports = {
generateNotes: async () => {
const pluginsDir = path.resolve(process.cwd(), 'plugins');
let releaseNotes = `# Submodule Commit IDs\n\n`;

if (fs.existsSync(pluginsDir)) {
const submodules = fs.readdirSync(pluginsDir);

submodules.forEach(submodule => {
const submodulePath = path.join(pluginsDir, submodule);
if (fs.existsSync(path.join(submodulePath, '.git'))) {
try {
const commitId = execSync(`git -C ${submodulePath} rev-parse HEAD`, { encoding: 'utf-8' }).trim();
releaseNotes += `- **${submodule}**: ${commitId}\n`;
} catch (error) {
releaseNotes += `- **${submodule}**: Error fetching commit ID\n`;
}
} else {
releaseNotes += `- **${submodule}**: Not a Git repository\n`;
}
});
} else {
releaseNotes += `No plugins directory found.\n`;
}

return releaseNotes;
}
};

0 comments on commit 330495e

Please sign in to comment.