name: Generate Release Notes on: push: tags: - "v*.*.*" workflow_dispatch: ~ jobs: generate-release-notes: runs-on: ubuntu-latest env: DASHSCOPE_API_KEY: ${{ secrets.HIGRESS_OPENAI_API_KEY }} MODEL_NAME: ${{ secrets.HIGRESS_OPENAI_API_MODEL }} MODEL_SERVER: ${{ secrets.MODEL_SERVER }} steps: - name: Checkout code uses: actions/checkout@v4 with: fetch-depth: 0 - name: Setup Go uses: actions/setup-go@v5 with: go-version: 1.24 - name: Clone GitHub MCP Server run: | git clone https://github.com/github/github-mcp-server.git cd github-mcp-server git checkout 5904a0365ec11f661ecea5c255e86860d279f3b1 go build -o ../github-mcp-serve ./cmd/github-mcp-server cd .. chmod u+x github-mcp-serve - name: Setup Python uses: actions/setup-python@v4 with: python-version: "3.10" - name: Clone Higress Report Agent run: | git clone https://github.com/higress-group/higress-report-agent.git mv github-mcp-serve higress-report-agent/ - name: Clean up old release notes run: | RELEASE_VERSION=$(cat ${GITHUB_WORKSPACE}/VERSION) CLEAN_VERSION=${RELEASE_VERSION#v} if [ -d "release-notes/${CLEAN_VERSION}" ]; then echo "Removing old release notes directory: release-notes/${CLEAN_VERSION}" rm -rf release-notes/${CLEAN_VERSION} else echo "No old release notes directory found for version ${CLEAN_VERSION}." fi - name: Create Release Report Script run: | cat > generate_release_report.sh << 'EOF' #!/bin/bash # Script to generate release notes for Higress projects echo "Fetching GitHub generated release notes for ${GITHUB_REPO_OWNER}/${GITHUB_REPO_NAME}..." curl -L \ "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%,} if [ -z "${PR_NUMS}" ]; then echo "No PR numbers found in release notes for ${GITHUB_REPO_OWNER}/${GITHUB_REPO_NAME} tag=${RELEASE_VERSION}." rm release_page.html exit 0 fi echo "Identifying important PRs..." IMPORTANT_PR_NUMS=$(cat release_page.html | grep -o ".*/${GITHUB_REPO_OWNER}/${GITHUB_REPO_NAME}/pull/[0-9]*.*" | grep -o "pull/[0-9]*" | grep -o "[0-9]*" | sort -n | uniq | tr '\n' ',') IMPORTANT_PR_NUMS=${IMPORTANT_PR_NUMS%,} rm release_page.html echo "Extracted PR numbers for ${GITHUB_REPO_OWNER}/${GITHUB_REPO_NAME}: ${PR_NUMS}" echo "Important PR numbers: ${IMPORTANT_PR_NUMS}" echo "Generating detailed release notes for ${GITHUB_REPO_OWNER}/${GITHUB_REPO_NAME}..." 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 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 cp report.md ../ cp report.EN.md ../ cd .. # 去除主库版本号前缀v,以主库版本号为路径 CLEAN_VERSION=${MAIN_RELEASE_VERSION#v} echo "Creating release notes directory for main version ${MAIN_RELEASE_VERSION}..." mkdir -p release-notes/${CLEAN_VERSION} echo "# ${REPORT_TITLE}" >>release-notes/${CLEAN_VERSION}/README_ZH.md sed 's/# Release Notes//' report.md >>release-notes/${CLEAN_VERSION}/README_ZH.md echo -e "\n" >>release-notes/${CLEAN_VERSION}/README_ZH.md echo "# ${REPORT_TITLE}" >>release-notes/${CLEAN_VERSION}/README.md sed 's/# Release Notes//' report.EN.md >>release-notes/${CLEAN_VERSION}/README.md echo -e "\n" >>release-notes/${CLEAN_VERSION}/README.md rm report.md rm report.EN.md echo "${REPORT_TITLE} release notes saved to release-notes/${CLEAN_VERSION}/" EOF chmod +x generate_release_report.sh - name: Generate Release Notes for Higress env: GITHUB_REPO_OWNER: alibaba GITHUB_REPO_NAME: higress GITHUB_PERSONAL_ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }} REPORT_TITLE: Higress run: | export MAIN_RELEASE_VERSION=$(cat ${GITHUB_WORKSPACE}/VERSION) export RELEASE_VERSION=$(cat ${GITHUB_WORKSPACE}/VERSION) bash generate_release_report.sh - name: Generate Release Notes for Higress Console env: GITHUB_REPO_OWNER: higress-group GITHUB_REPO_NAME: higress-console GITHUB_PERSONAL_ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }} REPORT_TITLE: Higress Console run: | export MAIN_RELEASE_VERSION=$(cat ${GITHUB_WORKSPACE}/VERSION) export RELEASE_VERSION=$(grep "^higress-console:" ${GITHUB_WORKSPACE}/DEP_VERSION | head -n1 | sed 's/higress-console: //') bash generate_release_report.sh - name: Create Update Release Notes Script run: | cat > update_release_note.sh << 'EOF' #!/bin/bash CLEAN_VERSION=${RELEASE_VERSION#v} RELEASE_INFO=$(curl -s -L \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer ${GITHUB_TOKEN}" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/repos/${GITHUB_REPO_OWNER}/${GITHUB_REPO_NAME}/releases/tags/${RELEASE_VERSION}) RELEASE_ID=$(echo $RELEASE_INFO | jq -r .id) RELEASE_BODY=$(echo $RELEASE_INFO | jq -r .body) NEW_CONTRIBUTORS=$(echo "$RELEASE_BODY" | awk '/## New Contributors/{flag=1; next} /\*\*Full Changelog\*\*/{flag=0} flag' | sed 's/\\n/\n/g') FULL_CHANGELOG=$(echo "$RELEASE_BODY" | awk '/\*\*Full Changelog\*\*:/{print $0}' | sed 's/\*\*Full Changelog\*\*: //g' | sed 's/\\n/\n/g') RELEASE_NOTES=$(cat release-notes/${CLEAN_VERSION}/README.md | sed 's/# /## /g') if [[ -n "$NEW_CONTRIBUTORS" ]]; then RELEASE_NOTES="${RELEASE_NOTES} ## New Contributors ${NEW_CONTRIBUTORS}" fi if [[ -n "$FULL_CHANGELOG" ]]; then RELEASE_NOTES="${RELEASE_NOTES} **Full Changelog**: ${FULL_CHANGELOG}" fi JSON_DATA=$(jq -n \ --arg body "$RELEASE_NOTES" \ '{body: $body}') curl -L \ -X PATCH \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer ${GITHUB_TOKEN}" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/repos/${GITHUB_REPO_OWNER}/${GITHUB_REPO_NAME}/releases/${RELEASE_ID} \ -d "$JSON_DATA" EOF chmod +x update_release_note.sh - name: Update Release Notes env: GITHUB_REPO_OWNER: alibaba GITHUB_REPO_NAME: higress GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | export RELEASE_VERSION=$(cat ${GITHUB_WORKSPACE}/VERSION) bash update_release_note.sh - name: Clean run: | rm generate_release_report.sh rm update_release_note.sh rm -rf higress-report-agent rm -rf github-mcp-server - name: Create Pull Request uses: peter-evans/create-pull-request@v7 with: token: ${{ secrets.GITHUB_TOKEN }} commit-message: "Add release notes" branch: add-release-notes title: "Add release notes" body: | This PR adds release notes. - Automatically generated by GitHub Actions labels: release notes, automated base: main