Make release.sh smarter, fix #1043.