forked from MaaAssistantArknights/MaaAssistantArknights
-
Notifications
You must be signed in to change notification settings - Fork 0
212 lines (185 loc) · 7.6 KB
/
res-update-game.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
name: res-update-game
on:
schedule:
- cron: "*/20 * * * *"
workflow_dispatch:
inputs:
commit_message:
description: "Commit Message"
type: string
required: false
jobs:
update-game-resources:
if: github.repository_owner == 'MaaAssistantArknights'
runs-on: windows-latest
env:
GH_TOKEN: ${{ secrets.MISTEOWORKFLOW }}
steps:
- name: Checkout MAA
uses: actions/checkout@v4
with:
show-progress: false
fetch-depth: 1
token: ${{ secrets.MISTEOWORKFLOW }}
- name: Restore ResourceUpdater.exe from cache
id: cache-restore
uses: actions/cache/restore@v4
with:
key: ${{ runner.os }}-resource-updater-main-cpp-${{ hashFiles('.\tools\ResourceUpdater\main.cpp') }}
path: |
.\tools\ResourceUpdater\x64\Release\opencv_world4_maa.dll
.\tools\ResourceUpdater\x64\Release\ResourceUpdater.exe
- name: Bootstrap MaaDeps
if: steps.cache-restore.outputs.cache-hit != 'true'
run: |
python3 maadeps-download.py x64-windows
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Add msbuild to PATH
if: steps.cache-restore.outputs.cache-hit != 'true'
uses: microsoft/setup-msbuild@v1
- name: Build Resource Updater
if: steps.cache-restore.outputs.cache-hit != 'true'
run: |
MSBUILD tools/ResourceUpdater/ResourceUpdater.vcxproj /t:rebuild /p:Configuration="Release" /p:Platform="x64" /p:BuildProjectReferences=false /m
- name: Save ResourceUpdater.exe to cache
id: cache-save
if: always() && steps.cache-restore.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
key: ${{ runner.os }}-resource-updater-main-cpp-${{ hashFiles('.\tools\ResourceUpdater\main.cpp') }}
path: |
.\tools\ResourceUpdater\x64\Release\opencv_world4_maa.dll
.\tools\ResourceUpdater\x64\Release\ResourceUpdater.exe
- name: Clone ArknightsGameResource for Official
uses: actions/checkout@v4
with:
show-progress: false
repository: yuanyan3060/ArknightsGameResource
ref: main
path: .\tools\ResourceUpdater\x64\Release\Official
sparse-checkout: |
/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
sparse-checkout-cone-mode: false
- name: Clone ArknightsGameResource_Yostar for Overseas
uses: actions/checkout@v4
with:
show-progress: false
repository: Kengxxiao/ArknightsGameData_Yostar
ref: main
path: .\tools\ResourceUpdater\x64\Release\Overseas
sparse-checkout: |
/en_US/gamedata/excel/item_table.json
/en_US/gamedata/excel/building_data.json
/en_US/gamedata/excel/range_table.json
/en_US/gamedata/excel/character_table.json
/en_US/gamedata/excel/gacha_table.json
/en_US/gamedata/excel/roguelike_topic_table.json
/en_US/gamedata/excel/activity_table.json
/ja_JP/gamedata/excel/item_table.json
/ja_JP/gamedata/excel/building_data.json
/ja_JP/gamedata/excel/range_table.json
/ja_JP/gamedata/excel/character_table.json
/ja_JP/gamedata/excel/gacha_table.json
/ja_JP/gamedata/excel/roguelike_topic_table.json
/ja_JP/gamedata/excel/activity_table.json
/ko_KR/gamedata/excel/item_table.json
/ko_KR/gamedata/excel/building_data.json
/ko_KR/gamedata/excel/range_table.json
/ko_KR/gamedata/excel/character_table.json
/ko_KR/gamedata/excel/gacha_table.json
/ko_KR/gamedata/excel/roguelike_topic_table.json
/ko_KR/gamedata/excel/activity_table.json
sparse-checkout-cone-mode: false
- name: Clone arknights-toolbox-update for Taiwan
uses: actions/checkout@v4
with:
show-progress: false
repository: arkntools/arknights-toolbox-update
ref: data-tw
path: .\tools\ResourceUpdater\x64\Release\Overseas\zh_TW\gamedata\excel
token: ${{ secrets.ARKNTOOLS_MAA_RESOURCE_UPDATER}}
- name: Run Resource Updater
run: |
.\tools\ResourceUpdater\x64\Release\ResourceUpdater.exe
- name: Overseas Tasks Ordering
run: |
python3 tools/TaskSorter/TaskSorter.py
- name: Check if only sorted
id: check_only_sorted
run: |
git status
$diff = $(git diff --numstat HEAD | findstr -i resource)
if ($LASTEXITCODE -ne 0) {
echo "no diff"
exit 0
}
echo "diff: "$diff
$sp = $($diff -split "\s+")
$numbers = $($sp | Where-Object { $_ -match "^\d+$" })
echo "numbers: "$numbers
$length = $numbers.Length
$noDiff = $true
for ($i = 0; $i -lt $length; $i += 2) {
$firstNumber = $numbers[$i]
$secondNumber = $numbers[$i+1]
if ($firstNumber -gt 1) {
$noDiff = $false
break
}
if ($firstNumber -ne $secondNumber) {
$noDiff = $false
break
}
}
echo "noDiff: "$noDiff
echo "only_sorted=$noDiff" >> $env:GITHUB_OUTPUT
- name: Cancelling
if: steps.check_only_sorted.outputs.only_sorted == 'True'
uses: andymckay/cancel-action@0.3
- name: Add files to git
if: steps.check_only_sorted.outputs.only_sorted != 'True'
id: add_files
run: |
git status
git config user.name "$env:GITHUB_ACTOR"
git config user.email "$env:GITHUB_ACTOR@users.noreply.github.com"
git add .
$commit_msg = "${{ github.event.inputs.commit_message }}"
if (-not [string]::IsNullOrWhiteSpace($commit_msg)) {
$commit_msg = $commit_msg.Trim()
} else {
$commit_msg = "chore: Auto Update Game Resources - $(Get-Date -Format 'yyyy-MM-dd')"
}
git commit -m "$commit_msg" -m "[skip changelog]"
if ($LASTEXITCODE -eq 0) {
echo "have_commits=True" >> $env:GITHUB_OUTPUT
}
git pull origin $(git rev-parse --abbrev-ref HEAD) --unshallow --rebase
- name: Cancelling
if: steps.add_files.outputs.have_commits != 'True'
uses: andymckay/cancel-action@0.3
- name: Push changes # push the output folder to your repo
if: steps.add_files.outputs.have_commits == 'True'
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.MISTEOWORKFLOW }}
- name: Update OTA resource
if: steps.add_files.outputs.have_commits == 'True'
run: |
gh workflow --repo MaaAssistantArknights/MaaRelease run update-resource.yml
# - name: Release # ref: https://docs.github.com/en/actions/using-workflows/triggering-a-workflow#triggering-a-workflow-from-a-workflow
# if: steps.add_files.outputs.have_commits == 'True'
# run: |
# gh workflow run release-nightly-ota -f release_body="Auto Release of Resource Updates"
# env:
# GH_TOKEN: ${{ github.token }}