From ef537056e7c7e57891ae5aeddf40b8f63da66967 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Sun, 3 Apr 2022 12:09:50 +0200 Subject: [PATCH] Script to update version numbers --- arduino/library-arduino.json | 2 +- arduino/library-arduino.properties | 2 +- library.json | 2 +- library.properties | 2 +- scripts/update_release.py | 61 +++++++++++++++++++++++------- version.txt | 2 +- 6 files changed, 52 insertions(+), 19 deletions(-) diff --git a/arduino/library-arduino.json b/arduino/library-arduino.json index 49517278..1798ead5 100644 --- a/arduino/library-arduino.json +++ b/arduino/library-arduino.json @@ -1,6 +1,6 @@ { "name": "Embedded Template Library - Arduino", - "version": "20.27.1", + "version": "20.27.2", "authors": { "name": "John Wellbelove", "email": "john.wellbelove@etlcpp.com" diff --git a/arduino/library-arduino.properties b/arduino/library-arduino.properties index 41cd6c40..227f2137 100644 --- a/arduino/library-arduino.properties +++ b/arduino/library-arduino.properties @@ -1,5 +1,5 @@ name=Embedded Template Library - Arduino -version=20.27.1 +version=20.27.2 author= John Wellbelove maintainer=John Wellbelove license=MIT diff --git a/library.json b/library.json index 1e2433e2..67f96961 100644 --- a/library.json +++ b/library.json @@ -1,6 +1,6 @@ { "name": "Embedded Template Library", - "version": "20.27.1", + "version": "20.27.2", "authors": { "name": "John Wellbelove", "email": "john.wellbelove@etlcpp.com" diff --git a/library.properties b/library.properties index f0910604..d8a8267d 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=Embedded Template Library -version=20.27.1 +version=20.27.2 author= John Wellbelove maintainer=John Wellbelove license=MIT diff --git a/scripts/update_release.py b/scripts/update_release.py index 09af3384..18a2ffce 100644 --- a/scripts/update_release.py +++ b/scripts/update_release.py @@ -127,10 +127,10 @@ def get_version(): elements = version.split('.', 3) - return elements[0], elements[1], elements[2] + return version, elements[0], elements[1], elements[2] #------------------------------------------------------------------------------ -def create_version_h(): +def update_version_h(): print('') print('Creating version.h') @@ -162,37 +162,70 @@ def create_version_h(): index = text[i].find(search_patch) if index != -1: text[i] = text[i][index:length_patch] + patch_version - print(text[i]) #------------------------------------------------------------------------------ -def create_library_json(): +def update_library_json(filename): print('') - print('Creating library.json') + print('Creating %s' % filename) + + with open(filename) as f: + text = f.read().splitlines() + + search = 'version' + + for i in range(len(text) - 1): + index = text[i].find(search) + if index != -1: + text[i] = ' \"version\": \"' + full_version + '\",' + + with open(filename, 'w') as f: + for line in text: + f.write(line) + f.write('\n') #------------------------------------------------------------------------------ -def create_library_properties(): +def update_library_properties(filename): print('') - print('Creating library.properties') + print('Creating %s' % filename) + + with open(filename, 'r') as f: + text = f.read().splitlines() + + search = 'version' + + for i in range(len(text) - 1): + index = text[i].find(search) + if index != -1: + text[i] = 'version=' + full_version + + with open(filename, 'w') as f: + for line in text: + f.write(line) + f.write('\n') #------------------------------------------------------------------------------ def update_versions(): print('') print('Update Versions') - print('') + global full_version global major_version global minor_version global patch_version - major_version, minor_version, patch_version = get_version() + full_version, major_version, minor_version, patch_version = get_version() - print("Version = %s.%s.%s" % ( major_version, minor_version, patch_version )) + print("Version = %s.%s.%s" % (major_version, minor_version, patch_version )) - create_version_h() - create_library_json() - create_library_properties() + update_version_h() + + update_library_json(os.path.join(etl_dir, 'library.json')) + update_library_json(os.path.join(arduino_dir, 'library-arduino.json')) + + update_library_properties(os.path.join(etl_dir, 'library.properties')) + update_library_properties(os.path.join(arduino_dir, 'library-arduino.properties')) #------------------------------------------------------------------------------ if __name__ == "__main__": - create_arduino_variant() update_versions() + create_arduino_variant() diff --git a/version.txt b/version.txt index 99eae3a0..a39410f2 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -20.27.1 \ No newline at end of file +20.27.2 \ No newline at end of file