Skip to content

Commit fe45512

Browse files
fix(ci): add error handling to dev release pruning step
The pruning logic assumed gh CLI and jq always succeed. Now each stage (list, parse, delete) captures errors, emits a ::warning:: annotation, and exits cleanly so a pruning failure never breaks the dev build.
1 parent 70c7627 commit fe45512

File tree

1 file changed

+21
-11
lines changed

1 file changed

+21
-11
lines changed

.github/workflows/publish.yml

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -234,17 +234,27 @@ jobs:
234234
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
235235
run: |
236236
# List dev releases sorted newest-first, skip the first 5, delete the rest
237-
gh release list --limit 100 --json tagName,isPrerelease,createdAt \
238-
| jq -r '
239-
[ .[] | select(.isPrerelease and (.tagName | startswith("dev-v"))) ]
240-
| sort_by(.createdAt) | reverse
241-
| .[5:]
242-
| .[].tagName
243-
' \
244-
| while read -r tag; do
245-
echo "Deleting old dev release: $tag"
246-
gh release delete "$tag" --yes --cleanup-tag
247-
done
237+
# Non-critical: failures here should not fail the workflow
238+
TAGS=$(gh release list --limit 100 --json tagName,isPrerelease,createdAt 2>&1) || {
239+
echo "::warning::Failed to list releases for pruning: ${TAGS}"
240+
exit 0
241+
}
242+
243+
OLD_TAGS=$(echo "$TAGS" | jq -r '
244+
[ .[] | select(.isPrerelease and (.tagName | startswith("dev-v"))) ]
245+
| sort_by(.createdAt) | reverse
246+
| .[5:]
247+
| .[].tagName
248+
' 2>&1) || {
249+
echo "::warning::Failed to parse release list for pruning: ${OLD_TAGS}"
250+
exit 0
251+
}
252+
253+
echo "$OLD_TAGS" | while read -r tag; do
254+
[ -z "$tag" ] && continue
255+
echo "Deleting old dev release: $tag"
256+
gh release delete "$tag" --yes --cleanup-tag || echo "::warning::Failed to delete release ${tag}"
257+
done
248258
249259
- name: Summary
250260
env:

0 commit comments

Comments
 (0)