JP loadingbg sync (state-cache, azl v4) #14
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: JP loadingbg sync (cached, split) | |
| permissions: | |
| contents: write | |
| on: | |
| workflow_dispatch: | |
| jobs: | |
| sync: | |
| runs-on: ubuntu-latest | |
| steps: | |
| # ============================= | |
| # 基础环境 | |
| # ============================= | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.11" | |
| - name: Install azlassets | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install azlassets | |
| # ============================= | |
| # 恢复 JP 客户端缓存(分卷) | |
| # ============================= | |
| - name: Restore JP client cache (split, if exists) | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| API="https://api.github.com/repos/${{ github.repository }}/releases/tags/jp-loadingbg-latest" | |
| if curl -fsSL -H "Authorization: token $GITHUB_TOKEN" "$API" > release.json; then | |
| PARTS=$(jq -r '.assets[] | select(.name|test("^jp-client-cache.part-")) | .browser_download_url' release.json) | |
| if [ -n "$PARTS" ]; then | |
| echo "Restoring JP client cache from split parts..." | |
| mkdir -p cache_parts | |
| for url in $PARTS; do | |
| fname=$(basename "$url") | |
| curl -L "$url" -o "cache_parts/$fname" | |
| done | |
| cat cache_parts/jp-client-cache.part-* | tar -I zstd -xf - | |
| else | |
| echo "No cache parts found, cold start." | |
| fi | |
| else | |
| echo "No previous release found, cold start." | |
| fi | |
| # ============================= | |
| # downloader(热/冷启动) | |
| # ============================= | |
| - name: Download JP assets (incremental) | |
| run: | | |
| python -m downloader JP | |
| # ============================= | |
| # 恢复上次 loadingbg(用于 diff) | |
| # ============================= | |
| - name: Restore last loadingbg snapshot (if exists) | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| API="https://api.github.com/repos/${{ github.repository }}/releases/tags/jp-loadingbg-latest" | |
| if curl -fsSL -H "Authorization: token $GITHUB_TOKEN" "$API" > release.json; then | |
| FULL_URL=$(jq -r '.assets[] | select(.name=="loadingbg_full.zip") | .browser_download_url' release.json) | |
| if [ -n "$FULL_URL" ] && [ "$FULL_URL" != "null" ]; then | |
| curl -L -o loadingbg_full.zip "$FULL_URL" | |
| unzip -q loadingbg_full.zip | |
| mv current_loadingbg last_loadingbg | |
| fi | |
| fi | |
| # ============================= | |
| # 收集 loadingbg | |
| # ============================= | |
| - name: Collect loadingbg | |
| run: | | |
| python scripts/collect_loadingbg.py | |
| # ============================= | |
| # diff + zip | |
| # ============================= | |
| - name: Diff and zip | |
| run: | | |
| bash scripts/diff_and_zip.sh | |
| - name: Read diff status | |
| id: diffcheck | |
| run: | | |
| echo "has_diff=$(cat has_diff.flag)" >> $GITHUB_OUTPUT | |
| # ============================= | |
| # 元信息 | |
| # ============================= | |
| - name: Generate meta info | |
| run: | | |
| echo "client=JP" > meta.txt | |
| echo "generated_at=$(date -u)" >> meta.txt | |
| echo "has_diff=${{ steps.diffcheck.outputs.has_diff }}" >> meta.txt | |
| # ============================= | |
| # 瘦身 ClientAssets,防止爆盘 | |
| # ============================= | |
| - name: Prune JP client cache (reduce disk usage) | |
| run: | | |
| cd ClientAssets/JP | |
| rm -rf ClientExtract || true | |
| rm -rf tmp || true | |
| cd ../.. | |
| # ============================= | |
| # 打包并分卷缓存(<2GB/卷) | |
| # ============================= | |
| - name: Pack JP client cache (split) | |
| run: | | |
| rm -f jp-client-cache.part-* | |
| tar -I zstd -cf - ClientAssets/JP | split -b 1900M - jp-client-cache.part- | |
| # ============================= | |
| # 发布 Release(分卷 cache) | |
| # ============================= | |
| - name: Publish Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: jp-loadingbg-latest | |
| name: JP loadingbg latest | |
| body: | | |
| Manual sync of Azur Lane JP loadingbg assetbundles. | |
| Changes detected: ${{ steps.diffcheck.outputs.has_diff }} | |
| - loadingbg_full.zip : latest full snapshot | |
| - loadingbg_diff.zip : only when updated | |
| - jp-client-cache.part-* : JP client cache (split, for fast incremental sync) | |
| files: | | |
| jp-client-cache.part-* | |
| loadingbg_full.zip | |
| meta.txt | |
| ${{ steps.diffcheck.outputs.has_diff == 'true' && 'loadingbg_diff.zip' || '' }} |