Skip to content

Commit

Permalink
testing release description generation with GitHub actions
Browse files Browse the repository at this point in the history
  • Loading branch information
wduda committed Oct 9, 2024
1 parent 8e352a4 commit 812bd1e
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,39 @@ jobs:
filename: 'TravelWindowII-${{ github.event.inputs.tag }}.zip'
exclusions: '*.git* *.github* *.vscode* *.gitignore* /*doc/* /*screenshots/*'

# parse changelog to set release description
- name: extract latest changelog entry
id: changelog
run: |
# Find the line number of the latest version header
LATEST_VERSION_LINE=$(grep -n "^## v" CHANGELOG.md | head -n1 | cut -d: -f1)
# Find the line number of the next version header or EOF
NEXT_VERSION_LINE=$(tail -n +$((LATEST_VERSION_LINE + 1)) CHANGELOG.md | grep -n "^## v" | head -n1 | cut -d: -f1)
if [ -z "$NEXT_VERSION_LINE" ]; then
NEXT_VERSION_LINE=$(wc -l < CHANGELOG.md)
else
NEXT_VERSION_LINE=$((LATEST_VERSION_LINE + NEXT_VERSION_LINE - 1))
fi
# Extract the content between these line numbers
CHANGELOG_CONTENT=$(sed -n "${LATEST_VERSION_LINE},${NEXT_VERSION_LINE}p" CHANGELOG.md)
# Escape newlines and quote special characters for GitHub Actions
CHANGELOG_CONTENT="${CHANGELOG_CONTENT//'%'/'%25'}"
CHANGELOG_CONTENT="${CHANGELOG_CONTENT//$'\n'/'%0A'}"
CHANGELOG_CONTENT="${CHANGELOG_CONTENT//$'\r'/'%0D'}"
# Set output for use in subsequent steps
echo "::set-output name=content::$CHANGELOG_CONTENT"
# create the GitHub release
- name: create github release
uses: softprops/action-gh-release@v2
with:
draft: true
prerelease: false
name: ${{ github.event.inputs.tag }}
tag_name: ${{ github.event.inputs.tag }}
body: ${{ steps.changelog.outputs.content }}
files: 'TravelWindowII-${{ github.event.inputs.tag }}.zip'

0 comments on commit 812bd1e

Please sign in to comment.