|
11 | 11 |
|
12 | 12 | steps: |
13 | 13 | - uses: actions/checkout@v4 |
| 14 | + with: |
| 15 | + fetch-depth: 0 # full history for changelog generation |
14 | 16 |
|
15 | 17 | - name: Set up Python |
16 | 18 | uses: actions/setup-python@v5 |
@@ -59,16 +61,100 @@ jobs: |
59 | 61 | name: source-archive |
60 | 62 | path: ${{ env.ARCHIVE }} |
61 | 63 |
|
| 64 | + - name: Extract changelog for this version |
| 65 | + id: changelog |
| 66 | + run: | |
| 67 | + VERSION=$(grep '"version"' library.json | sed -E 's/.*"version" *: *"([^"]+)".*/\1/') |
| 68 | + echo "version=${VERSION}" >> "$GITHUB_OUTPUT" |
| 69 | +
|
| 70 | + # Extract the section for this version from CHANGELOG.md |
| 71 | + # Matches everything between "## [X.Y.Z]" and the next "## [" heading |
| 72 | + NOTES="" |
| 73 | + if [[ -f CHANGELOG.md ]]; then |
| 74 | + NOTES=$(awk -v ver="${VERSION}" ' |
| 75 | + BEGIN { found=0 } |
| 76 | + /^## \[/ { |
| 77 | + if (found) exit |
| 78 | + if ($0 ~ "\\[" ver "\\]") { found=1; next } |
| 79 | + } |
| 80 | + found { print } |
| 81 | + ' CHANGELOG.md) |
| 82 | + fi |
| 83 | +
|
| 84 | + if [[ -z "${NOTES}" ]]; then |
| 85 | + echo "No CHANGELOG entry found for ${VERSION}, generating from commits..." |
| 86 | + # Get the previous tag |
| 87 | + PREV_TAG=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || echo "") |
| 88 | + if [[ -n "${PREV_TAG}" ]]; then |
| 89 | + NOTES=$(git log "${PREV_TAG}..HEAD" --pretty=format:"- %s (%h)" --no-merges) |
| 90 | + else |
| 91 | + NOTES=$(git log --pretty=format:"- %s (%h)" --no-merges -20) |
| 92 | + fi |
| 93 | + fi |
| 94 | +
|
| 95 | + # Write to file to preserve multiline |
| 96 | + echo "${NOTES}" > /tmp/release_notes.md |
| 97 | +
|
| 98 | + - name: Generate AI-style release summary |
| 99 | + id: summary |
| 100 | + run: | |
| 101 | + VERSION="${{ steps.changelog.outputs.version }}" |
| 102 | + PREV_TAG=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || echo "") |
| 103 | +
|
| 104 | + # Build a structured release body |
| 105 | + { |
| 106 | + echo "# ESPAsyncWebClient v${VERSION}" |
| 107 | + echo "" |
| 108 | +
|
| 109 | + # Changelog section |
| 110 | + echo "## What's Changed" |
| 111 | + cat /tmp/release_notes.md |
| 112 | + echo "" |
| 113 | +
|
| 114 | + # Auto-generated commit summary by category |
| 115 | + if [[ -n "${PREV_TAG}" ]]; then |
| 116 | + echo "## Commit Summary" |
| 117 | + echo "" |
| 118 | +
|
| 119 | + # Fixes |
| 120 | + FIXES=$(git log "${PREV_TAG}..HEAD" --pretty=format:"- %s (%h)" --no-merges --grep="^[Ff]ix" || true) |
| 121 | + if [[ -n "${FIXES}" ]]; then |
| 122 | + echo "### Bug Fixes" |
| 123 | + echo "${FIXES}" |
| 124 | + echo "" |
| 125 | + fi |
| 126 | +
|
| 127 | + # Features |
| 128 | + FEATURES=$(git log "${PREV_TAG}..HEAD" --pretty=format:"- %s (%h)" --no-merges --grep="^[Ff]eat" || true) |
| 129 | + if [[ -n "${FEATURES}" ]]; then |
| 130 | + echo "### New Features" |
| 131 | + echo "${FEATURES}" |
| 132 | + echo "" |
| 133 | + fi |
| 134 | +
|
| 135 | + # Other commits |
| 136 | + OTHER=$(git log "${PREV_TAG}..HEAD" --pretty=format:"- %s (%h)" --no-merges --invert-grep --grep="^[Ff]ix" --grep="^[Ff]eat" || true) |
| 137 | + if [[ -n "${OTHER}" ]]; then |
| 138 | + echo "### Other Changes" |
| 139 | + echo "${OTHER}" |
| 140 | + echo "" |
| 141 | + fi |
| 142 | +
|
| 143 | + echo "**Full diff**: https://github.com/${{ github.repository }}/compare/${PREV_TAG}...v${VERSION}" |
| 144 | + echo "" |
| 145 | + fi |
| 146 | +
|
| 147 | + # Stats |
| 148 | + echo "## Verification" |
| 149 | + echo "- :white_check_mark: All examples built successfully" |
| 150 | + echo "- :white_check_mark: Version metadata consistent across library.json, library.properties, and HttpCommon.h" |
| 151 | + echo "- :package: Source archive attached" |
| 152 | + } > /tmp/full_release_notes.md |
| 153 | +
|
62 | 154 | - name: Create Release |
63 | 155 | uses: softprops/action-gh-release@v2 |
64 | 156 | with: |
65 | 157 | files: ${{ env.ARCHIVE }} |
66 | | - name: Release ${{ github.ref }} |
67 | | - body: | |
68 | | - ## Changes in this release |
69 | | - See the Git diff for this tag or the Releases page for details. |
70 | | - |
71 | | - ## Verification |
72 | | - - Examples built successfully |
73 | | - - Version metadata consistent |
74 | | - - Source archive attached |
| 158 | + name: "v${{ steps.changelog.outputs.version }}" |
| 159 | + body_path: /tmp/full_release_notes.md |
| 160 | + generate_release_notes: true |
0 commit comments