Extract versioning code

Starting a PR for this in case we need to discuss it. See globalize/globalize-versioning#2 for details.