Skip to content

Commit a259994

Browse files
committed
try if can delete all the previous release assets
1 parent 9215065 commit a259994

File tree

1 file changed

+7
-20
lines changed

1 file changed

+7
-20
lines changed

.github/workflows/publish-all-operators.yaml

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -250,41 +250,28 @@ 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 old assets from this tag
254-
# requires GH CLI and contents: write
253+
- name: Delete existing release if it exists
254+
# Delete the entire release first to ensure clean state
255255
env:
256256
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
257257
REPO: ${{ github.repository }}
258258
TAG: v${{ needs.start.outputs.new_version }}
259259
shell: bash
260260
run: |
261261
set -euo pipefail
262-
# Fetch the release ID for our tag (if it exists)
263-
release_id=$(gh api "repos/$REPO/releases/tags/$TAG" --jq .id || echo "")
264-
if [ -n "$release_id" ]; then
265-
echo "Found existing release $TAG (id=$release_id), pruning assets…"
266-
# Loop through all assets on that release
267-
gh api "repos/$REPO/releases/$release_id/assets" --jq '.[].id' | \
268-
while read asset_id; do
269-
name=$(gh api "repos/$REPO/releases/assets/$asset_id" --jq .name)
270-
# If the name does NOT contain our tag, delete it
271-
if [[ "$name" != *"$TAG"* ]]; then
272-
echo "Deleting old asset: $name"
273-
gh api "repos/$REPO/releases/assets/$asset_id" -X DELETE
274-
else
275-
echo "Keeping current asset: $name"
276-
fi
277-
done
262+
# Check if release exists and delete it
263+
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
278266
else
279-
echo "No existing release v$TAG to prune—moving on."
267+
echo "No existing release $TAG found"
280268
fi
281269
282270
- name: Create draft release
283271
uses: softprops/action-gh-release@v2
284272
with:
285273
name: v${{ needs.start.outputs.new_version }}
286274
body: ${{ steps.changelog.outputs.changelog }}
287-
overwrite_files: true
288275
draft: true
289276
files: |
290277
./aws-euid-deployment-files-${{ needs.start.outputs.new_version }}.zip

0 commit comments

Comments
 (0)