[scripts] improve version checking in build scripts