Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix deletion of old releases #42

Merged
merged 1 commit into from
Jan 3, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 30 additions & 1 deletion .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,36 @@ jobs:
run: git push origin --delete nightly || true
- name: Delete existing nightly release
run: |
curl -X DELETE -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" https://api.github.com/repos/${{ github.repository }}/releases/tags/nightly
TAG_NAME=nightly

# Fetch the release associated with the tag
RESPONSE=$(curl -s -H "Authorization: Bearer $GITHUB_TOKEN" \
-H "Accept: application/vnd.github+json" \
"https://api.github.com/repos/$REPO/releases/tags/$TAG_NAME")

# Check if a release was found
RELEASE_ID=$(echo "$RESPONSE" | jq -r ".id")

if [[ "$RELEASE_ID" == "null" || -z "$RELEASE_ID" ]]; then
echo "No release found for tag: $TAG_NAME"
else
echo "Deleting release with ID: $RELEASE_ID"
curl -s -X DELETE -H "Authorization: Bearer $GITHUB_TOKEN" \
-H "Accept: application/vnd.github+json" \
"https://api.github.com/repos/$REPO/releases/$RELEASE_ID"
fi

# Delete the tag.
RESPONSE=$(curl -s -X DELETE -H "Authorization: Bearer $GITHUB_TOKEN" \
-H "Accept: application/vnd.github+json" \
"https://api.github.com/repos/$REPO/git/refs/tags/$TAG_NAME")

# Check for success
if echo "$RESPONSE" | grep -q '"message":'; then
echo "Error: $(echo "$RESPONSE" | jq -r '.message')"
else
echo "Tag '$TAG_NAME' deleted successfully."
fi
- name: Release
uses: softprops/action-gh-release@v2
with:
Expand Down
Loading