Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 39 additions & 37 deletions .github/workflows/jp-loadingbg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,13 @@ jobs:
with:
python-version: "3.11"

- name: Install azlassets (v4.x)
- name: Install azlassets
run: |
python -m pip install --upgrade pip
pip install "azlassets==4.0.0"
pip install azlassets
azl --help

# =============================
# 恢复 azlassets state cache(非常小)
# =============================
# Restore azlassets state cache from previous release
- name: Restore azlassets state cache (if exists)
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down Expand Up @@ -63,33 +61,45 @@ jobs:
else:
print("[patch] VersionType.__hash__ already present:", VT.__hash__)

# Patch 2: remove_asset 支持目录删除(修复 IsADirectoryError)
_orig_remove_asset = updater.remove_asset
def _patched_remove_asset(assetpath):
import pathlib
# azlassets 版本差异:assetpath 可能为 AssetPath 对象(带 .full)
# 或已经是 pathlib.Path
if isinstance(assetpath, pathlib.Path):
p = assetpath
else:
p = pathlib.Path(assetpath.full)
if p.is_dir():
import shutil
shutil.rmtree(p)
print(f"[patch] Removed directory: {p}")
# Patch 2: delete_asset_safe / remove_asset 支持目录删除(修复 IsADirectoryError)
import pathlib
if hasattr(updater, 'remove_asset'):
_orig_func = updater.remove_asset
_func_name = 'remove_asset'
elif hasattr(updater, 'delete_asset_safe'):
_orig_func = updater.delete_asset_safe
_func_name = 'delete_asset_safe'
else:
_orig_func = None
_func_name = None

if _orig_func is not None:
def _patched_func(assetpath):
if isinstance(assetpath, pathlib.Path):
p = assetpath
else:
p = pathlib.Path(assetpath.full)
if p.is_dir():
import shutil
shutil.rmtree(p)
print(f"[patch] Removed directory: {p}")
else:
_orig_func(assetpath)

if _func_name == 'remove_asset':
updater.remove_asset = _patched_func
else:
_orig_remove_asset(assetpath)
updater.remove_asset = _patched_remove_asset
print("[patch] Patched updater.remove_asset to handle directories")
updater.delete_asset_safe = _patched_func
print(f"[patch] Patched updater.{_func_name} to handle directories")
else:
print("[patch] No remove_asset or delete_asset_safe found, skipping directory patch")

# 让 azl 按 CLI 方式运行 download JP
sys.argv = ["azl", "download", "JP"]
azl.main()
PY

# =============================
# 恢复上次 loadingbg_full.zip → last_loadingbg(用于 diff)
# =============================
# Restore previous full snapshot for diff comparison
- name: Restore last loadingbg snapshot (if exists)
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -107,16 +117,12 @@ jobs:
fi
fi

# =============================
# 收集本次 loadingbg(若没更新可能不存在)
# =============================
# Collect current JP loadingbg files
- name: Collect loadingbg
run: |
python scripts/collect_loadingbg.py

# =============================
# diff + zip(你已修过:无 current_loadingbg 也能正常结束)
# =============================
# Diff current vs previous, generate zip archives
- name: Diff and zip
run: |
bash scripts/diff_and_zip.sh
Expand All @@ -132,9 +138,7 @@ jobs:
echo "generated_at=$(date -u)" >> meta.txt
echo "has_diff=${{ steps.diffcheck.outputs.has_diff }}" >> meta.txt

# =============================
# 打包 state cache(只保留逻辑状态,不含 AssetBundles)
# =============================
# Pack azlassets logical state (excluding AssetBundles) for next run
- name: Pack azlassets client state
run: |
rm -rf state_tmp
Expand All @@ -146,9 +150,7 @@ jobs:
fi
tar -cf jp-client-state.tar -C state_tmp ClientAssets

# =============================
# 发布 Release
# =============================
# Publish GitHub Release with all artifacts
- name: Publish Release
uses: softprops/action-gh-release@v2
with:
Expand Down
Loading