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

Fixes: #6850
Merge pull request #6847 from Srokap/semver_branches

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