From 86927b4cfcef2143d18889ee436233a0ab0e3023 Mon Sep 17 00:00:00 2001 From: Tommy Chow Date: Tue, 6 Jan 2026 21:25:18 -0500 Subject: [PATCH] add release notes extraction for GitHub draft releases --- .github/workflows/gh-release.yml | 47 ++++++++++++++++++++++++++++++-- 1 file changed, 45 insertions(+), 2 deletions(-) diff --git a/.github/workflows/gh-release.yml b/.github/workflows/gh-release.yml index ee9a2edd..1846001d 100644 --- a/.github/workflows/gh-release.yml +++ b/.github/workflows/gh-release.yml @@ -51,11 +51,54 @@ jobs: run: | flutter build apk --dart-define CLIENT_ID=$CLIENT_ID --dart-define SECRET=$SECRET mv build/app/outputs/flutter-apk/app-release.apk frosty-${{ github.ref_name }}.apk - + + # Extract release notes from assets/release-notes.md for the current version. + - name: Extract release notes + id: release_notes + run: | + VERSION="${{ github.ref_name }}" + RELEASE_NOTES_FILE="assets/release-notes.md" + + # Extract the section for this version using awk + # Starts at "## vX.X.X", skips date line, stops at next "---" or "## v" header + NOTES=$(awk -v version="$VERSION" ' + BEGIN { found=0; output="" } + $0 ~ "^## " version "$" { found=1; next } + found && /^[A-Z][a-z]+ [0-9]+, [0-9]+$/ { next } + found && /^---$/ { exit } + found && /^## v[0-9]+\.[0-9]+\.[0-9]+$/ { exit } + found { output = output $0 "\n" } + END { print output } + ' "$RELEASE_NOTES_FILE") + + # Clean up "on GitHub" suffix (redundant since we're on GitHub) + NOTES=$(echo "$NOTES" | sed 's/ on GitHub)/)/') + + # Trim leading/trailing whitespace + NOTES=$(echo "$NOTES" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//') + + if [ -n "$NOTES" ]; then + # Get the previous tag for the Full Changelog link + PREV_TAG=$(git describe --tags --abbrev=0 "$VERSION^" 2>/dev/null || echo "") + + echo "found=true" >> $GITHUB_OUTPUT + echo "body<> $GITHUB_OUTPUT + echo "$NOTES" >> $GITHUB_OUTPUT + if [ -n "$PREV_TAG" ]; then + echo "" >> $GITHUB_OUTPUT + echo "**Full Changelog**: https://github.com/${{ github.repository }}/compare/${PREV_TAG}...${VERSION}" >> $GITHUB_OUTPUT + fi + echo "EOF" >> $GITHUB_OUTPUT + else + echo "found=false" >> $GITHUB_OUTPUT + echo "::warning::No release notes found for $VERSION in $RELEASE_NOTES_FILE" + fi + # Create a draft release on GitHub. - name: Release uses: softprops/action-gh-release@v2 with: draft: true - generate_release_notes: true + generate_release_notes: ${{ steps.release_notes.outputs.found != 'true' }} + body: ${{ steps.release_notes.outputs.found == 'true' && steps.release_notes.outputs.body || '' }} files: frosty-${{ github.ref_name }}.apk