diff --git a/.github/scripts/pacther_mover.py b/.github/scripts/pacther_mover.py new file mode 100644 index 000000000..5e902133e --- /dev/null +++ b/.github/scripts/pacther_mover.py @@ -0,0 +1,54 @@ +"""Simple Patch mover""" + +import os +import sys +import shutil +from loguru import logger +from pathlib import Path + +RESOURCEPACK_PATH = Path("pack/assets") + +def ci_formatter(ci: bool): + """ + Log message fomater + + Parameters: + ci (bool): Check if is ci + """ + if ci: + # pylint: disable=line-too-long + log_format = "{time:YYYY-MM-DD HH:mm:ss}{level}{message}" + logger.remove() + logger.add(sys.stderr, format=log_format) + else: + log_format = "{time:YYYY-MM-DD HH:mm:ss} | {level: <8} | {name}:{function}:{line} - {message}" + logger.remove() + logger.add(sys.stderr, format=log_format) + logger.add("loguru.log") + +def patch_mover(): + """ + Simple patch mover + """ + logger.info("🚩 複製補丁") + logger.info("") + for i in Path("MultiVersions/Patcher").iterdir(): + id = i.name + if id.endswith("patch"): + logger.info(f"📂 複製 {id}") + path = Path(f"{RESOURCEPACK_PATH}/{id}/lang") + path.mkdir(parents=True) + shutil.copy(i.joinpath("lang/zh_tw.json"), path) + else: + logger.error(f"⚠️ {id} 不符合資料夾命名規則") + sys.exit(1) + +def main(): + """ + Main! + """ + ci = os.environ.get("CI") + ci_formatter(ci) + patch_mover() + +main() \ No newline at end of file diff --git a/.github/workflows/Reusable-ResourcePacker.yml b/.github/workflows/Reusable-ResourcePacker.yml index 3d4dad993..ca2832bd9 100644 --- a/.github/workflows/Reusable-ResourcePacker.yml +++ b/.github/workflows/Reusable-ResourcePacker.yml @@ -109,6 +109,12 @@ jobs: matrix_version: ${{ inputs.matrix_version }} LOGURU_LEVEL: "INFO" + - name: Move Patch + run: | + poetry run python .github/scripts/pacther_mover.py + env: + LOGURU_LEVEL: "INFO" + - name: Copy misc things run: | cp MultiVersions/configs/pack.mcmeta pack/