@@ -27,11 +27,45 @@ jobs:
27
27
filename : ' TravelWindowII-${{ github.event.inputs.tag }}.zip'
28
28
exclusions : ' *.git* *.github* *.vscode* *.gitignore* /*doc/* /*screenshots/*'
29
29
30
+ # parse changelog to set release description
31
+ - name : extract latest changelog entry
32
+ id : changelog
33
+ run : |
34
+ # Use ${{ github.workspace }} to get the full path to CHANGELOG.md
35
+ CHANGELOG_PATH="${{ github.workspace }}/TravelWindowII/CHANGELOG.md"
36
+
37
+ # Find the line number of the latest version header
38
+ LATEST_VERSION_LINE=$(grep -n "^## v" "$CHANGELOG_PATH" | head -n1 | cut -d: -f1)
39
+
40
+ # Find the line number of the next version header or EOF
41
+ NEXT_VERSION_LINE=$(tail -n +$((LATEST_VERSION_LINE + 1)) "$CHANGELOG_PATH" | grep -n "^## v" | head -n1 | cut -d: -f1)
42
+ if [ -z "$NEXT_VERSION_LINE" ]; then
43
+ NEXT_VERSION_LINE=$(wc -l < "$CHANGELOG_PATH")
44
+ else
45
+ NEXT_VERSION_LINE=$((LATEST_VERSION_LINE + NEXT_VERSION_LINE - 1))
46
+ fi
47
+
48
+ # Escape newlines and quote special characters for GitHub Actions
49
+ CHANGELOG_CONTENT="${CHANGELOG_CONTENT//'%'/'%25'}"
50
+ CHANGELOG_CONTENT="${CHANGELOG_CONTENT//$'\n'/'%0A'}"
51
+ CHANGELOG_CONTENT="${CHANGELOG_CONTENT//$'\r'/'%0D'}"
52
+
53
+ # Extract the content between these line numbers
54
+ CHANGELOG_CONTENT=$(sed -n "$((LATEST_VERSION_LINE+1)),$((NEXT_VERSION_LINE-1))p" "$CHANGELOG_PATH" | sed '/^\s*$/d')
55
+
56
+ # Set output for use in subsequent steps using heredoc to handle multiline output
57
+ EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)
58
+ echo "content<<$EOF" >> $GITHUB_OUTPUT
59
+ echo "$CHANGELOG_CONTENT" >> $GITHUB_OUTPUT
60
+ echo "$EOF" >> $GITHUB_OUTPUT
61
+
30
62
# create the GitHub release
31
63
- name : create github release
32
64
uses : softprops/action-gh-release@v2
33
65
with :
34
66
draft : true
35
67
prerelease : false
36
68
name : ${{ github.event.inputs.tag }}
69
+ tag_name : ${{ github.event.inputs.tag }}
70
+ body : ${{ steps.changelog.outputs.CONTENT }}
37
71
files : ' TravelWindowII-${{ github.event.inputs.tag }}.zip'
0 commit comments