Skip to content

Commit

Permalink
(v1.0.1) code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Rey Columna authored and Rey Columna committed Apr 25, 2024
1 parent 2cbc8ba commit 7d0434a
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 51 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Release Notes Generator

[![GitHub license](https://img.shields.io/github/license/reyco1/release-notes)](https://github.com/reyco1/release-notes/blob/main/LICENSE) [![GitHub issues](https://img.shields.io/github/issues/reyco1/release-notes)](https://github.com/reyco1/release-notes/issues) ![GitHub code size in bytes](https://img.shields.io/github/languages/code-size/reyco1/release-notes) ![npm](https://img.shields.io/npm/dw/@reyco1/release-notes) ![npm](https://img.shields.io/npm/v/@reyco1/release-notes)
[![GitHub license](https://img.shields.io/github/license/reyco1/release-notes)](https://github.com/reyco1/release-notes/blob/main/LICENSE) [![GitHub issues](https://img.shields.io/github/issues/reyco1/release-notes)](https://github.com/reyco1/release-notes/issues) ![GitHub code size in bytes](https://img.shields.io/github/languages/code-size/reyco1/release-notes) ![npm](https://img.shields.io/npm/dw/@reyco1/release-notes) ![npm](https://img.shields.io/npm/v/@reyco1/release-notes) ![GitHub watchers](https://img.shields.io/github/watchers/reyco1/release-notes)



The Release Notes Generator is a command-line tool that automates the creation of professional release notes from Git commit logs. Leveraging OpenAI's powerful GPT-3.5 model, it efficiently converts raw commit data into a clean, structured format. This tool is ideal for project managers, developers, and teams looking to streamline their release documentation process.
Expand Down
57 changes: 11 additions & 46 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
#!/usr/bin/env node

import OpenAI from 'openai';
import { exec } from 'child_process';
import { writeFile, mkdir } from 'fs/promises';
import yargs from 'yargs';
import { hideBin } from 'yargs/helpers';
import { exec } from 'child_process';
import OpenAI from 'openai';
import yargs from 'yargs';
import fs from 'fs';

const prompt = fs.readFileSync('prompt.txt', 'utf8');
const apiKey = process.env.OPENAI_API_KEY;
const openai = new OpenAI({ apiKey });

const argv = yargs(hideBin(process.argv))
.option('since', {
Expand All @@ -29,14 +34,11 @@ const argv = yargs(hideBin(process.argv))
.alias('help', 'h')
.argv;

const apiKey = process.env.OPENAI_API_KEY;
if (!apiKey) {
console.error('Please set the OPENAI_API_KEY environment variable.');
process.exit(1);
}

const openai = new OpenAI({ apiKey });

const getCommitLogs = async (since, until) => {
console.log(`Fetching commit logs from ${since} to ${until}...`);
const command = `git log --since="${since}" --until="${until}" --pretty=format:"%ad - %s"`;
Expand All @@ -57,45 +59,7 @@ const generateReleaseNotes = async (commitLogs) => {
messages: [
{
role: "system",
content: `Steps to Format Git Commit Logs into Release Notes:
1. **Input Preparation:**
- User will provide all commit logs relevant for the release notes.
- Ensure each log entry follows the standard format: "(v[version number]) [Commit message]".
2. **Summary Creation:**
- Begin by summarizing the main achievements or features introduced in this batch of commits. Highlight any major enhancements, critical bug fixes, or significant performance improvements.
3. **Release Notes Formatting:**
- Group commits by their version number. Each group corresponds to a version release.
- For each version, sort the commit messages chronologically if dates are available, or maintain the order they were logged.
4. **Release Notes Template:**
- **Header:** Start with a heading for the Release Notes followed by the date range these notes cover (if applicable).
- **Summary:** Provide a brief, general summary of what this release encompasses. Highlight key features and improvements.
- **Detailed Changes:**
- For each version, create a subsection with the version number as the heading.
- List each commit message under its respective version heading. Remove any redundant information like author names, and ensure the focus is on what changed.
- Use bullet points for each commit message to improve readability.
5. **Consistency Check:**
- Ensure that the language is consistent throughout the document—use the same tense and voice.
- Check that formatting is uniform for each version subsection.
6. **Example Output Structure:**
Release Notes - [Date Range or 'As of [Latest Date]']
Summary:
This release brings significant user interface enhancements, improves performance, and fixes several critical bugs. Key updates include a revamped login screen and faster data processing.
Version 1.0.10:
- Updated the UI for easier use.
- Improved error handling in the data export feature.
Version 1.0.9:
- Enhanced security protocols for user authentication.
- Fixed memory leak issues observed in version 1.0.8.`,
content: prompt,
},
{
role: "user",
Expand All @@ -118,10 +82,11 @@ const saveToFile = async (releaseNotes, filePath) => {
};

const logs = await getCommitLogs(argv.since, argv.until);
// if there are not logs, throw a warning in red and exit

if (!logs) {
console.error('No logs found for the specified date range.');
process.exit(1);
}

const notes = await generateReleaseNotes(logs);
await saveToFile(notes, argv.output);
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@reyco1/release-notes",
"version": "1.0.0",
"version": "1.0.1",
"description": "Generates formatted release notes from Git commit logs using OpenAI's API.",
"main": "index.js",
"private": false,
Expand Down
39 changes: 39 additions & 0 deletions prompt.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
Steps to Format Git Commit Logs into Release Notes:

1. Input Preparation:
- User will provide all commit logs relevant for the release notes.
- Ensure each log entry follows the standard format: "(v[version number]) [Commit message]".

2. Summary Creation:
- Begin by summarizing the main achievements or features introduced in this batch of commits. Highlight any major enhancements, critical bug fixes, or significant performance improvements.

3. Release Notes Formatting:
- Group commits by their version number. Each group corresponds to a version release.
- For each version, sort the commit messages chronologically if dates are available, or maintain the order they were logged.

4. Release Notes Template:
- Header: Start with a heading for the Release Notes followed by the date range these notes cover (if applicable).
- Summary: Provide a brief, general summary of what this release encompasses. Highlight key features and improvements.
- Detailed Changes:
- For each version, create a subsection with the version number as the heading.
- List each commit message under its respective version heading. Remove any redundant information like author names, and ensure the focus is on what changed.
- Use bullet points for each commit message to improve readability.

5. Consistency Check:
- Ensure that the language is consistent throughout the document—use the same tense and voice.
- Check that formatting is uniform for each version subsection.

6. Example Output Structure:

Release Notes - [Date Range or 'As of [Latest Date]']

Summary:
This release brings significant user interface enhancements, improves performance, and fixes several critical bugs. Key updates include a revamped login screen and faster data processing.

Version 1.0.10:
- Updated the UI for easier use.
- Improved error handling in the data export feature.

Version 1.0.9:
- Enhanced security protocols for user authentication.
- Fixed memory leak issues observed in version 1.0.8.
2 changes: 1 addition & 1 deletion version.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"major": 1,
"minor": 0,
"patch": 0
"patch": 1
}

0 comments on commit 7d0434a

Please sign in to comment.