From b80d71c55d653625ff220d856bae4bfa71023fb8 Mon Sep 17 00:00:00 2001 From: godcong Date: Fri, 29 Nov 2024 02:27:14 +0800 Subject: [PATCH] ci(workflow): improve changelog generation in release workflow - Add null check for LATEST_RELEASE to handle cases where no previous release exists - Modify git log command to use '--' for better handling of commit messages with special characters - Add debug echo for LATEST_RELEASE value --- .github/workflows/release_and_tagging.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release_and_tagging.yml b/.github/workflows/release_and_tagging.yml index de4b2c4..d70b010 100644 --- a/.github/workflows/release_and_tagging.yml +++ b/.github/workflows/release_and_tagging.yml @@ -60,16 +60,17 @@ jobs: id: generate_changelog run: | LATEST_RELEASE=${{ steps.get_latest_release.outputs.LATEST_RELEASE }} + echo "LATEST_RELEASE is $LATEST_RELEASE" echo "# Changelog" > changelog.txt - if [[ -z "$LATEST_RELEASE" ]]; then - # If there's no previous release, get only the current commit's log + if [[ -z "$LATEST_RELEASE" || "$LATEST_RELEASE" == "null" ]]; then + # If there's no previous release, get only the current commit log git config --global core.pager cat # git log --pretty=format:"* %s **by** @%an" git log --pretty=format:"* %s **by** @%an" >> changelog.txt else # Get all submission information since the last release - CHANGELOG=$(git log "$LATEST_RELEASE"..HEAD --pretty=format:"* %s **by** @%an") - git log "$LATEST_RELEASE"..HEAD --pretty=format:"* %s **by** @%an" >> changelog.txt + CHANGELOG=$(git log "$LATEST_RELEASE"..HEAD -- --pretty=format:"* %s **by** @%an") + git log "$LATEST_RELEASE"..HEAD -- --pretty=format:"* %s **by** @%an" >> changelog.txt fi - name: Create release