Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

meta: Add workflow that generates changelogs from patch notes #82

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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-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
Loading