release.sh: improve version checking and support branches