|
| 1 | +import requests |
| 2 | +import os |
| 3 | + |
| 4 | +ASEPRITE_REPOSITORY = "aseprite/aseprite" |
| 5 | +SKIA_REPOSITORY = "aseprite/skia" |
| 6 | +SKIA_RELEASE_FILE_NAME = "Skia-Windows-Release-x64.zip" |
| 7 | + |
| 8 | + |
| 9 | +def get_latest_tag_aseprite(): |
| 10 | + response = requests.get( |
| 11 | + f"https://api.github.com/repos/{ASEPRITE_REPOSITORY}/releases" |
| 12 | + ) |
| 13 | + response_json = response.json() |
| 14 | + |
| 15 | + for release in response_json: |
| 16 | + if "beta" not in release["tag_name"].lower(): |
| 17 | + return release["tag_name"] |
| 18 | + |
| 19 | + return None |
| 20 | + |
| 21 | + |
| 22 | +def save_aseprite_tag(tag): |
| 23 | + with open("version.txt", "w") as f: |
| 24 | + f.write(tag) |
| 25 | + |
| 26 | + |
| 27 | +def clone_aseprite(tag): |
| 28 | + clone_url = f"https://github.com/{ASEPRITE_REPOSITORY}.git" |
| 29 | + git_cmd = f"git clone -b {tag} {clone_url} src/aseprite --depth 1" |
| 30 | + os.system(git_cmd) |
| 31 | + os.system("cd src/aseprite && git submodule update --init --recursive") |
| 32 | + |
| 33 | + |
| 34 | +def get_latest_tag_skia(): |
| 35 | + # response = requests.get(f'https://api.github.com/repos/{SKIA_REPOSITORY}/releases/latest') |
| 36 | + # response_json = response.json() |
| 37 | + # return response_json['tag_name'] |
| 38 | + return "m124-08a5439a6b" |
| 39 | + |
| 40 | + |
| 41 | +def download_skia_for_windows(tag): |
| 42 | + download_url = f"https://github.com/{SKIA_REPOSITORY}/releases/download/{tag}/{SKIA_RELEASE_FILE_NAME}" |
| 43 | + |
| 44 | + file_response = requests.get(download_url) |
| 45 | + file_response.raise_for_status() |
| 46 | + |
| 47 | + with open(f"src/{SKIA_RELEASE_FILE_NAME}", "wb") as f: |
| 48 | + f.write(file_response.content) |
| 49 | + |
| 50 | + os.system(f"7z x src/{SKIA_RELEASE_FILE_NAME} -osrc/skia") |
| 51 | + |
| 52 | + |
| 53 | +if __name__ == "__main__": |
| 54 | + aseprite_tag = get_latest_tag_aseprite() |
| 55 | + clone_aseprite(aseprite_tag) |
| 56 | + save_aseprite_tag(aseprite_tag) |
| 57 | + |
| 58 | + skia_tag = get_latest_tag_skia() |
| 59 | + download_skia_for_windows(skia_tag) |
0 commit comments