Repository navigation
76 lines (59 loc) · 3.41 KB
/
Copy pathrelease_notes.yml
File metadata and controls
76 lines (59 loc) · 3.41 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
# Uses OpenAI to summarise github's auto-generated release notes,
# Then update the release notes to contain the new summary
name: Update Release Notes
permissions:
contents: write
on:
release:
types:
- published
jobs:
get-release-notes:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Enhance release notes with LLM
id: enhance_notes
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
GH_TOKEN: ${{ github.token }}
RELEASE_BODY: ${{ github.event.release.body }}
run: |
echo "Release body:\n$RELEASE_BODY"
# Prepare the LLM API payload
payload=$(jq -n \
--arg model "gpt-4" \
--arg system_content "Follow the instructions to update the GitHub release notes provided below. The writing style should be simple, clear, and easy to read, yet it should follow these points: 1. Write a section titled \"TL;DR\" that describes everything contained in the \"What's Changed\" section. Provide a description of each change listed under the \"What's Changed\" section including a short description of why is this change beneficial to users and what good it brings. Make this \"TL;DR\" section informative and divide information into sections of related items; these section titles should include \"Changes to SQL\", \"Changes to Integrations\", \"Changes to Knowledge Bases\", \"Bug Fixes and Improvements\", \"Changes to Documentation\", unless a section does not have any items to be listed then do not list it. Do not mention any change authors in the \"TL;DR\" section. 2. The input comes in the Markdown format as below. Generate the output in the Markdown format as well. 3. Final format should adhere to the following: - start with the \"TL;DR\" section, which is a summary of the \"What's Changed\" section, - follow it with a new line containing \"---\" that separates the sections, - follow it with the \"What's Changed\" section, and DO NOT change the provided \"What's Changed\" section, - generate a Markdown format output that concatenates these two sections."\
--arg user_content "$RELEASE_BODY" \
'{
model: $model,
messages: [
{
role: "system",
content: $system_content
},
{
role: "user",
content: $user_content
}
]
}')
echo "Payload sent to OpenAI:\n$payload"
# Call the OpenAI API
response=$(curl -s -X POST https://api.openai.com/v1/chat/completions \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-H "Content-Type: application/json" \
-d "$payload")
echo "Raw response from OpenAI:\n$response"
# Extract enhanced notes from the API response
ENHANCED_NOTES=$(echo "$response" | jq -r '.choices[0].message.content // empty')
if [ -z "$ENHANCED_NOTES" ]; then
echo "LLM enhancement failed. Exiting."
exit 1
fi
echo "Enhanced release notes:\n$ENHANCED_NOTES"
# Write enhanced notes to a file
echo "$ENHANCED_NOTES" > enhanced_notes.md
# Update the release with the enhanced notes
gh release edit ${{ github.event.release.tag_name }} --notes-file enhanced_notes.md