release-bot icon indicating copy to clipboard operation
release-bot copied to clipboard

accept python versioning

Open TomasTomecek opened this issue 6 years ago • 3 comments

I am using python versioning scheme in my python project (you don't say). Unfortunately release bot fails to parse it:

08:51:35.770 utils.py          INFO   Editing line with new version:
__version__ = "0.2.0.dev0"
08:51:35.770 utils.py          WARNING Failed to validate version, aborting
08:51:35.771 utils.py          ERROR  No version files found. Aborting version update.

Related #12 and all other versioning issues

TomasTomecek avatar Nov 06 '18 09:11 TomasTomecek

@TomasTomecek Should I implement add a version_regex field to the config file to define custom version regex for the projects?

shresthagrawal avatar Mar 14 '19 16:03 shresthagrawal

Honestly, I don't know how to tackle this one. We are using semver to compare versions and if semver fails to parse the version, the execution stops. One regex would not do, we would need a more sophisticated solution. Maybe there are already libraries which handle this situation.

TomasTomecek avatar Mar 15 '19 14:03 TomasTomecek

The warning comes from update_version(), which uses semantic_version.validate() to make sure the version string we found in {'setup.py', '__init__.py', 'version.py'} is a proper semantic version string. I think we don't need to be so strict in this case and just replace

if semantic_version.validate(old_version):
  old_version -> new_version
else:
  configuration.logger.warning(f"Failed to validate version, aborting")

with

try:
  semantic_version.Version.coerce(old_version)
except ValueError:
  configuration.logger.warning(f"Failed to validate version, aborting")
else:
  old_version -> new_version

jpopelka avatar Mar 15 '19 16:03 jpopelka