-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
meta: Add workflow that generates changelogs from patch notes
- Loading branch information
1 parent
b9a181c
commit d77ca5c
Showing
2 changed files
with
81 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#!/bin/bash | ||
sdk=$1 | ||
sdkname=$2 | ||
openAIApiKey=$3 | ||
|
||
latestRelease=$(curl -s -X GET "https://api.github.com/repos/lootlocker/$sdk/releases/latest") | ||
|
||
version=$(echo "$latestRelease" | jq .tag_name) | ||
version=${version//\"/} | ||
patchnotes=$(echo "$latestRelease" | jq .body) | ||
patchnotes=${patchnotes//\\r\\n/\\n} | ||
|
||
prompt="Condense these patch notes (but dont mention the version number) to a short message (max 255 character) naming the important changes and crucial information in a helpful, informative, but punchy way: $patchnotes" | ||
prompt=${prompt//\"/} | ||
body='{ | ||
"model": "gpt-4o-mini", | ||
"messages": [ | ||
{ | ||
"role": "system", | ||
"content": "You are the chief tech communicator of LootLocker and a marketing Genius" | ||
}, | ||
{ | ||
"role": "user", | ||
"content": "'$prompt'" | ||
} | ||
] | ||
}' | ||
|
||
jsonResponse=$(curl -s "https://api.openai.com/v1/chat/completions" \ | ||
-H "Content-Type: application/json" \ | ||
-H "Authorization: Bearer $openAIApiKey" \ | ||
-d "$body") | ||
|
||
shortPatchNotes=$(echo "$jsonResponse" | jq .choices[0].message.content) | ||
shortPatchNotes=${shortPatchNotes//\"/} | ||
|
||
filename="$sdk-$version" | ||
filename=${filename//./-} | ||
filename="$filename.md" | ||
echo "---" > $filename | ||
echo "title: \"$sdkname $version\"" >> $filename | ||
echo "author: Erik Bylund" >> $filename | ||
dt=`date '+%Y-%m-%dT%H:%M:%SZ'` | ||
echo "date: $dt" >> $filename | ||
echo "---" >> $filename | ||
|
||
echo "" >> $filename | ||
|
||
echo "**🎉 $sdkname $version is released 🎉**" >> $filename | ||
echo "$shortPatchNotes" >> $filename | ||
echo "" >> $filename | ||
echo "[Find it here](https://github.com/lootlocker/$sdk/releases/tag/$version)" >> $filename |
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,29 @@ | ||
name: Generate changelog from release | ||
run-name: generate-changelog | ||
on: | ||
release: | ||
types: [published] | ||
workflow_dispatch: {} | ||
|
||
jobs: | ||
generate-changelog: | ||
name: Generate changelog from release | ||
runs-on: [ubuntu-latest] | ||
steps: | ||
- name: Install jq | ||
run: | | ||
sudo apt install jq | ||
- name: Checkout this repository | ||
uses: actions/checkout@v4 | ||
with: | ||
path: ./sdk | ||
- name: Generate changelog from latest release | ||
run: | | ||
./sdk/.github/scripts/generate-changelog.sh unreal-server-sdk "Unreal Server SDK" "${{ SECRETS.OPEN_AI_API_KEY }}" | ||
- name: Cat changelog so you can get it without downloading | ||
run: cat ./*.md | ||
- name: Expose changelog | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: changelog | ||
path: ./*.md |