Delete all Github releases, using the Github cli

October 18, 2021 0 By addshore

If you are like me, at some point while developing projects on Github you will have started and stopped using releases, opting to switch back to only creating tags.

Github defaults leave you in a bit of an awkward position here where the “Releases” section in the side bar will continue to show your old releases, even if you have made hundreds of tags since.

If you’re managing lots of repositories and have made lots of legacy releases, removing them can be a pain (particularly in the UI). So, once again, GitHub CLI to the rescue!

In the repository of your choice run the following, and all of your releases will be removed!

gh release list | awk '{print $1;}' | xargs -L1 gh release delete
Code language: JavaScript (javascript)

If you want to see them ahead of removing them, list them first.

gh release list
Code language: PHP (php)

Enjoy your time saving, and your nice clear releases list!