From 3f07a019f69e70c0440d624fe75f6b5abfbdf70a Mon Sep 17 00:00:00 2001 From: Jorben Date: Wed, 11 Feb 2026 14:42:34 +0800 Subject: [PATCH] =?UTF-8?q?ci(changelog):=20=F0=9F=91=B7=20use=20explicit?= =?UTF-8?q?=20prev=5Ftag=20for=20draft=20release=20changelog?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add previous stable tag detection to draft-release workflow so changelog-action generates correct diff range even when the current tag is a pre-release (e.g. beta-xxx). Aligns with the same approach used in changelog.yml. Co-Authored-By: Claude Opus 4.6 --- .github/workflows/draft-release.yml | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/.github/workflows/draft-release.yml b/.github/workflows/draft-release.yml index a5224ae..c6d0b3d 100644 --- a/.github/workflows/draft-release.yml +++ b/.github/workflows/draft-release.yml @@ -21,13 +21,26 @@ jobs: steps: - name: Checkout Code uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Find previous stable tag + id: prev_tag + run: | + CURRENT_TAG="${{ github.ref_name }}" + # List all tags matching X.Y.Z (no suffix), sorted by version descending + # Exclude the current tag, then take the first match as the previous stable tag + PREV_TAG=$(git tag -l --sort=-v:refname | grep -E '^[0-9]+\.[0-9]+\.[0-9]+$' | grep -v "^${CURRENT_TAG}$" | head -n 1) + echo "prev_tag=${PREV_TAG}" >> "$GITHUB_OUTPUT" + echo "Current tag: ${CURRENT_TAG}, Previous stable tag: ${PREV_TAG}" - name: Generate changelog id: changelog uses: requarks/changelog-action@v1 with: token: ${{ github.token }} - tag: ${{ github.ref_name }} + fromTag: ${{ github.ref_name }} + toTag: ${{ steps.prev_tag.outputs.prev_tag }} writeToFile: false - name: Create Draft Release