From 5a641bac7fbdec1b1ad4644efebd0d32df22b6b5 Mon Sep 17 00:00:00 2001 From: Alex Shnitman Date: Sat, 29 Nov 2025 09:34:38 +0200 Subject: [PATCH] re-create the release if one has already been pushed with the same tag --- .github/workflows/main.yml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 6e0e543..fdea93d 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -146,6 +146,29 @@ jobs: cat release_body.txt echo EOF } >> $GITHUB_OUTPUT + - name: Delete existing release if present + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + TAG_NAME: ${{ steps.date.outputs.date }} + run: | + # Authenticate GitHub CLI + echo "$GITHUB_TOKEN" | gh auth login --with-token + + # Check if release exists and delete it + if gh release view "$TAG_NAME" &>/dev/null; then + echo "Release $TAG_NAME already exists, deleting it..." + gh release delete "$TAG_NAME" --yes || true + fi + + # Fetch tags to check remote + git fetch --tags + + # Check if tag exists (locally or remotely) and delete it + if git rev-parse "$TAG_NAME" &>/dev/null 2>&1 || git ls-remote --tags origin "$TAG_NAME" | grep -q "$TAG_NAME"; then + echo "Tag $TAG_NAME already exists, deleting it..." + git tag -d "$TAG_NAME" 2>/dev/null || true + git push origin ":refs/tags/$TAG_NAME" || true + fi - name: Create GitHub Release uses: softprops/action-gh-release@v1 with: