1
0
mirror of synced 2024-11-27 17:00:50 +01:00

workflows - use commit message body minus empty lines as-is for changelog generation (#736)

This commit is contained in:
Wei-Cheng Yeh (IID) 2024-11-02 12:37:16 +08:00 committed by GitHub
parent 9e9c0ff0b1
commit 67be8442da
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -71,23 +71,25 @@ jobs:
id: get-commit-message
run: |
$message = git log -1 --pretty=%b
echo "::set-output name=message::$message"
$messagePath = 'COMMIT_MSG'
echo $message >> $messagePath
echo "messagePath=$messagePath" >> $env:GITHUB_ENV
- name: Update CHANGELOG.md
run: |
$version = '${{steps.get-version.outputs.version}}'
$date = '${{steps.get-date.outputs.date}}'
$message = '${{steps.get-commit-message.outputs.message}}'
$messagePath = $env:messagePath
$changelogPath = "CHANGELOG.md"
# Read commit description content
$messageLines = Get-Content -Path $messagePath
# Read CHANGELOG.md content
$changelog = Get-Content -Path $changelogPath
# Split the message into individual items, trim whitespace, and format
$messageArray = $message -split '-' | ForEach-Object { $_.Trim() } | Where-Object { $_ -ne "" }
# Format each item to have a leading dash
$message = ($messageArray | ForEach-Object { "- $_" }) -join "`n"
# Remove empty lines from the message
$message = ($messageLines | Where-Object { $_ -ne "" }) -join "`n"
# Check if the version already exists
if ($changelog -match "## \[$version\]") {