Skip to content
Merged
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
53 changes: 50 additions & 3 deletions .github/workflows/generate-release-notes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,40 @@ jobs:
"https://github.com/${GITHUB_REPO_OWNER}/${GITHUB_REPO_NAME}/releases/tag/${RELEASE_VERSION}" \
-o release_page.html

# Extract system prompt content from HTML
echo "Extracting system prompt content..."
pip install beautifulsoup4 markdownify
SYSTEM_PROMPT=$(python3 -c "
import sys
from bs4 import BeautifulSoup
from markdownify import markdownify

with open('release_page.html', 'r') as f:
soup = BeautifulSoup(f, 'html.parser')

system_prompt_header = soup.find('h2', string='system prompt')
if system_prompt_header:
content = []
for sibling in system_prompt_header.next_siblings:
if sibling.name == 'h2':
break
content.append(str(sibling))
html_content = ''.join(content).strip()
# Convert HTML to Markdown
if html_content:
markdown_content = markdownify(html_content)
print(markdown_content.strip())
else:
print('')
else:
print('')
")
if [ -z "${SYSTEM_PROMPT}" ]; then
echo "No system prompt found in release notes."
else
echo "System prompt content: ${SYSTEM_PROMPT}"
fi

echo "Extracting PR numbers from ${GITHUB_REPO_OWNER}/${GITHUB_REPO_NAME} release notes..."
PR_NUMS=$(cat release_page.html | grep -o "/${GITHUB_REPO_OWNER}/${GITHUB_REPO_NAME}/pull/[0-9]*" | grep -o "[0-9]*$" | sort -n | uniq | tr '\n' ',')
PR_NUMS=${PR_NUMS%,}
Expand All @@ -88,11 +122,24 @@ jobs:
cd higress-report-agent
pip install uv
uv sync

# Build command
CMD_ARGS="--mode 2 --choice 2 --pr_nums ${PR_NUMS}"
if [ -n "${IMPORTANT_PR_NUMS}" ]; then
uv run report_main.py --mode 2 --choice 2 --pr_nums ${PR_NUMS} --important_prs ${IMPORTANT_PR_NUMS}
else
uv run report_main.py --mode 2 --choice 2 --pr_nums ${PR_NUMS}
CMD_ARGS="${CMD_ARGS} --important_prs ${IMPORTANT_PR_NUMS}"
fi
if [ -n "${SYSTEM_PROMPT}" ]; then
echo "${SYSTEM_PROMPT}" > temp_system_prompt.txt
CMD_ARGS="${CMD_ARGS} --sys_prompt_file temp_system_prompt.txt"
fi

uv run report_main.py ${CMD_ARGS}

# Clean up temporary file
if [ -f "temp_system_prompt.txt" ]; then
rm temp_system_prompt.txt
fi
Comment on lines +138 to +141
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

应确保在所有退出路径上都清理临时文件,以防止残留文件占用磁盘空间。

🟢 Minor | 🧹 Code Smells

📋 问题详情

目前只在脚本正常执行完毕后清理临时文件temp_system_prompt.txt。如果脚本在执行过程中因错误而提前退出,临时文件将不会被清理,从而占用磁盘空间。为了确保临时文件总是被清理,应该使用trap命令在脚本退出时自动清理临时文件。

💡 解决方案

使用trap命令在脚本退出时自动清理临时文件。

-          # Clean up temporary file
-          if [ -f "temp_system_prompt.txt" ]; then
-              rm temp_system_prompt.txt
-          fi
+          # Set trap to clean up temporary file on exit
+          trap 'if [ -f "temp_system_prompt.txt" ]; then rm temp_system_prompt.txt; fi' EXIT


<!-- Suggestion code flag -->




---

> 您的反馈对我们很重要!(建议右键在新标签页中打开以下链接)

  [有用意见👍](https://ap-southeast-1.lingma-agents-api.aliyuncs.com/v1/code-platform/sessions/s-d392en4uo6cafirdek3g/feedback?suggestion_id=sg-74a0788a7ef2&feedback_type=helpful) | [无用意见👎](https://ap-southeast-1.lingma-agents-api.aliyuncs.com/v1/code-platform/sessions/s-d392en4uo6cafirdek3g/feedback?suggestion_id=sg-74a0788a7ef2&feedback_type=neutral) | [错误意见❌](https://ap-southeast-1.lingma-agents-api.aliyuncs.com/v1/code-platform/sessions/s-d392en4uo6cafirdek3g/feedback?suggestion_id=sg-74a0788a7ef2&feedback_type=misleading)



<!-- This is an auto-generated comment by LingmaAgent -->


cp report.md ../
cp report.EN.md ../
cd ..
Expand Down