Port update-version.sh to bash, refactor slightly
(cherry picked from commit 5267805254544eb58c4691321d7bc43356a300ce)