Skip to content

Commit 50793d3

Browse files
committed
release description generation with GitHub actions
1 parent 33e1f87 commit 50793d3

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

.github/workflows/release.yml

+34
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,45 @@ jobs:
2727
filename: 'TravelWindowII-${{ github.event.inputs.tag }}.zip'
2828
exclusions: '*.git* *.github* *.vscode* *.gitignore* /*doc/* /*screenshots/*'
2929

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+
3062
# create the GitHub release
3163
- name: create github release
3264
uses: softprops/action-gh-release@v2
3365
with:
3466
draft: true
3567
prerelease: false
3668
name: ${{ github.event.inputs.tag }}
69+
tag_name: ${{ github.event.inputs.tag }}
70+
body: ${{ steps.changelog.outputs.CONTENT }}
3771
files: 'TravelWindowII-${{ github.event.inputs.tag }}.zip'

0 commit comments

Comments
 (0)