From b8aac2c5b623241069c096ba6bd55dd24cc37476 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Thu, 11 Aug 2022 15:27:44 -0500 Subject: [PATCH] Create bump_version.py --- bin/bump_version.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 bin/bump_version.py diff --git a/bin/bump_version.py b/bin/bump_version.py new file mode 100644 index 000000000..31e63ba80 --- /dev/null +++ b/bin/bump_version.py @@ -0,0 +1,25 @@ +#!/usr/bin/env python +"""Bump the version number""" + +version_filename = "setup.py" + +lines = None + +with open(version_filename, 'r', encoding='utf-8') as f: + lines = f.readlines() + +with open(version_filename, 'w', encoding='utf-8') as f: + for line in lines: + if line.lstrip().startswith("version="): + # get rid of quotes around the version + line = line.replace('"', '') + # get rid of trailing comma + line = line.replace(",", "") + # split on '=' + words = line.split("=") + # split the version into parts (by period) + v = words[1].split(".") + ver = f'{v[0]}.{v[1]}.{int(v[2]) + 1}' + f.write(f' version="{ver}",\n') + else: + f.write(line)