Skip to content

Commit

Permalink
Allow bugfix releases to add 4th digit to version
Browse files Browse the repository at this point in the history
  • Loading branch information
jim-easterbrook committed Oct 20, 2022
1 parent 6da9860 commit 08b9228
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/photini/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Full documentation is at https://photini.readthedocs.io/"""

__version__ = '2022.10.1'
build = '2276 (1018345)'
__version__ = '2022.10.0.1'
build = '2277 (6da9860)'
26 changes: 19 additions & 7 deletions utils/update_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,18 +52,30 @@ def main(argv=None):
latest = tag.commit.committed_date
last_release = tag_name
# set current version number (calendar based)
major, minor, micro = map(int, last_release.split('.'))
today = date.today()
if today.year == major and today.month == minor:
micro += 1
last_release = [int(x) for x in last_release.split('.')]
major, minor, micro = last_release[:3]
version = [int(x) for x in __version__.split('.')]
if len(version) == 3:
# update normal version number based on date
today = date.today()
if today.year == major and today.month == minor:
micro += 1
else:
micro = 0
version = '{:4d}.{:d}.{:d}'.format(today.year, today.month, micro)
else:
micro = 0
# update bug fix version number
if len(last_release) == 3:
bug_fix = 1
else:
bug_fix = last_release[3] + 1
version = '{:4d}.{:d}.{:d}.{:d}'.format(major, minor, micro, bug_fix)
# update __init__.py if anything's changed
new_text = """\"\"\"Full documentation is at https://photini.readthedocs.io/\"\"\"
__version__ = '{:4d}.{:d}.{:d}'
__version__ = '{:s}'
build = '{:d} ({:s})'
""".format(today.year, today.month, micro, dev_no, commit)
""".format(version, dev_no, commit)
if new_text != init_text:
with open(INIT_FILE, 'w') as vf:
vf.write(new_text)
Expand Down

0 comments on commit 08b9228

Please sign in to comment.