From 3885c8a5d44a2004a16598eb9eeb35343bbe56e0 Mon Sep 17 00:00:00 2001 From: andresmr Date: Tue, 2 Jan 2024 14:45:02 +0100 Subject: [PATCH] run script with params --- .github/workflows/release-start.yml | 2 +- scripts/updateVersionName.py | 35 +++++++++++++++-------------- 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/.github/workflows/release-start.yml b/.github/workflows/release-start.yml index c07682a018c..43439ed8693 100644 --- a/.github/workflows/release-start.yml +++ b/.github/workflows/release-start.yml @@ -34,7 +34,7 @@ jobs: pip install toml - name: Run Python script to update base branch version - run: python scripts/updateVersionName.py + run: python scripts/updateVersionName.py inputs.version_name # override vName with new version # - name: Create release branch diff --git a/scripts/updateVersionName.py b/scripts/updateVersionName.py index 2335a1dc198..4a2b5119b74 100644 --- a/scripts/updateVersionName.py +++ b/scripts/updateVersionName.py @@ -1,28 +1,29 @@ import toml -import os +# import os +import sys - -file_path = os.path.join('gradle', 'libs.versions.toml') +# file_path = os.path.join('gradle', 'libs.versions.toml') +file_path = 'gradle/libs.versions.toml' # Load the TOML file with open(file_path, 'r') as file: data = toml.load(file) -# print("Data dictionary:", data) - # Print the current value of vName current_vName = data['versions']['vName'] print("Current value of vName:", current_vName) -# Update the desired value -data['versions']['vName'] = '2.10' - -# Save the changes back to the file -with open(file_path, 'w') as file: - toml.dump(data, file) - -# validate changes -with open(file_path, 'r') as file: - updated_data = toml.load(file) - -print("New value of vName:", data['versions']['vName']) +# Check if a new version is provided as a command-line argument +if len(sys.argv) > 1: + new_vName_value = sys.argv[1] + # Update the 'vName' value in the data dictionary + data['versions']['vName'] = new_vName_value + # Print the updated value + print("Updated value of vName:", new_vName_value) + + # Save the updated data back to the TOML file + with open(file_path, 'w') as file: + toml.dump(data, file) + print("File updated successfully!") +else: + print("No new version provided. To update the version, pass the new version as a command-line argument.")