Support for handling release dates
Most software will also store a release date along with the release number. I was hoping bumpversion could also set the release date for me. The search/replace options looked promising, but alas, I couldn't get it to work.
This would require the search option to recognize datetime formats or regexes. Even better, bumpversion could record the last release's date in it's config file, so a {current_date} could be used to search for the text to replace.
also set the release date for me
Can you elaborate on that ?
You can use {now:%d.%m.%Y} in both the tag and the message template string.
See https://github.com/peritus/bumpversion/blob/6ec908f018a827bfae94ed50baf241461eba7bcb/tests/test_cli.py#L1520-L1533 for an example that automatically adds a section to the changelog, with the current date.
Sorry, I should have been more specific. I want to record the release date in a Python source file.
This works for a changelog, because it adds a new section. But for recording the release date in a Python source file, it needs to replace the old release date.
Same problem here. Would be extremely useful if it was possible to replace
This is myprogram 1.0.0 (2015-06-15)
with
This is myprogram 1.1.0 (2016-11-07)
Same issue here too. Hope this will be available
I solved this by making the date part of the parse regex, but not using it as part of the version parts. So my cfg looks like this:
[bumpversion] current_version = 2016/06/04 1.0 serialize = {now:%Y/%m/%d} {major}.{minor} parse = \d{4}/\d{2}/\d{2}\s(?P<major>\d+)\.(?P<minor>\d+) ...
- So my current version includes the date.
- The parse regex consumes the date as part of the version
- The serialize string uses the "now" entry (which is evaluated as datetime.now() - alternatively 'utcnow' is: datetime.utcnow())
What about a situation where there is a line break in the middle? i.e.
Version: 1.0.0
Date: yyyy/mm/dd
can bump2version handle the newline to match the pattern?