chore(release): Improved version control in release script as well as error handling.

Fixes: #6850