import os import requests import json import subprocess # 获取最新 release 中所有文件的名称 response = requests.get("https://api.github.com/repos/Souma-Sumire/FFXIVChnTextPatch-Souma/releases/latest") if response.status_code == 200: data = response.json() assets = [asset["name"] for asset in data.get("assets", [])] else: print("Failed to fetch latest release files.") exit(1) # 打印文件列表 print("Files to download:") for asset in assets: print(asset) # 检查本地是否已经存在这些文件 for asset in assets: if not os.path.isfile(asset): # 如果本地不存在文件,则下载 print(f"Downloading {asset}...") download_url = f"https://github.com/Souma-Sumire/FFXIVChnTextPatch-Souma/releases/latest/download/{asset}" subprocess.run(["curl", "-LO", download_url]) # 将下载的文件添加到 Git 仓库中 subprocess.run(["git", "add", "."]) # 提交变更 subprocess.run(["git", "commit", "-m", "Add latest release files"]) # 推送到远程仓库 subprocess.run(["git", "push"])