-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from emanuel-braz/gpt-release-body
feat: add enhanced release notes feature
- Loading branch information
Showing
20 changed files
with
803 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
name: Generate Enhanced Release Notes | ||
run-name: Action started by ${{ github.actor }} | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
tagName: | ||
description: 'Tag of the release.' | ||
required: true | ||
type: string | ||
|
||
jobs: | ||
print_enhanced_release_notes: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Generate Release Notes | ||
id: release_notes | ||
uses: ./generate-enhanced-notes | ||
with: | ||
token: "${{ secrets.GITHUB_TOKEN }}" | ||
tag_name: ${{ github.event.inputs.tagName }} | ||
openai_key: "${{ secrets.OPENAI_KEY }}" | ||
use_previous_tag_latest_release: true | ||
verbose: true | ||
|
||
- name: Print Release Notes (Use it as you want) | ||
run: echo "${{ steps.release_notes.outputs.enhanced_notes }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
node_modules | ||
node_modules | ||
.vscode/settings.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
### Generate Enhanced Notes | ||
First create a secret in your repository called `OPENAI_KEY` with your OpenAI API key. | ||
https://platform.openai.com/account/api-keys | ||
|
||
Then create a workflow file (e.g. `.github/workflows/release_notes.yml`) with the following content: | ||
|
||
```yaml | ||
name: Generate Enhanced Release Notes | ||
run-name: Action started by ${{ github.actor }} | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
tagName: | ||
description: 'Tag of the release.' | ||
required: true | ||
type: string | ||
|
||
jobs: | ||
print_enhanced_release_notes: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Generate Release Notes | ||
id: release_notes | ||
uses: ./generate-enhanced-notes | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
tag_name: ${{ github.event.inputs.tagName }} | ||
openai_key: ${{ secrets.OPENAI_KEY }} | ||
use_previous_tag_latest_release: true | ||
verbose: true | ||
|
||
- name: Print Release Notes (Use it as you want) | ||
run: echo "${{ steps.release_notes.outputs.enhanced_notes }}" | ||
``` | ||
### Inputs (FILTERS) | ||
#### tag_name | ||
**Required** The name of the tag. | ||
#### token | ||
**Required** The token to use to create the release. Use `"${{ secrets.GITHUB_TOKEN }}"`. | ||
#### openai_key | ||
**Required** The key to use to generate the release notes. Use `"${{ secrets.OPENAI_KEY }}"`. | ||
#### previous_tag_name | ||
**Optional** The name of the previous tag. if "usePreviousTagLatestRelease" is true, this is ignored. | ||
#### use_previous_tag_latest_release | ||
**Optional** Whether to use the latest release of the previous tag to generate the release notes. Default `false`. | ||
|
||
#### verbose | ||
**Optional** Whether to print verbose output. Default `false`. | ||
|
||
## TODO | ||
- [ ] Add support for multiple languages | ||
- [ ] Add support for multiple models |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
const GenerateEnhancedNotes = require('./generate_enhanced_notes.js'); | ||
|
||
(async () => { | ||
await new GenerateEnhancedNotes().call(); | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
name: emanuel-braz/generate-enhanced-notes | ||
description: Generate release notes using OpenAI's GPT-3.5-turbo | ||
author: Emanuel Braz | ||
branding: | ||
icon: send | ||
color: gray-dark | ||
inputs: | ||
tag_name: | ||
description: The name of the tag of the release. | ||
required: true | ||
token: | ||
description: The token to use to create the release. Use `"${{ secrets.GITHUB_TOKEN }}"`. | ||
required: true | ||
openai_key: | ||
description: The key to use to generate the release notes. Use `"${{ secrets.OPENAI_KEY }}"`. | ||
required: true | ||
previous_tag_name: | ||
description: The name of the previous tag. if "usePreviousTagLatestRelease" is true, this is ignored. | ||
required: false | ||
use_previous_tag_latest_release: | ||
description: Whether to use the latest release of the previous tag to generate the release notes. Default `false`. | ||
required: false | ||
verbose: | ||
description: Whether to print verbose output. Default `false`. | ||
required: false | ||
|
||
outputs: | ||
enhanced_notes: | ||
description: The generated release notes. | ||
|
||
runs: | ||
using: node16 | ||
main: ./action.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
require('child_process') | ||
.execSync( | ||
'npm install @actions/core @actions/github', | ||
{ cwd: __dirname } | ||
); | ||
|
||
const core = require('@actions/core'); | ||
const github = require('@actions/github'); | ||
const { Logger } = require('../utils/logger.js'); | ||
|
||
const GitHubService = require('../services/github_service.js'); | ||
const GptService = require('../services/gpt_service.js'); | ||
|
||
class GenerateEnhancedNotes { | ||
|
||
async call({ tagName, previousTagName, token, openaiKey, usePreviousTagLatestRelease, owner, repo, verbose }) { | ||
|
||
tagName = tagName || core.getInput('tag_name'); | ||
previousTagName = previousTagName || core.getInput('previous_tag_name'); | ||
token = token || core.getInput('token'); | ||
openaiKey = openaiKey || core.getInput('openai_key'); | ||
usePreviousTagLatestRelease = usePreviousTagLatestRelease || core.getInput('use_previous_tag_latest_release') == 'true'; | ||
verbose = verbose || core.getInput('verbose') == 'true'; | ||
owner = owner || github.context.repo.owner | ||
repo = repo || github.context.repo.repo | ||
|
||
const api = github.getOctokit(core.getInput('token')); | ||
const logger = new Logger(verbose, core); | ||
|
||
if (usePreviousTagLatestRelease) { | ||
var latestRelease = await api.repos.getLatestRelease({ | ||
...github.context.repo | ||
}); | ||
previousTagName = latestRelease.data.tag_name; | ||
} | ||
|
||
const githubService = new GitHubService(token, owner, repo); | ||
var releasenotes = await githubService.generateReleaseNotes(tagName, previousTagName); | ||
logger.log(`RELEASE NOTES:\n\n${releasenotes}`); | ||
|
||
const gptService = new GptService(openaiKey); | ||
var enhancedNotes = await gptService.generateReleaseNotes(releasenotes); | ||
logger.log(`ENHANCED RELEASE NOTES:\n\n${enhancedNotes}`); | ||
|
||
core.setOutput('enhanced_notes', enhancedNotes); | ||
return enhancedNotes; | ||
} | ||
} | ||
|
||
module.exports = GenerateEnhancedNotes; |
Oops, something went wrong.