From 4f4145faa05f89e09fdaf52bd2a2b44c0b12b44f Mon Sep 17 00:00:00 2001 From: Max P Date: Fri, 16 Aug 2024 17:32:49 +0200 Subject: [PATCH] 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. --- .github/workflows/CreateRelease.yml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/workflows/CreateRelease.yml b/.github/workflows/CreateRelease.yml index c8460e6..89acd11 100644 --- a/.github/workflows/CreateRelease.yml +++ b/.github/workflows/CreateRelease.yml @@ -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