Skip to content

Commit aea285f

Browse files
jorbenclaude
andauthored
ci(changelog): 👷 use explicit prev_tag for draft release changelog (#27)
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 <noreply@anthropic.com>
1 parent 4d4a618 commit aea285f

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

.github/workflows/draft-release.yml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,26 @@ jobs:
2121
steps:
2222
- name: Checkout Code
2323
uses: actions/checkout@v3
24+
with:
25+
fetch-depth: 0
26+
27+
- name: Find previous stable tag
28+
id: prev_tag
29+
run: |
30+
CURRENT_TAG="${{ github.ref_name }}"
31+
# List all tags matching X.Y.Z (no suffix), sorted by version descending
32+
# Exclude the current tag, then take the first match as the previous stable tag
33+
PREV_TAG=$(git tag -l --sort=-v:refname | grep -E '^[0-9]+\.[0-9]+\.[0-9]+$' | grep -v "^${CURRENT_TAG}$" | head -n 1)
34+
echo "prev_tag=${PREV_TAG}" >> "$GITHUB_OUTPUT"
35+
echo "Current tag: ${CURRENT_TAG}, Previous stable tag: ${PREV_TAG}"
2436
2537
- name: Generate changelog
2638
id: changelog
2739
uses: requarks/changelog-action@v1
2840
with:
2941
token: ${{ github.token }}
30-
tag: ${{ github.ref_name }}
42+
fromTag: ${{ github.ref_name }}
43+
toTag: ${{ steps.prev_tag.outputs.prev_tag }}
3144
writeToFile: false
3245

3346
- name: Create Draft Release

0 commit comments

Comments
 (0)