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 }}"