Skip to content
Merged
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
38 changes: 38 additions & 0 deletions .github/scripts/ai-release-notes.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/bin/bash

# Sanitize the changelog by escaping backticks to prevent command execution
changelog_safe="${1//\`/\\\`}"

previous_release_notes=$(curl -s https://api.github.com/repos/$GITHUB_REPOSITORY/releases | jq -c '.[0:8][] | {"body": .body, "name": .name}')

conv=$(cat <<EOF
You are a helpful assistant that generates release notes for a software project.
You will be given a changelog and you will need to generate release notes for the following changelog:
$changelog_safe

The release notes will be embedded in the following format:
### Major Changes
{{ AI RESPONSE }}

<details>
...
</details>

Avoid long release notes. Keep it short and concise, a few bullet points (max 5-6). Use markdown formatting if needed.
Do NOT respond with suggestions! The response will be processed programmatically and embedded in the release notes.
Do NOT include the details tag or content in the response. Do NOT include the Major Changes header in the response.

Previous release notes:
$previous_release_notes
EOF
)

conv_json=$(echo "$conv" | jq -R -s '{"model": "'"$OPENROUTER_MODEL"'", "messages": [{"role": "user", "content": .}]}')
conv_response=$(curl -X POST -H "Authorization: Bearer $OPENROUTER_TOKEN" -H "Content-Type: application/json" -d "$conv_json" https://openrouter.ai/api/v1/chat/completions)
echo "$conv_response"

conv_response_text=$(echo "$conv_response" | jq -r '.choices[0].message.content')

echo "release_notes<<EOF" >> $GITHUB_OUTPUT
echo "$conv_response_text" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
13 changes: 12 additions & 1 deletion .github/workflows/build-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,19 @@ jobs:
fi
echo "changelog<<EOF" >> $GITHUB_OUTPUT
echo " - ${changelog//$'\n'/$'\n' - }" >> $GITHUB_OUTPUT
echo " - ${changelog//$'\n'/$'\n' - }" >> ./generated_changelog.txt
echo "EOF" >> $GITHUB_OUTPUT

- name: "Generate AI release notes"
id: ai_release_notes
run: |
./.github/scripts/ai-release-notes.sh "$(cat ./generated_changelog.txt)"
env:
OPENROUTER_MODEL: ${{ vars.OPENROUTER_MODEL }}
OPENROUTER_TOKEN: ${{ secrets.OPENROUTER_TOKEN }}
GITHUB_TOKEN: ${{ github.token }}
GITHUB_REPOSITORY: ${{ github.repository }}

# download build artifacts
- name: "Download build artifacts"
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
Expand All @@ -77,7 +88,7 @@ jobs:
tag_name: "v${{ inputs.version }}"
body: |
### Major Changes
* ...
${{ steps.ai_release_notes.outputs.release_notes }}

<details>
<summary>Full changelog</summary>
Expand Down