Reemus Icon

Fetch Git Tags Missing A GitHub Release


I needed a simple script to get all the git tags that don't have a GitHub release associated with it. This simple bash script will do precisely that. You will need to have the GitHub CLI installed for this to work.

# List git tags sorted by semver version
TAGS=$(git tag --sort=version:refname)
# Loop tags and check if a release exists for each
for TAG in $TAGS; do
  # Get the title of a release if it exists, otherwise return -1
  RELEASE_TITLE=$(gh release view $TAG --json name --jq '.name' 2>/dev/null || echo "-1")
  # If release title is the same as the tag name, it's already released
  if [[ "$RELEASE_TITLE" == "$TAG" ]]; then
    echo "Release already exists for tag: $TAG"
  # The release doesn't exist and you can process it as needed
  echo "Perform some work for tag: $TAG"



Your name will be displayed publicly

Loading comments...