mirror of
https://github.com/zhom/donutbrowser.git
synced 2026-08-27 21:30:23 +02:00
chore: make telegram releases ai-generated
This commit is contained in:
@@ -0,0 +1,23 @@
|
|||||||
|
messages:
|
||||||
|
- role: system
|
||||||
|
content: |-
|
||||||
|
You write short, friendly release summaries for Donut Browser, an anti-detect browser desktop app built with Tauri and Next.js.
|
||||||
|
|
||||||
|
Rules:
|
||||||
|
- Keep it minimal and friendly. No marketing voice, no filler, no superlatives.
|
||||||
|
- No emojis or pictographic symbols.
|
||||||
|
- Plain ASCII punctuation only. No em-dashes, en-dashes, ellipses, smart quotes, or any non-ASCII characters. Use a regular hyphen, three dots, or straight quotes instead.
|
||||||
|
- Plain text only. No markdown (no asterisks for bold, no backticks for code, no headings), no HTML tags.
|
||||||
|
- Focus on user-visible changes. Skip chore, docs-only, CI, test, dependency, formatting, and purely internal refactor commits unless they have user-visible impact.
|
||||||
|
- Group related commits into a single bullet when it reads better.
|
||||||
|
- Use simple, direct language.
|
||||||
|
- Do not include the version number, download links, or a heading. The surrounding message already has those.
|
||||||
|
- If nothing in the commits is user-visible, output exactly one bullet: "- Small fixes and internal improvements."
|
||||||
|
- role: user
|
||||||
|
content: |-
|
||||||
|
Write the summary for Donut Browser {{version}} from these commits:
|
||||||
|
|
||||||
|
{{commits}}
|
||||||
|
|
||||||
|
Format: one short opening sentence, a blank line, then bullets starting with "- " (one per line). Nothing else.
|
||||||
|
model: openai/gpt-4.1
|
||||||
@@ -22,6 +22,7 @@ on:
|
|||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
contents: read
|
contents: read
|
||||||
|
models: read
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
notify:
|
notify:
|
||||||
@@ -105,21 +106,12 @@ jobs:
|
|||||||
fi
|
fi
|
||||||
echo "skip=false" >> "$GITHUB_OUTPUT"
|
echo "skip=false" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
- name: Post release announcement to Telegram
|
- name: Collect commits between previous tag and current tag
|
||||||
|
id: commits
|
||||||
if: steps.gate.outputs.skip != 'true'
|
if: steps.gate.outputs.skip != 'true'
|
||||||
env:
|
env:
|
||||||
TELEGRAM_BOT_TOKEN: ${{ secrets.TELEGRAM_BOT_TOKEN }}
|
|
||||||
TELEGRAM_CHAT_ID: ${{ secrets.TELEGRAM_CHAT_ID }}
|
|
||||||
TAG: ${{ steps.tag.outputs.tag }}
|
TAG: ${{ steps.tag.outputs.tag }}
|
||||||
REPO: ${{ github.repository }}
|
|
||||||
run: |
|
run: |
|
||||||
if [ -z "$TELEGRAM_BOT_TOKEN" ] || [ -z "$TELEGRAM_CHAT_ID" ]; then
|
|
||||||
echo "::warning::TELEGRAM_BOT_TOKEN or TELEGRAM_CHAT_ID is not set — skipping Telegram notification."
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Find the previous stable tag (skip the current one) so the
|
|
||||||
# changelog range is well-defined.
|
|
||||||
PREV_TAG=$(git tag --sort=-version:refname \
|
PREV_TAG=$(git tag --sort=-version:refname \
|
||||||
| grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' \
|
| grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' \
|
||||||
| grep -v "^${TAG}$" \
|
| grep -v "^${TAG}$" \
|
||||||
@@ -127,29 +119,52 @@ jobs:
|
|||||||
if [ -z "$PREV_TAG" ]; then
|
if [ -z "$PREV_TAG" ]; then
|
||||||
PREV_TAG=$(git rev-list --max-parents=0 HEAD)
|
PREV_TAG=$(git rev-list --max-parents=0 HEAD)
|
||||||
fi
|
fi
|
||||||
|
git log --pretty=format:"- %s (%h)" "${PREV_TAG}..${TAG}" --no-merges > commits.txt
|
||||||
|
echo "previous-tag=${PREV_TAG}" >> "$GITHUB_OUTPUT"
|
||||||
|
echo "Collected $(wc -l < commits.txt) commits between ${PREV_TAG} and ${TAG}."
|
||||||
|
|
||||||
strip_prefix() { echo "$1" | sed -E 's/^[a-z]+(\([^)]*\))?: //'; }
|
- name: Generate summary with AI
|
||||||
|
id: ai
|
||||||
|
if: steps.gate.outputs.skip != 'true'
|
||||||
|
uses: actions/ai-inference@17ff458cb182449bbb2e43701fcd98f6af8f6570 # v2.1.0
|
||||||
|
with:
|
||||||
|
prompt-file: .github/prompts/telegram-release-summary.prompt.yml
|
||||||
|
input: |
|
||||||
|
version: ${{ steps.tag.outputs.tag }}
|
||||||
|
file_input: |
|
||||||
|
commits: ./commits.txt
|
||||||
|
max-tokens: 1024
|
||||||
|
|
||||||
# Build a plain bullet list from feat / fix / refactor commits.
|
- name: Post release announcement to Telegram
|
||||||
# Other commit types (chore, docs, ci, test, deps) are intentionally
|
if: steps.gate.outputs.skip != 'true'
|
||||||
# filtered out to keep the channel focused on user-visible changes.
|
env:
|
||||||
CHANGES=""
|
TELEGRAM_BOT_TOKEN: ${{ secrets.TELEGRAM_BOT_TOKEN }}
|
||||||
while IFS= read -r msg; do
|
TELEGRAM_CHAT_ID: ${{ secrets.TELEGRAM_CHAT_ID }}
|
||||||
[ -z "$msg" ] && continue
|
TAG: ${{ steps.tag.outputs.tag }}
|
||||||
case "$msg" in
|
REPO: ${{ github.repository }}
|
||||||
feat\(*\):*|feat:*|fix\(*\):*|fix:*|refactor\(*\):*|refactor:*)
|
AI_RESPONSE_FILE: ${{ steps.ai.outputs.response-file }}
|
||||||
CHANGES="${CHANGES}• $(strip_prefix "$msg")"$'\n'
|
AI_RESPONSE: ${{ steps.ai.outputs.response }}
|
||||||
;;
|
run: |
|
||||||
esac
|
if [ -z "$TELEGRAM_BOT_TOKEN" ] || [ -z "$TELEGRAM_CHAT_ID" ]; then
|
||||||
done < <(git log --pretty=format:%s "${PREV_TAG}..${TAG}")
|
echo "::warning::TELEGRAM_BOT_TOKEN or TELEGRAM_CHAT_ID is not set — skipping Telegram notification."
|
||||||
|
exit 0
|
||||||
if [ -z "$CHANGES" ]; then
|
|
||||||
CHANGES="• See release notes."$'\n'
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# HTML-escape the changelog before injecting into Telegram HTML
|
# Prefer the file output — `response` can be truncated for longer summaries.
|
||||||
# mode — commit messages can legitimately contain `<`, `>`, `&`.
|
if [ -n "$AI_RESPONSE_FILE" ] && [ -f "$AI_RESPONSE_FILE" ]; then
|
||||||
ESCAPED_CHANGES=$(printf '%s' "$CHANGES" \
|
SUMMARY=$(cat "$AI_RESPONSE_FILE")
|
||||||
|
else
|
||||||
|
SUMMARY="$AI_RESPONSE"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "${SUMMARY//[[:space:]]/}" ]; then
|
||||||
|
echo "::error::AI summary is empty"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# HTML-escape the AI summary before injecting into Telegram HTML mode —
|
||||||
|
# commit messages can legitimately contain `<`, `>`, `&` and the AI may echo them.
|
||||||
|
ESCAPED_CHANGES=$(printf '%s' "$SUMMARY" \
|
||||||
| python3 -c "import html, sys; sys.stdout.write(html.escape(sys.stdin.read()))")
|
| python3 -c "import html, sys; sys.stdout.write(html.escape(sys.stdin.read()))")
|
||||||
|
|
||||||
VERSION="${TAG}"
|
VERSION="${TAG}"
|
||||||
|
|||||||
Reference in New Issue
Block a user