diff --git a/.github/workflows/res-update-game.yml b/.github/workflows/res-update-game.yml index 8becf9184c..9af06091f7 100644 --- a/.github/workflows/res-update-game.yml +++ b/.github/workflows/res-update-game.yml @@ -129,7 +129,7 @@ jobs: # needs: [clone-resources-official, clone-resources-overseas, clone-resources-txwy] if: github.repository_owner == 'MaaAssistantArknights' - runs-on: windows-latest + runs-on: ubuntu-latest steps: - name: Checkout MAA uses: actions/checkout@v5 @@ -140,55 +140,73 @@ jobs: show-progress: false fetch-depth: 3 - - name: Restore ResourceUpdater.exe from cache - id: cache-resupd + - name: Restore ResourceUpdater from cache + id: resupd-cache uses: actions/cache/restore@v4 with: - key: Resource-updater-CMake-${{ hashFiles('./tools/ResourceUpdater/main.cpp') }} + key: ResourceUpdater-${{ runner.os }}-${{ hashFiles('tools/ResourceUpdater/main.cpp') }} path: | - ./tools/ResourceUpdater/opencv_world4_maa.dll - ./tools/ResourceUpdater/ResourceUpdater.exe + ./tools/ResourceUpdater/libc++.so.1 + ./tools/ResourceUpdater/libc++abi.so.1 + ./tools/ResourceUpdater/libopencv_world4.so.411 + ./tools/ResourceUpdater/libunwind.so.1 + ./tools/ResourceUpdater/ResourceUpdater - name: Cache MaaDeps - if: steps.cache-resupd.outputs.cache-hit != 'true' - id: cache-maadeps + if: steps.resupd-cache.outputs.cache-hit != 'true' + id: maadeps-cache uses: actions/cache@v4 with: path: | ./MaaDeps - key: ${{ runner.os }}-x64-maadeps-${{ hashFiles('./tools/maadeps-download.py') }} + key: ${{ runner.os }}-x64-maadeps-${{ hashFiles('tools/maadeps-download.py', 'tools/linux-toolchain-download.py') }} - name: Bootstrap MaaDeps - if: steps.cache-resupd.outputs.cache-hit != 'true' && steps.cache-maadeps.outputs.cache-hit != 'true' + if: steps.resupd-cache.outputs.cache-hit != 'true' && steps.maadeps-cache.outputs.cache-hit != 'true' env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - python3 tools/maadeps-download.py x64-windows + python3 tools/maadeps-download.py x64-linux + python3 tools/linux-toolchain-download.py x64 + + - name: Install llvm-20 + if: steps.resupd-cache.outputs.cache-hit != 'true' + run: | + wget https://apt.llvm.org/llvm.sh + chmod +x llvm.sh + sudo ./llvm.sh 20 - name: Config cmake - if: steps.cache-resupd.outputs.cache-hit != 'true' + if: steps.resupd-cache.outputs.cache-hit != 'true' run: | mkdir -p build - cmake -B build -DCMAKE_BUILD_TYPE=Release -DMAADEPS_TRIPLET='maa-x64-windows' -DBUILD_WPF_GUI=OFF -DBUILD_RES_UPDATER=ON + cmake -B build \ + -DCMAKE_BUILD_TYPE=Release \ + -DMAADEPS_TRIPLET='maa-x64-linux' \ + -DBUILD_RES_UPDATER=ON \ + -DCMAKE_TOOLCHAIN_FILE=cmake/linux/maa-x64-linux-toolchain.cmake - - name: Build Resource Updater - if: steps.cache-resupd.outputs.cache-hit != 'true' + - name: Build + if: steps.resupd-cache.outputs.cache-hit != 'true' run: | - cmake --build build --target ResourceUpdater --config Release --parallel $env:NUMBER_OF_PROCESSORS + cmake --build build --config Release --parallel $(nproc) - - name: Install Resource Updater - if: steps.cache-resupd.outputs.cache-hit != 'true' + - name: Install + if: steps.resupd-cache.outputs.cache-hit != 'true' run: | - cmake --install build --component ResourceUpdater --config Release --prefix tools/ResourceUpdater + cmake --install build --config Release --prefix tools/ResourceUpdater - - name: Save ResourceUpdater.exe to cache - if: always() && steps.cache-resupd.outputs.cache-hit != 'true' + - name: Save ResourceUpdater to cache + if: always() && steps.resupd-cache.outputs.cache-hit != 'true' uses: actions/cache/save@v4 with: - key: Resource-updater-CMake-${{ hashFiles('./tools/ResourceUpdater/main.cpp') }} + key: ResourceUpdater-${{ runner.os }}-${{ hashFiles('tools/ResourceUpdater/main.cpp') }} path: | - ./tools/ResourceUpdater/opencv_world4_maa.dll - ./tools/ResourceUpdater/ResourceUpdater.exe + ./tools/ResourceUpdater/libc++.so.1 + ./tools/ResourceUpdater/libc++abi.so.1 + ./tools/ResourceUpdater/libopencv_world4.so.411 + ./tools/ResourceUpdater/libunwind.so.1 + ./tools/ResourceUpdater/ResourceUpdater - name: Download txwy id: download-txwy @@ -201,7 +219,7 @@ jobs: - name: Delay txwy if: steps.download-txwy.outcome == 'failure' run: | - Start-Sleep -s 20 + sleep 10 - name: Re-download txwy if: steps.download-txwy.outcome == 'failure' @@ -221,7 +239,7 @@ jobs: - name: Delay Overseas if: steps.download-overseas.outcome == 'failure' run: | - Start-Sleep -s 20 + sleep 10 - name: Re-download Overseas if: steps.download-overseas.outcome == 'failure' @@ -241,7 +259,7 @@ jobs: - name: Delay Official if: steps.download-official.outcome == 'failure' run: | - Start-Sleep -s 20 + sleep 10 - name: Re-download Official if: steps.download-official.outcome == 'failure' @@ -252,13 +270,13 @@ jobs: - name: Run Resource Updater run: | - ./tools/ResourceUpdater/ResourceUpdater.exe + ./tools/ResourceUpdater/ResourceUpdater - name: Task Sorting id: task_sorting run: | python3 tools/TaskSorter/TaskSorter.py - Write-Output "gitdiff=$(git diff --name-only --diff-filter=ACM 2>$null | Select-String -Pattern '\.json$' -List)" >> $env:GITHUB_OUTPUT + echo "gitdiff=$(echo $(git diff --name-only --diff-filter=ACM 2>/dev/null | grep '\.json$'))" >> $GITHUB_OUTPUT - name: Run prettier uses: Nerixyz/actionsx-prettier@v3-adj @@ -267,7 +285,8 @@ jobs: - name: Update version.json date if necessary id: update_version - run: pwsh tools/ResourceUpdater/version.ps1 + run: | + tools/ResourceUpdater/version.sh - name: Setup python if: steps.update_version.outputs.contains_png == 'True' @@ -307,19 +326,19 @@ jobs: git config user.email "41898282+github-actions[bot]@users.noreply.github.com" git add . - $commit_msg = "${{ github.event.inputs.commit_message }}" - if ([string]::IsNullOrWhiteSpace($commit_msg)) { - $commit_msg = "chore: Auto Update Game Resources - $(Get-Date -Format 'yyyy-MM-dd')" - } else { - $commit_msg = $commit_msg.Trim() - } + commit_msg="${{ github.event.inputs.commit_message }}" + if [ -z "$commit_msg" ]; then + commit_msg="chore: Auto Update Game Resources - $(date '+%Y-%m-%d')" + else + commit_msg=$(echo "$commit_msg" | xargs) # Trim whitespace + fi - $run_url = "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" + run_url="https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" git commit -m "$commit_msg" -m "$run_url" -m "[skip changelog]" - if ($LASTEXITCODE -eq 0) { - Write-Output "have_commits=True" >> $env:GITHUB_OUTPUT - } + if [ $? -eq 0 ]; then + echo "have_commits=True" >> $GITHUB_OUTPUT + fi git pull origin ${{ github.ref_name }} --rebase diff --git a/resource/infrast.json b/resource/infrast.json index 8a13a04d1f..1583b4536b 100644 --- a/resource/infrast.json +++ b/resource/infrast.json @@ -3256,5 +3256,5 @@ ], "skillsGroup_Doc": "相关技能组参考https://bbs.nga.cn/read.php?tid=25965441" }, - "roomType": ["Power", "Reception", "Control", "Dorm", "Trade", "Office", "Mfg"] + "roomType": ["Trade", "Power", "Mfg", "Office", "Reception", "Dorm", "Control"] } diff --git a/tools/ResourceUpdater/.gitignore b/tools/ResourceUpdater/.gitignore index 31faa4249d..539a26e473 100644 --- a/tools/ResourceUpdater/.gitignore +++ b/tools/ResourceUpdater/.gitignore @@ -3,6 +3,7 @@ *.dll # for linux & macos ResourceUpdater +*.h *.so.* *.dylib.* diff --git a/tools/ResourceUpdater/clone_data_repo.sh b/tools/ResourceUpdater/clone_data_repo.sh new file mode 100755 index 0000000000..b084d2bf77 --- /dev/null +++ b/tools/ResourceUpdater/clone_data_repo.sh @@ -0,0 +1,122 @@ +#!/usr/bin/env bash + +script_root="$(dirname "$(realpath "$0")")" + +# Save current directory to return to it later +pushd . > /dev/null + +cd "$script_root" +work_dir="$(pwd)" + +# Clean up existing directories +[ -d "Official" ] && rm -rf "Official" +[ -d "Overseas" ] && rm -rf "Overseas" + +# Array to store all background process IDs +pids=() + +# Clone and sparse-checkout Official repository +{ + echo "ArknightsGameResource - Official" + git clone --filter=blob:none --no-checkout --depth 1 --sparse \ + "https://github.com/yuanyan3060/ArknightsGameResource" Official + cd Official + git sparse-checkout set --no-cone \ + "/levels.json" \ + "/item" \ + "/building_skill" \ + "/gamedata/excel/item_table.json" \ + "/gamedata/excel/building_data.json" \ + "/gamedata/excel/range_table.json" \ + "/gamedata/excel/character_table.json" \ + "/gamedata/excel/gacha_table.json" \ + "/gamedata/excel/roguelike_topic_table.json" \ + "/gamedata/excel/activity_table.json" + git checkout +} & +pids+=($!) + +# Clone and sparse-checkout Overseas repository +{ + echo -e "\nArknightsGameData_Yostar - Overseas" + git clone --filter=blob:none --no-checkout --depth 1 --sparse \ + "https://github.com/ArknightsAssets/ArknightsGamedata" Overseas + cd Overseas + git sparse-checkout set --no-cone \ + "/en/gamedata/excel/item_table.json" \ + "/en/gamedata/excel/building_data.json" \ + "/en/gamedata/excel/range_table.json" \ + "/en/gamedata/excel/character_table.json" \ + "/en/gamedata/excel/gacha_table.json" \ + "/en/gamedata/excel/roguelike_topic_table.json" \ + "/en/gamedata/excel/activity_table.json" \ + "/jp/gamedata/excel/item_table.json" \ + "/jp/gamedata/excel/building_data.json" \ + "/jp/gamedata/excel/range_table.json" \ + "/jp/gamedata/excel/character_table.json" \ + "/jp/gamedata/excel/gacha_table.json" \ + "/jp/gamedata/excel/roguelike_topic_table.json" \ + "/jp/gamedata/excel/activity_table.json" \ + "/kr/gamedata/excel/item_table.json" \ + "/kr/gamedata/excel/building_data.json" \ + "/kr/gamedata/excel/range_table.json" \ + "/kr/gamedata/excel/character_table.json" \ + "/kr/gamedata/excel/gacha_table.json" \ + "/kr/gamedata/excel/roguelike_topic_table.json" \ + "/kr/gamedata/excel/activity_table.json" + git checkout +} & +pids+=($!) + +# Clone and checkout the Taiwan repository +{ + echo -e "\narknights-toolbox-update - Taiwan" + mkdir -p Overseas/tw/gamedata/excel + cd Overseas/tw/gamedata/excel + git clone --filter=blob:none --no-checkout --depth 1 -b data-tw \ + "https://github.com/arkntools/arknights-toolbox-update" . + git checkout +} & +pids+=($!) + +# Fetch data from Penguin Stats +{ + mkdir -p "$work_dir/Overseas/tw/gamedata/excel" + cd "$work_dir/Overseas/tw/gamedata/excel" + + # Define the base URL and parameters + base_url="https://penguin-stats.io/PenguinStats/api/v2/stages?server=" + parameters=("CN" "US" "JP" "KR") + + # Loop through each parameter and make curl requests + curl_pids=() + for param in "${parameters[@]}"; do + { + url="${base_url}${param}" + output_file="stages_${param}.json" + echo "Fetching data for ${param}..." + + if curl -s -o "${output_file}" "${url}"; then + echo "Successfully fetched data for ${param}" + else + echo "Failed to fetch data for ${param}" >&2 + exit 1 + fi + } & + curl_pids+=($!) + done + + # Wait for all curl processes to complete + for pid in "${curl_pids[@]}"; do + wait "$pid" + done +} & +pids+=($!) + +# Wait for all main processes to complete +for pid in "${pids[@]}"; do + wait "$pid" +done + +# Return to original directory +popd > /dev/null diff --git a/tools/ResourceUpdater/version.sh b/tools/ResourceUpdater/version.sh new file mode 100755 index 0000000000..5dc5c0c41d --- /dev/null +++ b/tools/ResourceUpdater/version.sh @@ -0,0 +1,61 @@ +#!/usr/bin/env bash + +has_changes=false +has_png_changes=false + +git add . + +all_modified_files=$(git diff --name-only HEAD 2>/dev/null) + +git reset . + +if [ -z "$all_modified_files" ]; then + echo "No files to update." +else + has_changes=true + + # Filter out files in tasks directories + modified_files=$(echo "$all_modified_files" | grep -v '^resource\(/global/[^/]*/resource\)\?/tasks/') + + # Get unique directories + directories=$(echo "$modified_files" | xargs -I{} dirname {} | sort -u) + + # Build list of directories containing version.json + version_json_dirs=() + + for dir in $directories; do + # If this is Arknights-Tile-Pos folder, use parent directory + if [[ "$dir" =~ /Arknights-Tile-Pos$ ]]; then + version_json_dirs+=("$(dirname "$dir")") + else + version_json_dirs+=("$dir") + fi + done + + # Remove duplicates + version_json_dirs=($(echo "${version_json_dirs[@]}" | tr ' ' '\n' | sort -u)) + + # Update all version.json files + for dir in "${version_json_dirs[@]}"; do + version_file="$dir/version.json" + + if [ -f "$version_file" ]; then + # Use jq to update the JSON with proper 4-space indentation + current_date=$(date -u +"%Y-%m-%d %H:%M:%S.000") + jq --arg date "$current_date" --indent 4 '.last_updated = $date' "$version_file" > "$version_file.tmp" + mv "$version_file.tmp" "$version_file" + + echo "Updated: $version_file" + fi + done + + # Check for PNG changes + if echo "$all_modified_files" | grep -q '\.png$'; then + has_png_changes=true + fi +fi + +echo "Changes: $has_changes" +echo "PNG Changes: $has_png_changes" +echo "changes=$has_changes" >> $GITHUB_OUTPUT +echo "contains_png=$has_png_changes" >> $GITHUB_OUTPUT