Skip to content

Commit 9609350

Browse files
authored
Add step to retrieve previous git tag in workflow
1 parent 6df6536 commit 9609350

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

.github/workflows/docker-image.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,11 +129,24 @@ jobs:
129129
id: get-new-version
130130
run: echo "NEW_VERSION=${{ needs.build.outputs.new_version }}" >> $GITHUB_OUTPUT
131131

132+
- name: Get previous tag
133+
id: previous-tag
134+
run: |
135+
# Get the most recent tag (excluding the current commit's tags)
136+
PREV_TAG=$(git tag --sort=-version:refname | head -1)
137+
if [ -z "$PREV_TAG" ]; then
138+
# If no tags exist, use the initial commit
139+
PREV_TAG=$(git rev-list --max-parents=0 HEAD)
140+
fi
141+
echo "PREV_TAG=$PREV_TAG" >> $GITHUB_OUTPUT
142+
132143
- name: Generate Changelog
133144
id: changelog
134145
uses: mikepenz/release-changelog-builder-action@v6
135146
with:
136147
token: ${{ secrets.GH_TOKEN }}
148+
fromTag: ${{ steps.previous-tag.outputs.PREV_TAG }}
149+
toTag: HEAD
137150
configuration: |
138151
{
139152
"categories": [

0 commit comments

Comments
 (0)