From c6715bc9806549f002730fd6d8e52318779ae559 Mon Sep 17 00:00:00 2001 From: Martin Liriano Date: Mon, 24 Jul 2023 14:49:43 -0400 Subject: [PATCH] updated version_update.py to update composer.json version --- .github/version_update.py | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/.github/version_update.py b/.github/version_update.py index 88c55c8c..e189acb7 100644 --- a/.github/version_update.py +++ b/.github/version_update.py @@ -1,4 +1,4 @@ -import re, sys +import re, sys, json import xml.etree.ElementTree as ET # fetch type of upgrade code from bash arguments @@ -27,6 +27,9 @@ # xml_file_name dictates where XML file is located xml_file_name = './etc/config.xml' +# json_file_name dictates where XML file is located +json_file_name = 'composer.json' + # updateMajorVersion(Lines) updates the Major version x.0.0 def updateMajorVersion(Lines) : @@ -158,6 +161,20 @@ def processXML(version): # write data back to file tree.write(xml_file_name) +# processJSON(versiion) takes version input and writes to the config.xml +def processJSON(version): + # read JSON file + j_file = open('composer.json') + + j_obj = json.load(j_file) + + j_obj['version'] = version + + j_obj = json.dumps(j_obj, indent=4) + + with open(json_file_name, 'w') as outfile: + outfile.write(j_obj) + # writeToFile(version) takes in version from update functions and writes it to the version file def writeToFile(contents, filename) : file1 = open(filename, 'w') @@ -214,6 +231,7 @@ def readFile(filename) : # 4. Write the update to the changelog file # 5. Clear the branch changelog file # 6. Update the XML version + # 7. Update the composer.json version changelog_file_lines = readFile(changelog_file_name) @@ -225,4 +243,7 @@ def readFile(filename) : writeToFile([], branch_changelog_file_name) - processXML(version_to_write) \ No newline at end of file + processXML(version_to_write) + + processJSON(version_to_write) +