[build] Improved version name logic