From 50233e85f1c819f3d88b6441d78f643257bc9974 Mon Sep 17 00:00:00 2001 From: forchannot Date: Thu, 12 Sep 2024 00:18:25 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20=E5=B0=86zip=E7=A7=BB=E5=8A=A8?= =?UTF-8?q?=E5=88=B0release=E4=B8=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitattributes | 1 - ...e_starrail_res.yml => update_all_file.yml} | 35 ++++++++- .github/workflows/update_file.yml | 38 ---------- .gitignore | 4 +- generate_res_list.py | 76 +++++++++++-------- resources.zip | 3 - star_rail.zip | 3 - update_starrail_res.py | 10 +-- 8 files changed, 84 insertions(+), 86 deletions(-) delete mode 100644 .gitattributes rename .github/workflows/{update_starrail_res.yml => update_all_file.yml} (50%) delete mode 100644 .github/workflows/update_file.yml delete mode 100644 resources.zip delete mode 100644 star_rail.zip diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 486a2325..00000000 --- a/.gitattributes +++ /dev/null @@ -1 +0,0 @@ -*.zip filter=lfs diff=lfs merge=lfs -text diff --git a/.github/workflows/update_starrail_res.yml b/.github/workflows/update_all_file.yml similarity index 50% rename from .github/workflows/update_starrail_res.yml rename to .github/workflows/update_all_file.yml index e5635b2f..1de15ff6 100644 --- a/.github/workflows/update_starrail_res.yml +++ b/.github/workflows/update_all_file.yml @@ -1,11 +1,16 @@ -name: Update Star Rail Resources +name: Update Files on: workflow_dispatch: + push: + branches: [main] + paths: + - "fonts/**" + - "LittlePaimon/**" jobs: update: - name: Update Star Rail Resources + name: Update Files runs-on: ubuntu-latest steps: - name: Checkout repo @@ -27,7 +32,7 @@ jobs: run: | python update_starrail_res.py - - name: Update Files + - name: Update files run: | python generate_res_list.py @@ -36,5 +41,27 @@ jobs: with: author_name: github-actions[bot] author_email: github-actions[bot]@users.noreply.github.com - message: ":wrench: 自动更新星铁资源" + message: ":wrench: 自动更新资源列表" add: . + + - uses: dev-drprasad/delete-tag-and-release@v1.1 + with: + tag_name: Resources-V1.0 + github_token: ${{ secrets.GITHUB_TOKEN }} + + - name: Tag Repo + uses: richardsimko/update-tag@v1 + with: + tag_name: Resources-V1.0 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Upload Resources + uses: softprops/action-gh-release@v2 + if: ${{ success() }} + with: + tag_name: Resources-V1.0 + append_body: true + files: | + resources.zip + star_rail.zip diff --git a/.github/workflows/update_file.yml b/.github/workflows/update_file.yml deleted file mode 100644 index d62b2d09..00000000 --- a/.github/workflows/update_file.yml +++ /dev/null @@ -1,38 +0,0 @@ -name: Update Files - -on: - push: - branches: [ main ] - paths: - - 'fonts/**' - - 'LittlePaimon/**' - - workflow_dispatch: - -jobs: - update: - name: Update Files - runs-on: ubuntu-latest - steps: - - name: Checkout repo - uses: actions/checkout@master - - - name: Setup python - uses: actions/setup-python@v1 - with: - python-version: 3.9 - - - name: Update files - run: | - python generate_res_list.py - - - - name: Commit changes - uses: EndBug/add-and-commit@v9 - with: - author_name: github-actions[bot] - author_email: github-actions[bot]@users.noreply.github.com - message: ':wrench: 自动更新资源列表' - add: | - 'resources_list.json' - 'resources.zip' \ No newline at end of file diff --git a/.gitignore b/.gitignore index 0a5c6728..423b91b8 100644 --- a/.gitignore +++ b/.gitignore @@ -10,4 +10,6 @@ LittlePaimon/furniture LittlePaimon/material LittlePaimon/genshin_map/results genshin_guide/guide/download.py -.idea \ No newline at end of file +.idea +resources.zip +star_rail.zip \ No newline at end of file diff --git a/generate_res_list.py b/generate_res_list.py index 2d8e131f..7f926b34 100644 --- a/generate_res_list.py +++ b/generate_res_list.py @@ -3,58 +3,72 @@ import zipfile from pathlib import Path -font_path = Path(__file__).parent / 'fonts' -res_path = Path(__file__).parent / 'LittlePaimon' -img_path = Path(__file__).parent / 'genshin_img' +font_path = Path(__file__).parent / "fonts" +res_path = Path(__file__).parent / "LittlePaimon" +img_path = Path(__file__).parent / "genshin_img" -exclude_path = ['avatar', 'avatar_side', 'talent', 'weapon', 'splash', 'results', 'material', 'other', 'furniture'] -unlock_list = ['general'] +exclude_path = [ + "avatar", + "avatar_side", + "talent", + "weapon", + "splash", + "results", + "material", + "other", + "furniture", +] +unlock_list = ["general"] emoticons_temp = [] -file_list = [{ - 'path': f'{file.parent.name}/{file.name}', - 'hash': hashlib.md5(file.read_bytes()).hexdigest(), - 'lock': True -} for file in font_path.iterdir()] +file_list = [ + { + "path": f"{file.parent.name}/{file.name}", + "hash": hashlib.md5(file.read_bytes()).hexdigest(), + "lock": True, + } + for file in font_path.iterdir() +] this_path = str(Path().absolute()) -for file in res_path.rglob('*'): +for file in res_path.rglob("*"): if not file.is_file(): continue if file.parent.name not in exclude_path: - if file.parent.name.startswith('emoticons'): - if file.name.split('-')[0] in emoticons_temp: + if file.parent.name.startswith("emoticons"): + if file.name.split("-")[0] in emoticons_temp: continue else: - emoticons_temp.append(file.name.split('-')[0]) - if file.parent.name.startswith('artifact') and file.name.startswith('UI'): + emoticons_temp.append(file.name.split("-")[0]) + if file.parent.name.startswith("artifact") and file.name.startswith("UI"): continue file_list.append({ - 'path': str(file).replace(this_path, '').replace('\\', '/').lstrip('/'), - 'hash': hashlib.md5(file.read_bytes()).hexdigest(), - 'lock': False if file.parent.name in unlock_list else True + "path": str(file).replace(this_path, "").replace("\\", "/").lstrip("/"), + "hash": hashlib.md5(file.read_bytes()).hexdigest(), + "lock": False if file.parent.name in unlock_list else True, }) -with open('resources_list.json', 'w', encoding='utf-8') as f: +with open("resources_list.json", "w", encoding="utf-8") as f: json.dump(file_list, f, ensure_ascii=False, indent=2) -img_list = {chara.name: [img.name for img in chara.iterdir()] for chara in img_path.iterdir()} +img_list = { + chara.name: [img.name for img in chara.iterdir()] for chara in img_path.iterdir() +} -with open('genshin_img_list.json', 'w', encoding='utf-8') as f: +with open("genshin_img_list.json", "w", encoding="utf-8") as f: json.dump(img_list, f, ensure_ascii=False, indent=2) -# 暂时关闭zip打包,等待解决lfs超出大小问题后恢复 -# resources_zip_path = Path() / 'resources.zip' -# resources_zip = zipfile.ZipFile(resources_zip_path, 'w', zipfile.ZIP_DEFLATED) +resources_zip_path = Path() / "resources.zip" +resources_zip = zipfile.ZipFile(resources_zip_path, "w", zipfile.ZIP_DEFLATED) -# for file in Path('fonts').iterdir(): -# resources_zip.write(file) -# for file in Path('LittlePaimon').rglob('*'): -# exclude_path_ = exclude_path + ["character_portrait"] -# if file.name not in exclude_path_ and file.parent.name not in exclude_path_: -# resources_zip.write(file) +for file in Path("fonts").iterdir(): + resources_zip.write(file) +for file in Path("LittlePaimon").rglob("*"): + exclude_path_ = exclude_path + ["character_portrait"] + if file.name not in exclude_path_ and file.parent.name not in exclude_path_: + resources_zip.write(file) -# resources_zip.close() +resources_zip.close() diff --git a/resources.zip b/resources.zip deleted file mode 100644 index dca8aa68..00000000 --- a/resources.zip +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:8178484bc5a383246e2fbc07e293eda6a370adf0809e633339283bf774c82a0b -size 107973732 diff --git a/star_rail.zip b/star_rail.zip deleted file mode 100644 index fae81d4c..00000000 --- a/star_rail.zip +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:880752b9d4d232eedd0ef5dd924de69c2b16a336b2f40c845d974f55c93128b1 -size 19126764 diff --git a/update_starrail_res.py b/update_starrail_res.py index 632bee18..b3017c3d 100644 --- a/update_starrail_res.py +++ b/update_starrail_res.py @@ -1,6 +1,6 @@ import asyncio import os -# import zipfile +import zipfile from pathlib import Path import httpx @@ -88,8 +88,8 @@ async def limited_download(client, url, semaphore, pbar): if __name__ == "__main__": asyncio.run(download_res()) - # path = this_path + "/star_rail.zip" - # with zipfile.ZipFile(path, "w") as zf: - # for file in star_rail_res_path.rglob("*"): - # zf.write(file, file.relative_to(star_rail_res_path)) + path = this_path + "/star_rail.zip" + with zipfile.ZipFile(path, "w") as zf: + for file in star_rail_res_path.rglob("*"): + zf.write(file, file.relative_to(star_rail_res_path)) print("StarRailRes updated.")