From c0ad93cea0aa570a693df4a57e426dab2ac47170 Mon Sep 17 00:00:00 2001 From: Sylvain Tricot Date: Fri, 15 Nov 2019 14:26:16 +0100 Subject: [PATCH] Add update_version.py and CI folder --- CI/update_version.py | 66 ++++++++++++++++++++++++++++++++++++++++++++ Makefile | 6 +++- 2 files changed, 71 insertions(+), 1 deletion(-) create mode 100644 CI/update_version.py diff --git a/CI/update_version.py b/CI/update_version.py new file mode 100644 index 0000000..7f11a61 --- /dev/null +++ b/CI/update_version.py @@ -0,0 +1,66 @@ +# coding: utf-8 +# vim: set et ts=4 sw=4 sts nu fdm=indent mouse=a: + +import subprocess +from distutils.version import LooseVersion + +def get_version(): + p = subprocess.run(['git describe'], shell=True, stdout=subprocess.PIPE) + output = p.stdout.decode('utf-8') + return output + +def set_version(version): + cmd = ['git', 'tag', '-a', version, '-m', f"Python MsSpec ({version})"] + subprocess.run(cmd) + +def ask_new_version(current_version): + version = LooseVersion(current_version) + components = version.version + last_major = int(components[0]) + last_minor = int(components[1]) + pre_release_type = 'Final release' + pre_release_number = None + post_release_number = None + dev_release_number = None + if 'a' in components: + pre_release_type = "Alpha release" + pre_release_number = int(components[components.index('a') + 1]) + if 'b' in components: + pre_release_type = "Alpha release" + pre_release_number = int(components[components.index('b') + 1]) + if 'rc' in components: + pre_release_type = "Release candidate" + pre_release_number = int(components[components.index('rc') + 1]) + if 'post' in components: + post_release_number = int(components[components.index('post') + 1]) + if 'dev' in components: + dev_release_number = int(components[components.index('dev') + 1]) + + release_kind = "" + if dev_release_number is not None: release_kind += "Developmental release of a " + if post_release_number is not None: release_kind += "post-" + release_kind += pre_release_type + + print(f"The current version is a {release_kind} ({str(version).strip()})") + + + new_major = input(f"Please enter the new MAJOR revision number [{last_major}]: ") + if new_major == '': + new_major = last_major + new_major = int(new_major) + + if new_major > last_major: + new_minor = 0 + else: + minor = last_minor + 1 + new_minor = input(f"Please enter the new MINOR revision number [{minor}]: ") + if new_minor == '': + new_minor = minor + + # check + new_version = f"{str(new_major)}.{str(new_minor)}" + assert LooseVersion(new_version) > version + print(f"The new version is: {new_version}") + set_version(new_version) + +ask_new_version(get_version()) diff --git a/Makefile b/Makefile index 7e9337a..82257b0 100644 --- a/Makefile +++ b/Makefile @@ -3,11 +3,15 @@ LICENSE:=$(shell cat ./license.txt) VERSION:=$(shell cd src && python -c "import msspec; print(msspec.__version__)") SETUPFILE:=pymsspec-$(VERSION).setup -.PHONY: clean +.PHONY: clean purge version clean: @rm -rf *.setup +version: + @./CI/make_version.sh + + purge: clean @echo "Purging all..." @find ./src -type f -name '*.pyc' -exec rm {} +