diff --git a/.github/workflows/build-release.yml b/.github/workflows/build-release.yml index 820cded4..15c6c38c 100644 --- a/.github/workflows/build-release.yml +++ b/.github/workflows/build-release.yml @@ -159,13 +159,28 @@ jobs: - name: Delete existing release and tag if found run: | - if gh release view v${{ env.VERSION }} > /dev/null 2>&1; then - echo "Release exists" - gh release delete v${{ env.VERSION }} --yes - end + VERSION="v${{ env.VERSION }}" - git tag -d v${{ env.VERSION }} || true - git push origin :refs/tags/v${{ env.VERSION }} || true + if gh release view "$VERSION" > /dev/null 2>&1; then + echo "Release $VERSION exists. Deleting release..." + gh release delete "$VERSION" --yes + else + echo "Release $VERSION does not exist." + fi + + if git rev-parse "$VERSION" >/dev/null 2>&1; then + echo "Tag $VERSION exists locally. Deleting tag..." + git tag -d "$VERSION" || true + else + echo "Tag $VERSION does not exist locally." + fi + + if git ls-remote --tags origin | grep "refs/tags/$VERSION" >/dev/null 2>&1; then + echo "Tag $VERSION exists on remote. Deleting remote tag..." + git push origin :refs/tags/"$VERSION" || true + else + echo "Tag $VERSION does not exist on remote." + fi env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}