Skip to content

Commit

Permalink
Add logic to auto-update export json files (#1083)
Browse files Browse the repository at this point in the history
  • Loading branch information
a-maurice authored Aug 13, 2024
1 parent 721f9b5 commit 63eedac
Show file tree
Hide file tree
Showing 14 changed files with 699 additions and 270 deletions.
32 changes: 32 additions & 0 deletions scripts/update_versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
Example usage (in root folder):
python scripts/update_versions.py --unity_sdk_version=<version number>
"""
import json
import glob
import os
import re
import requests
Expand Down Expand Up @@ -214,6 +216,35 @@ def update_readme(unity_sdk_version):
with open(readme_path, "w") as fout:
fout.write(replacement)

def update_json_version(json_path, new_version):
"""
Updates the version number associated with "com.google.external-dependency-manager" in a JSON file.
Args:
json_path (str): The path to the JSON file to be modified.
new_version (str): The new version number to be set.
"""

with open(json_path, 'r') as file:
data = json.load(file)

target_key = "com.google.external-dependency-manager"
if target_key in data:
data[target_key] = new_version

with open(json_path, 'w') as file:
json.dump(data, file, indent=2) # Indentation for better readability

def update_export_json_files():
jar_version = get_latest_repo_tag('googlesamples/unity-jar-resolver')
jar_version = jar_version.lstrip("v") # jar resolver need to strip "v" from the tag
primary_path = os.path.join(os.getcwd(), 'unity_packer', 'exports.json')
update_json_version(primary_path, jar_version)
json_dir = os.path.join(os.getcwd(), 'unity_packer', 'debug_single_export_json')
for json_file in glob.glob(os.path.join(json_dir, '*.json')):
update_json_version(json_file, jar_version)


def main(argv):
if len(argv) > 1:
raise app.UsageError('Too many command-line arguments.')
Expand All @@ -224,6 +255,7 @@ def main(argv):
update_unity_version(FLAGS.unity_sdk_version)
update_android_deps()
update_readme(FLAGS.unity_sdk_version)
update_export_json_files()

if __name__ == '__main__':
app.run(main)
4 changes: 2 additions & 2 deletions unity_packer/debug_single_export_json/analytics.json
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@
"manifest": {
"unity": "2020.1",
"dependencies": {
"com.google.external-dependency-manager": "1.2.177"
"com.google.external-dependency-manager": "1.2.182"
}
}
}
Expand Down Expand Up @@ -343,4 +343,4 @@
}
}
]
}
}
4 changes: 2 additions & 2 deletions unity_packer/debug_single_export_json/app_check.json
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@
"manifest": {
"unity": "2020.1",
"dependencies": {
"com.google.external-dependency-manager": "1.2.177"
"com.google.external-dependency-manager": "1.2.182"
}
}
}
Expand Down Expand Up @@ -333,4 +333,4 @@
}
}
]
}
}
4 changes: 2 additions & 2 deletions unity_packer/debug_single_export_json/auth.json
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@
"manifest": {
"unity": "2020.1",
"dependencies": {
"com.google.external-dependency-manager": "1.2.177"
"com.google.external-dependency-manager": "1.2.182"
}
}
}
Expand Down Expand Up @@ -342,4 +342,4 @@
}
}
]
}
}
4 changes: 2 additions & 2 deletions unity_packer/debug_single_export_json/crashlytics.json
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@
"manifest": {
"unity": "2020.1",
"dependencies": {
"com.google.external-dependency-manager": "1.2.177"
"com.google.external-dependency-manager": "1.2.182"
}
}
}
Expand Down Expand Up @@ -339,4 +339,4 @@
}
}
]
}
}
4 changes: 2 additions & 2 deletions unity_packer/debug_single_export_json/database.json
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@
"manifest": {
"unity": "2020.1",
"dependencies": {
"com.google.external-dependency-manager": "1.2.177"
"com.google.external-dependency-manager": "1.2.182"
}
}
}
Expand Down Expand Up @@ -356,4 +356,4 @@
}
}
]
}
}
4 changes: 2 additions & 2 deletions unity_packer/debug_single_export_json/dynamic_links.json
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@
"manifest": {
"unity": "2020.1",
"dependencies": {
"com.google.external-dependency-manager": "1.2.177"
"com.google.external-dependency-manager": "1.2.182"
}
}
}
Expand Down Expand Up @@ -315,4 +315,4 @@
}
}
]
}
}
4 changes: 2 additions & 2 deletions unity_packer/debug_single_export_json/firestore.json
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@
"manifest": {
"unity": "2020.1",
"dependencies": {
"com.google.external-dependency-manager": "1.2.177"
"com.google.external-dependency-manager": "1.2.182"
}
}
}
Expand Down Expand Up @@ -338,4 +338,4 @@
}
}
]
}
}
4 changes: 2 additions & 2 deletions unity_packer/debug_single_export_json/functions.json
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@
"manifest": {
"unity": "2020.1",
"dependencies": {
"com.google.external-dependency-manager": "1.2.177"
"com.google.external-dependency-manager": "1.2.182"
}
}
}
Expand Down Expand Up @@ -337,4 +337,4 @@
}
}
]
}
}
4 changes: 2 additions & 2 deletions unity_packer/debug_single_export_json/installations.json
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@
"manifest": {
"unity": "2020.1",
"dependencies": {
"com.google.external-dependency-manager": "1.2.177"
"com.google.external-dependency-manager": "1.2.182"
}
}
}
Expand Down Expand Up @@ -337,4 +337,4 @@
}
}
]
}
}
4 changes: 2 additions & 2 deletions unity_packer/debug_single_export_json/messaging.json
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@
"manifest": {
"unity": "2020.1",
"dependencies": {
"com.google.external-dependency-manager": "1.2.177"
"com.google.external-dependency-manager": "1.2.182"
}
}
}
Expand Down Expand Up @@ -375,4 +375,4 @@
}
}
]
}
}
4 changes: 2 additions & 2 deletions unity_packer/debug_single_export_json/remote_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@
"manifest": {
"unity": "2020.1",
"dependencies": {
"com.google.external-dependency-manager": "1.2.177"
"com.google.external-dependency-manager": "1.2.182"
}
}
}
Expand Down Expand Up @@ -342,4 +342,4 @@
}
}
]
}
}
4 changes: 2 additions & 2 deletions unity_packer/debug_single_export_json/storage.json
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@
"manifest": {
"unity": "2020.1",
"dependencies": {
"com.google.external-dependency-manager": "1.2.177"
"com.google.external-dependency-manager": "1.2.182"
}
}
}
Expand Down Expand Up @@ -360,4 +360,4 @@
}
}
]
}
}
Loading

0 comments on commit 63eedac

Please sign in to comment.