Used git describe instead of git tag | head -n 1 to get the latest tag.