28
28
29
29
jobs :
30
30
meta :
31
- runs-on : ubuntu-latest
32
- steps :
33
- - uses : actions/checkout@v3
34
- with :
35
- fetch-depth : 0
36
- - id : set_tag
37
- run : |
38
- is_release=${{ startsWith(github.ref, 'refs/tags/v') }}
39
- tag=$(git describe --tags --match "v*" ${{ github.ref }} || true)
40
- if [[ $tag != v* ]]; then
41
- tag=$(curl -sX GET "https://api.github.com/repos/MaaXYZ/MaaFramework/releases/latest" --header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' | awk '/tag_name/{print $4}' FS='["]')
42
- if [[ $tag != v* ]]; then
43
- tag="v0.0.0"
44
- fi
45
- tag=$(date "+$tag-%y%m%d-$(git rev-parse --short HEAD)")
46
- fi
47
- if ! $($is_release) ; then
48
- prefix=${tag%-*-*}
49
- suffix=${tag#$prefix-}
50
- tag="$prefix-ci.$suffix"
51
- fi
52
-
53
- echo tag=$tag | tee -a $GITHUB_OUTPUT
54
- echo is_release=$is_release | tee -a $GITHUB_OUTPUT
55
- outputs :
56
- tag : ${{ steps.set_tag.outputs.tag }}
57
- is_release : ${{ steps.set_tag.outputs.is_release }}
31
+ uses : ./.github/workflows/meta.yml
58
32
59
33
windows :
60
34
needs : meta
@@ -173,8 +147,8 @@ jobs:
173
147
174
148
- name : Build MAA
175
149
env :
176
- CC : ${{ matrix.arch == 'x86_64' && 'ccache gcc' || 'ccache aarch64-linux-gnu-gcc' }}
177
- CXX : ${{ matrix.arch == 'x86_64' && 'ccache g++' || 'ccache aarch64-linux-gnu-g++' }}
150
+ CC : ${{ matrix.arch == 'x86_64' && 'gcc' || 'aarch64-linux-gnu-gcc' }}
151
+ CXX : ${{ matrix.arch == 'x86_64' && 'g++' || 'aarch64-linux-gnu-g++' }}
178
152
run : |
179
153
cmake --preset 'NinjaMulti' \
180
154
-DMAADEPS_TRIPLET='maa-${{ matrix.arch == 'x86_64' && 'x64' || 'arm64' }}-linux' \
@@ -220,41 +194,31 @@ jobs:
220
194
221
195
- name : Install dep
222
196
run : |
223
- brew install cmake ninja
224
- # ccache?
197
+ brew install cmake ninja ccache
225
198
226
199
- name : Install compiler
227
200
run : |
228
201
brew install llvm
229
- # 17
202
+
203
+ - name : Setup ccache
204
+ uses : Chocobo1/setup-ccache-action@v1
205
+ with :
206
+ remove_stale_cache : false
230
207
231
208
- name : Bootstrap MaaDeps
232
209
env :
233
210
GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
234
211
run : |
235
212
python3 tools/maadeps-download.py ${{ matrix.arch == 'x86_64' && 'x64' || 'arm64' }}-osx
236
213
237
- - name : Build MAA for x86_64
238
- if : ${{ matrix.arch == 'x86_64' }}
239
- env :
240
- CC : " /usr/local/opt/llvm/bin/clang"
241
- CXX : " /usr/local/opt/llvm/bin/clang++"
242
- run : |
243
- cmake --preset 'NinjaMulti' \
244
- -DMAADEPS_TRIPLET='maa-${{ matrix.arch == 'x86_64' && 'x64' || 'arm64' }}-osx' \
245
- -DMAA_HASH_VERSION='${{ needs.meta.outputs.tag }}'
246
-
247
- cmake --build build --preset 'NinjaMulti - Release' -j 16
248
-
249
- - name : Build MAA for aarch64
250
- if : ${{ matrix.arch == 'aarch64' }}
251
- env :
252
- CC : " /opt/homebrew/opt/llvm/bin/clang"
253
- CXX : " /opt/homebrew/opt/llvm/bin/clang++"
214
+ - name : Build MAA
254
215
run : |
216
+ LLVM_PREFIX=$(brew --prefix llvm)
255
217
cmake --preset 'NinjaMulti' \
256
218
-DMAADEPS_TRIPLET='maa-${{ matrix.arch == 'x86_64' && 'x64' || 'arm64' }}-osx' \
257
- -DMAA_HASH_VERSION='${{ needs.meta.outputs.tag }}'
219
+ -DMAA_HASH_VERSION='${{ needs.meta.outputs.tag }}' \
220
+ -DCMAKE_C_COMPILER=${LLVM_PREFIX}/bin/clang \
221
+ -DCMAKE_CXX_COMPILER=${LLVM_PREFIX}/bin/clang++
258
222
259
223
cmake --build build --preset 'NinjaMulti - Release' -j 16
260
224
@@ -348,9 +312,6 @@ jobs:
348
312
nuget_pack :
349
313
needs : [meta, windows, ubuntu, macos, android]
350
314
runs-on : ubuntu-latest
351
- env :
352
- NUGET_PACKAGE_ID : Maa.Framework.Runtimes # need ${{ secrets.NuGetAPIKey }}
353
-
354
315
steps :
355
316
- uses : nuget/setup-nuget@v1
356
317
@@ -362,10 +323,15 @@ jobs:
362
323
- name : Nuget Pack
363
324
working-directory : tools/nupkgs
364
325
run : |
365
- tag=${{ needs.meta.outputs.tag }}
366
- nuget pack Maa.Framework.Runtimes.nuspec \
367
- -Verbosity detailed \
368
- -Properties "id=$NUGET_PACKAGE_ID;version=${tag#v};year=$(date +%Y);branch=$(git rev-parse --abbrev-ref HEAD);commit=$(git rev-parse HEAD);docs_path=../../docs;assets_path=../../assets"
326
+ wget https://raw.githubusercontent.com/MaaAssistantArknights/design/main/logo/maa-logo_128x128.png
327
+ version=${{ needs.meta.outputs.version }}
328
+ for NUSPEC in Maa.Framework.Runtime*.nuspec; do
329
+ cat Head.nuspec $NUSPEC Tail.nuspec > temp && mv temp $NUSPEC
330
+
331
+ nuget pack $NUSPEC \
332
+ -Verbosity detailed \
333
+ -Properties "version=${version//-post/};year=$(date +%Y);branch=$(git rev-parse --abbrev-ref HEAD);commit=$(git rev-parse HEAD);root_path=../.."
334
+ done
369
335
370
336
- uses : actions/upload-artifact@v3
371
337
if : always()
@@ -400,6 +366,7 @@ jobs:
400
366
needs : [meta, windows, ubuntu, macos, nuget_pack, pip_pack]
401
367
runs-on : ubuntu-latest
402
368
env :
369
+ OUTPUT_PUBLISH_FAILED : ' echo "failed=true" >> $GITHUB_OUTPUT && echo "::error::Failed to publish packages"'
403
370
NUGET_PACKAGE_SOURCE : https://api.nuget.org/v3/index.json # https://apiint.nugettest.org/v3/index.json
404
371
405
372
steps :
@@ -408,20 +375,23 @@ jobs:
408
375
path : assets
409
376
410
377
- name : Publish Nupkgs
378
+ id : nuget
411
379
run : |
412
380
nuget push assets/MAA-nupkgs/*.nupkg \
413
381
-ApiKey ${{ secrets.NuGetAPIKey }} \
414
382
-Source $NUGET_PACKAGE_SOURCE \
415
- -SkipDuplicate
383
+ || eval $OUTPUT_PUBLISH_FAILED
416
384
rm -r assets/MAA-nupkgs
417
385
418
386
- name : Publish Pip Packages
387
+ id : pip
419
388
run : |
420
389
pip install --upgrade twine
421
390
python -m twine upload \
422
391
assets/MAA-pip-pkgs/*.whl \
423
392
--username __token__\
424
- --password ${{ secrets.PYPI_TOKEN }}
393
+ --password ${{ secrets.PYPI_TOKEN }} \
394
+ || eval $OUTPUT_PUBLISH_FAILED
425
395
rm -r assets/MAA-pip-pkgs
426
396
427
397
- run : |
@@ -434,3 +404,14 @@ jobs:
434
404
with :
435
405
files : assets/*.zip
436
406
tag_name : ${{ needs.meta.outputs.tag }}
407
+
408
+ - name : Create issue if failed to publish packages
409
+ if : steps.nuget.outputs.failed || steps.pip.outputs.failed
410
+ uses : actions-cool/issues-helper@v3
411
+ with :
412
+ actions : ' create-issue'
413
+ title : ' ${{ needs.meta.outputs.tag }} failed to publish packages'
414
+ body : |
415
+ Please manually publish the following packages:
416
+ ${{ steps.nuget.outputs.failed && '- nuget @moomiji' || '' }}
417
+ ${{ steps.pip.outputs.failed && '- pip @QiE2035' || '' }}
0 commit comments