forked from slopus/happy-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.release-it.notes.js
More file actions
executable file
·83 lines (68 loc) · 2.64 KB
/
.release-it.notes.js
File metadata and controls
executable file
·83 lines (68 loc) · 2.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/usr/bin/env node
import { execSync } from 'child_process';
/**
* Generate release notes using Claude Code by analyzing git commits
* Usage: node scripts/generate-release-notes.js <from-tag> <to-version>
*/
const [,, fromTag, toVersion] = process.argv;
if (!fromTag || !toVersion) {
console.error('Usage: node scripts/generate-release-notes.js <from-tag> <to-version>');
process.exit(1);
}
async function generateReleaseNotes() {
try {
// Get commit range for the release
const commitRange = fromTag === 'null' || !fromTag ? '--all' : `${fromTag}..HEAD`;
// Get git log for the commits
let gitLog;
try {
gitLog = execSync(
`git log ${commitRange} --pretty=format:"%h - %s (%an, %ar)" --no-merges`,
{ encoding: 'utf8' }
);
} catch (error) {
// Fallback to recent commits if tag doesn't exist
console.error(`Tag ${fromTag} not found, using recent commits instead`);
gitLog = execSync(
`git log -10 --pretty=format:"%h - %s (%an, %ar)" --no-merges`,
{ encoding: 'utf8' }
);
}
if (!gitLog.trim()) {
console.error('No commits found for release notes generation');
process.exit(1);
}
// Create a prompt for Claude to analyze commits and generate release notes
const prompt = `Please analyze these git commits and generate professional release notes for version ${toVersion} of the Happy CLI tool (a Claude Code session sharing CLI).
Git commits:
${gitLog}
Please format the output as markdown with:
- A brief summary of the release
- Organized sections for:
- 🚀 New Features
- 🐛 Bug Fixes
- ♻️ Refactoring
- 🔧 Other Changes
- Use bullet points for each change
- Keep descriptions concise but informative
- Focus on user-facing changes
- New line after each section
Do not include any preamble or explanations, just return the markdown release notes.`;
// Call Claude Code to generate release notes
console.error('Generating release notes with Claude Code...');
const releaseNotes = execSync(
`claude --print "${prompt}"`,
{
encoding: 'utf8',
stdio: ['pipe', 'pipe', 'inherit'],
maxBuffer: 1024 * 1024 * 10 // 10MB buffer
}
);
// Output release notes to stdout for release-it to use
console.log(releaseNotes.trim());
} catch (error) {
console.error('Error generating release notes:', error.message);
process.exit(1);
}
}
generateReleaseNotes();