diff --git a/.github/scripts/ai-release-notes.sh b/.github/scripts/ai-release-notes.sh new file mode 100755 index 00000000..b2c06052 --- /dev/null +++ b/.github/scripts/ai-release-notes.sh @@ -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 < +... + + +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<> $GITHUB_OUTPUT +echo "$conv_response_text" >> $GITHUB_OUTPUT +echo "EOF" >> $GITHUB_OUTPUT diff --git a/.github/workflows/build-release.yml b/.github/workflows/build-release.yml index 7a7b916c..7744291b 100644 --- a/.github/workflows/build-release.yml +++ b/.github/workflows/build-release.yml @@ -60,8 +60,19 @@ jobs: fi echo "changelog<> $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 @@ -77,7 +88,7 @@ jobs: tag_name: "v${{ inputs.version }}" body: | ### Major Changes - * ... + ${{ steps.ai_release_notes.outputs.release_notes }}
Full changelog