(build) Improve the way version number is detected