Skip to content

Commit 7d5f433

Browse files
authored
Update publish.yml - bugfix of reading previous release when not any exists
1 parent 4a46638 commit 7d5f433

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

.github/workflows/publish.yml

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -108,13 +108,21 @@ jobs:
108108
109109
echo "::group::Old release delete"
110110
RELEASE_ID=$(curl -s -H "Authorization: token $TOKEN" \
111-
https://api.github.com/repos/$REPO/releases/tags/$TAG | jq -r .id)
111+
https://api.github.com/repos/$REPO/releases/tags/$TAG)
112112
113-
if [ "$RELEASE_ID" != "null" ]; then
114-
echo "Deleting release ID $RELEASE_ID"
115-
curl -s -X DELETE -H "Authorization: token $TOKEN" \
116-
https://api.github.com/repos/$REPO/releases/$RELEASE_ID
113+
MESSAGE=$(echo "$RELEASE_ID" | jq -r '.message // empty')
114+
if [ "$MESSAGE" = "Not Found" ]; then
115+
echo "Release with tag $TAG not found"
116+
else
117+
RELEASE_ID =$(echo "RELEASE_ID" | jq -r '.id // empty')
118+
119+
if [ "$RELEASE_ID" != "null" ]; then
120+
echo "Deleting release ID $RELEASE_ID"
121+
curl -s -X DELETE -H "Authorization: token $TOKEN" \
122+
https://api.github.com/repos/$REPO/releases/$RELEASE_ID
123+
fi
117124
fi
125+
118126
echo "::endgroup::"
119127
120128
echo "::group::Old tag delete"

0 commit comments

Comments
 (0)