Skip to content

JP loadingbg sync (state-cache, azl v4) #23

JP loadingbg sync (state-cache, azl v4)

JP loadingbg sync (state-cache, azl v4) #23

Workflow file for this run

name: JP loadingbg sync (state-cache)
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
# =============================
# 恢复 azlassets 状态 cache(非常小)
# =============================
- name: Restore azlassets state cache (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
STATE_URL=$(jq -r '.assets[] | select(.name=="jp-client-state.tar") | .browser_download_url' release.json)
if [ -n "$STATE_URL" ] && [ "$STATE_URL" != "null" ]; then
echo "Restoring azlassets state cache..."
curl -L -o jp-client-state.tar "$STATE_URL"
tar -xf jp-client-state.tar
else
echo "No state cache found, cold-ish start."
fi
fi
# =============================
# downloader
# =============================
- name: Download JP assets
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
# =============================
# ✅ 只打包 azlassets 状态(极小)
# =============================
- name: Pack azlassets client state
run: |
mkdir -p state_tmp/ClientAssets
cp -r ClientAssets/JP state_tmp/ClientAssets/
rm -rf state_tmp/ClientAssets/JP/AssetBundles
tar -cf jp-client-state.tar -C state_tmp ClientAssets
# =============================
# 发布 Release(稳定)
# =============================
- name: Publish Release
uses: softprops/action-gh-release@v2
with:
tag_name: jp-loadingbg-latest
name: JP loadingbg latest
body: |
JP loadingbg sync with azlassets state cache.
- jp-client-state.tar : azlassets logical state (safe cache)
- loadingbg_full.zip : latest full snapshot
- loadingbg_diff.zip : only when updated
files: |
jp-client-state.tar
loadingbg_full.zip
meta.txt
${{ steps.diffcheck.outputs.has_diff == 'true' && 'loadingbg_diff.zip' || '' }}