@@ -250,45 +250,6 @@ 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 : Cleanup assets from all previous releases
254- # Clean up assets from all releases to prevent accumulation
255- env :
256- GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
257- REPO : ${{ github.repository }}
258- CURRENT_TAG : v${{ needs.start.outputs.new_version }}
259- shell : bash
260- run : |
261- set -euo pipefail
262- echo "Current release will be: $CURRENT_TAG"
263-
264- # Get all releases and clean up their assets
265- gh api "repos/$REPO/releases" --jq -r '.[] | select(.tag_name != null and .tag_name != "") | .tag_name' | \
266- while read -r tag; do
267- if [ "$tag" != "$CURRENT_TAG" ] && [ -n "$tag" ]; then
268- echo "Cleaning up assets from release: $tag"
269- # Check if the release exists and has assets
270- if gh release view "$tag" --repo "$REPO" >/dev/null 2>&1; then
271- # Get all asset IDs for this release and delete them
272- asset_ids=$(gh api "repos/$REPO/releases/tags/$tag" --jq -r '.assets[].id' 2>/dev/null || echo "")
273- if [ -n "$asset_ids" ]; then
274- echo "$asset_ids" | while read -r asset_id; do
275- if [ -n "$asset_id" ]; then
276- asset_name=$(gh api "repos/$REPO/releases/assets/$asset_id" --jq -r '.name' 2>/dev/null || echo "unknown")
277- echo " Deleting asset: $asset_name from $tag"
278- gh api "repos/$REPO/releases/assets/$asset_id" -X DELETE 2>/dev/null || echo " Failed to delete asset $asset_id"
279- fi
280- done
281- else
282- echo " No assets found for $tag"
283- fi
284- else
285- echo " Release $tag not found, skipping"
286- fi
287- fi
288- done
289-
290- echo "Cleanup complete - only $CURRENT_TAG will have assets"
291-
292253 - name : Create draft release
293254 uses : softprops/action-gh-release@v2
294255 with :
0 commit comments