Skip to content

Commit

Permalink
chore: 🧼 add release script for deleting old drafts
Browse files Browse the repository at this point in the history
  • Loading branch information
Ashley committed Nov 17, 2023
1 parent 2d2e482 commit dd8a8ec
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions scripts/release-draft.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash

# Set your GitHub repository details
USERNAME="wizarrrr"
REPO="wizarr"

# Get your GitHub Personal Access Token
# Make sure it has the "repo" scope
CURRENT_DIR=$(pwd)
TOKEN=$(cat $CURRENT_DIR/scripts/github_token.txt)

# Fetch all releases (including drafts) using the GitHub API
releases=$(curl -s -H "Authorization: token $TOKEN" "https://api.github.com/repos/$USERNAME/$REPO/releases?per_page=100")

# Delete all releases that are drafts
for row in $(echo "${releases}" | jq -r '.[] | @base64'); do
_jq() {
echo ${row} | base64 --decode | jq -r ${1}
}

if [ $(_jq '.draft') == true ]; then
id=$(_jq '.id')
echo "Deleting release with id $id and tag $(_jq '.tag_name')"
curl -X DELETE -H "Authorization: token $TOKEN" "https://api.github.com/repos/$USERNAME/$REPO/releases/$id"
fi
done

0 comments on commit dd8a8ec

Please sign in to comment.