From a397aa4772a6aaec8308a73f29ff8e5efa192717 Mon Sep 17 00:00:00 2001 From: donker <donker@astron.nl> Date: Wed, 14 Apr 2021 15:56:10 +0200 Subject: [PATCH] new file --- tag_software_version.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100755 tag_software_version.py diff --git a/tag_software_version.py b/tag_software_version.py new file mode 100755 index 00000000..0ec25419 --- /dev/null +++ b/tag_software_version.py @@ -0,0 +1,28 @@ +#! /usr/bin/python3 + +import subprocess +import time + + +tag_str = time.strftime("%Y-%m-%dT%H.%M.%S_sdptr", time.gmtime()) +p1 = subprocess.Popen('git tag -a {} -m "production version"'.format(tag_str), stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True) +print(p1.communicate()[0]) + +p2 = subprocess.Popen('git describe --tags --always', stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True) + +version = p2.communicate()[0].decode('utf-8') +print(version) + + +with open('config.h', 'r') as fd: + config_file = fd.read() + +ptr = config_file.find('#define VERSION') +ptr1 = config_file.find('"', ptr) + 1 +ptr2 = config_file.find('"', ptr1) + +old_version = config_file[ptr1:ptr2] +config_file = config_file.replace(old_version, version.strip()) + +with open('config.h', 'w') as fd: + fd.write(config_file) -- GitLab