bumpversion icon indicating copy to clipboard operation
bumpversion copied to clipboard

Support for handling release dates

Open brechtm opened this issue 9 years ago • 6 comments

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.

brechtm avatar Aug 09 '16 11:08 brechtm

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.

peritus avatar Aug 09 '16 11:08 peritus

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.

brechtm avatar Aug 09 '16 11:08 brechtm

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)

benoistlaurent avatar Nov 07 '16 13:11 benoistlaurent

Same issue here too. Hope this will be available

haidaraM avatar Oct 16 '17 23:10 haidaraM

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())

arcanefoam avatar Jan 23 '18 18:01 arcanefoam

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?

dgarrimar avatar Nov 18 '21 17:11 dgarrimar