@@ -250,21 +250,29 @@ jobs:
250250 (cd ./deployment/gcp-oidc-deployment-files-${{ needs.start.outputs.new_version }} && zip -r ../../gcp-oidc-deployment-files-${{ needs.start.outputs.new_version }}.zip . )
251251 (cd manifests && zip -r ../uid2-operator-release-manifests-${{ needs.start.outputs.new_version }}.zip .)
252252
253- - name : Delete existing release if it exists
254- # Delete the entire release first to ensure clean state
253+
254+ - name : Cleanup old assets from existing release
255+ # Clean up all assets from existing release to ensure only current assets are included
255256 env :
256257 GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
257258 REPO : ${{ github.repository }}
258259 TAG : v${{ needs.start.outputs.new_version }}
259260 shell : bash
260261 run : |
261262 set -euo pipefail
262- # Check if release exists and delete it
263+ # Check if release exists
263264 if gh release view "$TAG" --repo "$REPO" >/dev/null 2>&1; then
264- echo "Deleting existing release $TAG"
265- gh release delete "$TAG" --repo "$REPO" --yes
265+ echo "Found existing release $TAG, cleaning up all assets..."
266+ # Get all asset IDs and delete them
267+ gh api "repos/$REPO/releases/tags/$TAG" --jq '.assets[].id' | \
268+ while read -r asset_id; do
269+ asset_name=$(gh api "repos/$REPO/releases/assets/$asset_id" --jq -r '.name')
270+ echo "Deleting asset: $asset_name (ID: $asset_id)"
271+ gh api "repos/$REPO/releases/assets/$asset_id" -X DELETE
272+ done
273+ echo "All assets cleaned up for release $TAG"
266274 else
267- echo "No existing release $TAG found"
275+ echo "No existing release $TAG found - will create new release "
268276 fi
269277
270278 - name : Create draft release
0 commit comments