From eb1f4d8b986343f00e018841230b853905ee1de8 Mon Sep 17 00:00:00 2001 From: godcong Date: Thu, 28 Nov 2024 21:44:38 +0800 Subject: [PATCH] ci(runtime): update GitHub release_and_tagging workflow - Improve curl command for getting latest release with additional headers - Enhance changelog generation process: - Add header for changelog - Handle case when LATEST_RELEASE is "null" - Optimize git log formatting --- .github/workflows/release_and_tagging.yml | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release_and_tagging.yml b/.github/workflows/release_and_tagging.yml index ec9c1cc..f481907 100644 --- a/.github/workflows/release_and_tagging.yml +++ b/.github/workflows/release_and_tagging.yml @@ -42,7 +42,10 @@ jobs: - name: Get latest release id: get_latest_release run: | - LATEST_RELEASE=$(curl -s -H "Authorization: token ${{ env.GITHUB_TOKEN }}" https://api.github.com/repos/${{ github.repository }}/releases/latest | jq -r '.tag_name') + LATEST_RELEASE=$(curl -L \ + -H "Accept: application/vnd.github+json" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + -H "Authorization: token ${{ env.GITHUB_TOKEN }}" https://api.github.com/repos/${{ github.repository }}/releases/latest | jq -r '.tag_name') echo "LATEST_RELEASE=$LATEST_RELEASE" >> $GITHUB_OUTPUT - name: Determine next version @@ -60,9 +63,10 @@ jobs: id: generate_changelog run: | LATEST_RELEASE=${{ steps.get_latest_release.outputs.LATEST_RELEASE }} - echo "LATEST_RELEASE=$LATEST_RELEASE" >> $GITHUB_OUTPUT - if [[ -z "$LATEST_RELEASE" ]]; then - # If there's no previous release, get only the current commit's log + echo "LATEST_RELEASE is $LATEST_RELEASE" + echo "# Changelog" > changelog.txt + 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