From 905ec155e34a5e4d7d95c28adf126b11f0c08669 Mon Sep 17 00:00:00 2001 From: Minidoracat Date: Sun, 8 Jun 2025 03:59:04 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20=E4=BF=AE=E5=BE=A9=E8=87=AA?= =?UTF-8?q?=E5=8B=95=E7=99=BC=E4=BD=88=E6=B5=81=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/publish.yml | 37 ++++++++++++++++++++++++++++------- 1 file changed, 30 insertions(+), 7 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 4535b12..5b243e9 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -77,15 +77,36 @@ jobs: # Extract highlights from English CHANGELOG if [ -f "RELEASE_NOTES/CHANGELOG.en.md" ]; then - # Find the section for the new version and extract highlights - awk "/## \[${NEW_VERSION}\]/{flag=1; next} /## \[/{flag=0} flag && /### 🌟 Highlights/{getline; while(getline && !/^###/ && !/^##/) if(/^[^[:space:]]/ || /^- /) print}' RELEASE_NOTES/CHANGELOG.en.md > highlights.txt + echo "🔍 Extracting highlights for $NEW_VERSION from CHANGELOG..." - # If no highlights section found, extract from new features - if [ ! -s highlights.txt ]; then - awk "/## \[${NEW_VERSION}\]/{flag=1; next} /## \[/{flag=0} flag && /### ✨ New Features/{getline; while(getline && !/^###/ && !/^##/) if(/^- /) print}' RELEASE_NOTES/CHANGELOG.en.md | head -4 > highlights.txt + # Step 1: Find the version section and extract everything until next version + sed -n "/## \[${NEW_VERSION}\]/,/## \[/p" RELEASE_NOTES/CHANGELOG.en.md | head -n -1 > version_section.txt + + # Step 2: Try to extract highlights section + if grep -q "### 🌟 Highlights" version_section.txt; then + echo "📝 Found Highlights section" + sed -n '/### 🌟 Highlights/,/### /p' version_section.txt | head -n -1 | tail -n +2 | grep -E "^[^#]" | head -5 > highlights.txt + elif grep -q "### ✨ New Features" version_section.txt; then + echo "📝 Using New Features section as highlights" + sed -n '/### ✨ New Features/,/### /p' version_section.txt | head -n -1 | tail -n +2 | grep -E "^- " | head -4 > highlights.txt + else + echo "⚠️ No highlights or new features section found" + echo "" > highlights.txt fi - echo "✅ Extracted highlights for $NEW_VERSION" + # Clean up temporary file + rm -f version_section.txt + + # Check if we got any content + if [ -s highlights.txt ]; then + echo "✅ Successfully extracted highlights for $NEW_VERSION" + echo "📄 Content preview:" + head -2 highlights.txt + else + echo "⚠️ No highlights extracted, using default content" + echo "- 🚀 New features and improvements" > highlights.txt + echo "- 🐛 Bug fixes and optimizations" >> highlights.txt + fi else echo "⚠️ CHANGELOG.en.md not found, using default highlights" echo "- 🚀 New features and improvements" > highlights.txt @@ -98,7 +119,9 @@ jobs: NEW_VERSION="v${{ steps.bump_version.outputs.new }}" # Get release title from English CHANGELOG - RELEASE_TITLE=$(awk "/## \[${NEW_VERSION}\]/{print; exit}" RELEASE_NOTES/CHANGELOG.en.md | sed 's/## \[.*\] - //') + if [ -f "RELEASE_NOTES/CHANGELOG.en.md" ]; then + RELEASE_TITLE=$(grep "## \[${NEW_VERSION}\]" RELEASE_NOTES/CHANGELOG.en.md | head -1 | sed 's/## \[.*\] - //') + fi if [ -z "$RELEASE_TITLE" ]; then RELEASE_TITLE="Latest Release" fi