Skip to content

Commit

Permalink
meta: Add workflow that generates changelogs from patch notes
Browse files Browse the repository at this point in the history
  • Loading branch information
kirre-bylund committed Dec 18, 2024
1 parent 18c3c98 commit e850ff6
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 0 deletions.
52 changes: 52 additions & 0 deletions .github/scripts/generate-changelog.sh
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
29 changes: 29 additions & 0 deletions .github/workflows/generate-changelog.yml
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-sdk "Unreal 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

0 comments on commit e850ff6

Please sign in to comment.