From da5ef7c25ca5b748fa141adcab6956208f00fd78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E6=99=AF=E7=AB=8B?= Date: Sun, 4 Aug 2024 14:29:56 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=9B=B4=E6=96=B0=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/release.yml | 31 +++++++++++++------------------ bin/clearTag.cmd | 4 +++- 2 files changed, 16 insertions(+), 19 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 825e548d5..867e7b016 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -28,33 +28,28 @@ jobs: id: last_tag run: | + # 获取所有标签,按版本排序(降序) Tags=$(git tag --list --sort=-version:refname) - # 获取倒数第一个标签 - FRIEST_LATEST_TAG=$(echo "$Tags" | awk 'NR==1 {print $1; exit}') + # 获取最新的标签(即列表中的第一个) + LATEST_TAG=$(echo "$Tags" | awk 'NR==1 {print $1; exit}') - # 获取倒数第二个标签 - SECOND_LATEST_TAG=$(echo "$Tags" | awk 'NR==1 {print $2; exit}') + # 获取倒数第二个标签(如果存在) + if [[ -n "$Tags" ]]; then + SECOND_LATEST_TAG=$(echo "$Tags" | tac | awk 'NR==1 {print $1; exit}') + else + SECOND_LATEST_TAG="" + fi - # 如果没有倒数第一个标签,则输出为空字符串 - if [[ -z "$FRIEST_LATEST_TAG" ]]; then - echo "::set-output name=tag_last::v1.0.0" - else - echo "::set-output name=tag_last::$FRIEST_LATEST_TAG" - fi - - # 如果没有倒数第二个标签,则输出为空字符串 - if [[ -z "$SECOND_LATEST_TAG" ]]; then - echo "::set-output name=tag_cmd::-S master" - else - echo "::set-output name=tag_cmd::-S $SECOND_LATEST_TAG" - fi + # 设置输出变量 + echo "::set-output name=tag_last::${LATEST_TAG:-v1.0.0}" + echo "::set-output name=tag_cmd::-S ${SECOND_LATEST_TAG:-v1.0.0} " - name: Generate Release Notes run: | rm -rf log newTag=${{ steps.last_tag.outputs.tag_last }} - git-log -m tag -f ${{ steps.last_tag.outputs.tag_cmd }} -v ${newTag#v} + git-log -m tag -f ${{ steps.last_tag.outputs.tag_cmd }}-v ${newTag#v} - name: Create Release id: create_release diff --git a/bin/clearTag.cmd b/bin/clearTag.cmd index 93db0c581..1c12279fb 100644 --- a/bin/clearTag.cmd +++ b/bin/clearTag.cmd @@ -1,8 +1,10 @@ @echo off setlocal +git pull + echo Deleting remote tags... -for /f "delims=" %%x in ('git tag') do git push --delete origin %%x +for /f "delims=" %%x in ('git tag') do git push --delete origin %%x echo Deleting local tags... for /f "delims=" %%i in ('git tag') do git tag -d %%i