添加更新云控的流程

main
zhouzhuo 2025-08-04 20:07:41 +08:00
parent 467ce252a2
commit c89f1149a9
2 changed files with 53 additions and 11 deletions

View File

@ -215,6 +215,7 @@ class FirebaseHelper:
index = index + 1 index = index + 1
def update_remote_config(self, group, condition, main_key, sub_key, value, is_string=False): def update_remote_config(self, group, condition, main_key, sub_key, value, is_string=False):
## sub_key 该云控里面的json的某个参数的key
try: try:
etag = self.get_remote_value() etag = self.get_remote_value()
online_txt = "" online_txt = ""
@ -257,9 +258,9 @@ class FirebaseHelper:
if __name__ == "__main__": if __name__ == "__main__":
helper = FirebaseHelper() helper = FirebaseHelper()
blob1 = helper.get_file("Bundles/Android/Level/14cd688726c4d6b75b669990b16552e4.bundle") # blob1 = helper.get_file("Bundles/Android/Level/14cd688726c4d6b75b669990b16552e4.bundle")
# blob2 = helper.get_file("Bundles/Android/Level/thesmiths/thesmiths_hcq20231212_1/a6d87302cb3f.bundle") # blob2 = helper.get_file("Bundles/Android/Level/thesmiths/thesmiths_hcq20231212_1/a6d87302cb3f.bundle")
print(blob1 is None) # print(blob1 is None)
# print(blob2 is None) # print(blob2 is None)
etag = helper.get_remote_value() etag = helper.get_remote_value()
print(etag) print(etag)

View File

@ -29,13 +29,17 @@ sys.path.insert(0, os.path.join(tools_path, "config_convert"))
sys.path.insert(0, os.path.join(tools_path, "build_package")) sys.path.insert(0, os.path.join(tools_path, "build_package"))
platform = "Android" platform = "Android"
env = "release"
if len(sys.argv) > 1: if len(sys.argv) > 1:
platform = sys.argv[1] platform = sys.argv[1]
if len(sys.argv) > 1:
env = sys.argv[2]
from google_drive.google_sheet import GoogleSheetHelper from google_drive.google_sheet import GoogleSheetHelper
from firebase.firebase_helper import FirebaseHelper from firebase.firebase_helper import FirebaseHelper
from notification_helper import NotificationHelper from notification_helper import NotificationHelper
import upload_firebase_storage import upload_firebase_storage
import config as config
notification_helper = NotificationHelper() notification_helper = NotificationHelper()
# 尝试导入 utils 模块 # 尝试导入 utils 模块
@ -67,6 +71,7 @@ ASSET_PATH = os.path.abspath(os.path.join(curr_dir, "../profile_asset"))
# Unity执行文件路径 # Unity执行文件路径
UNITY_PATH = "/Applications/Unity/Hub/Editor/2021.3.45f1/Unity.app/Contents/MacOS/Unity" UNITY_PATH = "/Applications/Unity/Hub/Editor/2021.3.45f1/Unity.app/Contents/MacOS/Unity"
RESOURCE_ROOT = os.path.abspath(os.path.join(curr_dir, "../build_profile_package/Bundles")) RESOURCE_ROOT = os.path.abspath(os.path.join(curr_dir, "../build_profile_package/Bundles"))
REMOTE_CONFIG_FILE = os.path.join(curr_dir, "../../FindObjectBundleBuilder/Tools/firebase/remote_config.json")
json_path = os.path.abspath(os.path.join(curr_dir, 'temp_config/profile.json')) json_path = os.path.abspath(os.path.join(curr_dir, 'temp_config/profile.json'))
google_sheet_file_name = 'FIndObject装饰配置表' google_sheet_file_name = 'FIndObject装饰配置表'
@ -328,31 +333,67 @@ def build_package():
return is_build_success, bundle_file_path return is_build_success, bundle_file_path
def upload_package(is_build_success, ab_path): def upload_package(is_build_success, ab_dir):
''' 上传资源包到storage ''' ''' 上传资源包到storage '''
print(f"ab_path {ab_path}") print(f"ab_path {ab_dir}")
if is_build_success: if is_build_success:
print(f"开始上传ab包到firebase") print(f"开始上传ab包到firebase")
storage_path = "Bundles/{}".format(platform) + '/Profile' storage_path = "Bundles/{}".format(platform) + f'/Profile/profile-{env}.bundle'
# 从ab_dir文件夹下获取所有.bundle文件
bundle_file = ""
if os.path.exists(ab_dir):
for root, dirs, files in os.walk(ab_dir):
for file in files:
if file.endswith('.bundle'):
bundle_file_path = os.path.join(root, file)
bundle_file = bundle_file_path
print(f"找到bundle文件: {bundle_file_path}")
break
if bundle_file == "":
print(f"没有找到资源包")
raise Exception("没有找到资源包")
tmUploadPackage1 = time.time() tmUploadPackage1 = time.time()
helper = FirebaseHelper() generation = helper.upload_file(storage_path, bundle_file)
upload_firebase_storage.upload_directory(helper,storage_path,ab_path, ".version") # upload_firebase_storage.upload_directory(helper,storage_path,ab_dir, ".version")
tmUploadPackage2 = time.time() tmUploadPackage2 = time.time()
print(f"firebase上传耗时{tmUploadPackage2 - tmUploadPackage1}") print(f"firebase上传耗时{tmUploadPackage2 - tmUploadPackage1}")
return generation, storage_path
def refresh_remote_config():
def refresh_remote_config(url):
''' 刷新云控 ''' ''' 刷新云控 '''
remote_key = "profile_asset_config"
# with open(REMOTE_CONFIG_FILE, "r") as f:
# online_txt = f.read()
#
# if online_txt != None and online_txt != "":
# online_json = json.loads(online_txt)
#
# value = online_json["parameters"][remote_key]["defaultValue"]["value"]
# value_json = json.loads(value)
# value_json[env] = url
helper.update_remote_config(None, None, remote_key, env, url)
if __name__ == "__main__": if __name__ == "__main__":
# platform = "Android" # platform = "Android"
# env = 'debug'
print(1) print(1)
helper = FirebaseHelper()
get_json() get_json()
copy_file_to_unity() copy_file_to_unity()
tmBuildPackage1 = time.time() tmBuildPackage1 = time.time()
is_build_success, ab_path = build_package() is_build_success, ab_dir = build_package()
tmBuildPackage2 = time.time() tmBuildPackage2 = time.time()
print(f" unity打包耗时{tmBuildPackage2 - tmBuildPackage1}") print(f" unity打包耗时{tmBuildPackage2 - tmBuildPackage1}")
time.sleep(1) time.sleep(1)
upload_package(is_build_success, ab_path) generation, storage_path = upload_package(is_build_success, ab_dir)
url = f"{config.cdn}/{storage_path}?generation={generation}"
print(url)
time.sleep(1)
refresh_remote_config(url)
print(2)