From 684f034aee0d92d0925eea471b0c0e219c5ed9f0 Mon Sep 17 00:00:00 2001 From: Juergen Kunz Date: Sun, 19 Oct 2025 14:33:58 +0000 Subject: [PATCH] ci(release): auto-delete existing release before creating new one - Checks if release already exists for the tag - Automatically deletes conflicting release if found - Prevents duplicate/stale releases when recreating tags - Ensures fresh binaries when tag is recreated This fixes the issue where recreating a tag would keep old release with outdated binaries. --- .gitea/workflows/release.yml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/.gitea/workflows/release.yml b/.gitea/workflows/release.yml index 98e4152..4fa9975 100644 --- a/.gitea/workflows/release.yml +++ b/.gitea/workflows/release.yml @@ -152,6 +152,29 @@ jobs: echo "Release notes:" cat /tmp/release_notes.md + - name: Delete existing release if it exists + run: | + VERSION="${{ steps.version.outputs.version }}" + + echo "Checking for existing release $VERSION..." + + # Try to get existing release by tag + EXISTING_RELEASE_ID=$(curl -s \ + -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ + "https://code.foss.global/api/v1/repos/serve.zone/nupst/releases/tags/$VERSION" \ + | jq -r '.id // empty') + + if [ -n "$EXISTING_RELEASE_ID" ]; then + echo "Found existing release (ID: $EXISTING_RELEASE_ID), deleting..." + curl -X DELETE -s \ + -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ + "https://code.foss.global/api/v1/repos/serve.zone/nupst/releases/$EXISTING_RELEASE_ID" + echo "Existing release deleted" + sleep 2 + else + echo "No existing release found, proceeding with creation" + fi + - name: Create Gitea Release run: | VERSION="${{ steps.version.outputs.version }}"