Prevent duplicate releases in workflow

Added a check to ensure the version already exists as a tag before creating a new release. This prevents creating duplicate releases and refines the version comparison logic by changing the exit status to 0 when the version hasn't changed.
This commit is contained in:
2024-08-16 17:32:49 +02:00
parent f7c4e609c2
commit 4f4145faa0

View File

@@ -54,9 +54,16 @@ jobs:
- name: Check if version changed
id: check_version
run: |
# Check if the version already exists as a tag
if git rev-parse "refs/tags/${{ env.VERSION }}" >/dev/null 2>&1; then
echo "Version ${{ env.VERSION }} already exists as a tag. No release will be created."
exit 0
fi
# Compare current version with previous tag
if [ "${{ env.VERSION }}" == "${{ env.PREVIOUS_TAG }}" ]; then
echo "Version has not changed. No release will be created."
exit 1
exit 0
fi
shell: bash