Skip to content

Commit 2ec5f01

Browse files
authored
Merge branch 'main' into feat/android
2 parents 08504ef + a91a5e4 commit 2ec5f01

File tree

268 files changed

+8644
-5619
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

268 files changed

+8644
-5619
lines changed

.editorconfig

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
root = true
2+
3+
[*]
4+
indent_style = space
5+
insert_final_newline = true
6+
charset = utf-8
7+
end_of_line = lf
8+
indent_size = 4

.github/workflows/build.yml

+40-59
Original file line numberDiff line numberDiff line change
@@ -28,33 +28,7 @@ on:
2828

2929
jobs:
3030
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
5832

5933
windows:
6034
needs: meta
@@ -173,8 +147,8 @@ jobs:
173147
174148
- name: Build MAA
175149
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++' }}
178152
run: |
179153
cmake --preset 'NinjaMulti' \
180154
-DMAADEPS_TRIPLET='maa-${{ matrix.arch == 'x86_64' && 'x64' || 'arm64' }}-linux' \
@@ -220,41 +194,31 @@ jobs:
220194

221195
- name: Install dep
222196
run: |
223-
brew install cmake ninja
224-
# ccache?
197+
brew install cmake ninja ccache
225198
226199
- name: Install compiler
227200
run: |
228201
brew install llvm
229-
# 17
202+
203+
- name: Setup ccache
204+
uses: Chocobo1/setup-ccache-action@v1
205+
with:
206+
remove_stale_cache: false
230207

231208
- name: Bootstrap MaaDeps
232209
env:
233210
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
234211
run: |
235212
python3 tools/maadeps-download.py ${{ matrix.arch == 'x86_64' && 'x64' || 'arm64' }}-osx
236213
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
254215
run: |
216+
LLVM_PREFIX=$(brew --prefix llvm)
255217
cmake --preset 'NinjaMulti' \
256218
-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++
258222
259223
cmake --build build --preset 'NinjaMulti - Release' -j 16
260224
@@ -348,9 +312,6 @@ jobs:
348312
nuget_pack:
349313
needs: [meta, windows, ubuntu, macos, android]
350314
runs-on: ubuntu-latest
351-
env:
352-
NUGET_PACKAGE_ID: Maa.Framework.Runtimes # need ${{ secrets.NuGetAPIKey }}
353-
354315
steps:
355316
- uses: nuget/setup-nuget@v1
356317

@@ -362,10 +323,15 @@ jobs:
362323
- name: Nuget Pack
363324
working-directory: tools/nupkgs
364325
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
369335
370336
- uses: actions/upload-artifact@v3
371337
if: always()
@@ -400,6 +366,7 @@ jobs:
400366
needs: [meta, windows, ubuntu, macos, nuget_pack, pip_pack]
401367
runs-on: ubuntu-latest
402368
env:
369+
OUTPUT_PUBLISH_FAILED: 'echo "failed=true" >> $GITHUB_OUTPUT && echo "::error::Failed to publish packages"'
403370
NUGET_PACKAGE_SOURCE: https://api.nuget.org/v3/index.json # https://apiint.nugettest.org/v3/index.json
404371

405372
steps:
@@ -408,20 +375,23 @@ jobs:
408375
path: assets
409376

410377
- name: Publish Nupkgs
378+
id: nuget
411379
run: |
412380
nuget push assets/MAA-nupkgs/*.nupkg \
413381
-ApiKey ${{ secrets.NuGetAPIKey }} \
414382
-Source $NUGET_PACKAGE_SOURCE \
415-
-SkipDuplicate
383+
|| eval $OUTPUT_PUBLISH_FAILED
416384
rm -r assets/MAA-nupkgs
417385
418386
- name: Publish Pip Packages
387+
id: pip
419388
run: |
420389
pip install --upgrade twine
421390
python -m twine upload \
422391
assets/MAA-pip-pkgs/*.whl \
423392
--username __token__\
424-
--password ${{ secrets.PYPI_TOKEN }}
393+
--password ${{ secrets.PYPI_TOKEN }} \
394+
|| eval $OUTPUT_PUBLISH_FAILED
425395
rm -r assets/MAA-pip-pkgs
426396
427397
- run: |
@@ -434,3 +404,14 @@ jobs:
434404
with:
435405
files: assets/*.zip
436406
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' || '' }}

.github/workflows/doc.yml

+12-1
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,14 @@ on:
88
workflow_dispatch:
99

1010
jobs:
11+
meta:
12+
uses: ./.github/workflows/meta.yml
1113

1214
build:
15+
needs: meta
1316
runs-on: ubuntu-latest
1417
env:
15-
VERSION: ${{ github.ref_name }}
18+
DOC_VERSION: ${{ format('({0}) {1}', needs.meta.outputs.tag == github.ref_name && 'main' || github.ref_name, needs.meta.outputs.tag) }}
1619
permissions:
1720
contents: write
1821
steps:
@@ -25,9 +28,17 @@ jobs:
2528
with:
2629
doxyfile-path: tools/Doxygen/Doxyfile
2730

31+
- name: Build index.json
32+
uses: MaaXYZ/MaaApiConverter@v1
33+
with:
34+
version: ${{ env.DOC_VERSION }}
35+
xml: ./docs-gen/html/xml
36+
output: ./docs-gen/html
37+
2838
- name: Deploy to GitHub Pages
2939
uses: peaceiris/actions-gh-pages@v3
3040
with:
3141
github_token: ${{ secrets.GITHUB_TOKEN }}
3242
publish_dir: ./docs-gen/html
3343
publish_branch: gh-pages
44+
commit_message: ${{ env.DOC_VERSION }}

.github/workflows/meta.yml

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: meta
2+
3+
on:
4+
workflow_call:
5+
outputs:
6+
is_release:
7+
value: ${{ jobs.set.outputs.is_release }}
8+
tag:
9+
value: ${{ jobs.set.outputs.tag }}
10+
version:
11+
value: ${{ jobs.set.outputs.version }}
12+
13+
jobs:
14+
set:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v3
18+
with:
19+
fetch-depth: 0
20+
- id: set
21+
run: |
22+
is_release=${{ startsWith(github.ref, 'refs/tags/v') }}
23+
commit_hash=$(git rev-parse --short HEAD)
24+
25+
if $is_release; then
26+
tag=$(git describe --tags || true)
27+
else
28+
tag=$(git describe --tags --match "v*" --exclude "*-post*" || true)
29+
fi
30+
if [[ $tag != v* ]]; then
31+
if $is_release; then echo "::error::Failed to get tag on releasing" && exit 1; fi
32+
ver_core=$(curl -sX GET "https://api.github.com/repos/MaaXYZ/MaaFramework/releases/latest" --header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' | awk '/tag_name/{print $4}' FS='["]' || true)
33+
tag=$(date "+$ver_core-1%m%d-${commit_hash}")
34+
if [[ $tag != v* ]]; then
35+
tag=$(date "+v%Y.%-m.%-d-2%H%M-${commit_hash}")
36+
fi
37+
fi
38+
39+
if $is_release; then
40+
version=${tag#v}
41+
else
42+
ver_core=${tag%-*-*}
43+
suffixs=(${tag//-/ })
44+
tag=${ver_core}-post.${suffixs[-2]}-ci.${{ github.run_id }}
45+
version=${tag#v}+${commit_hash}.$(date +%Y%m%d)
46+
fi
47+
48+
echo "tag=$tag
49+
version=$version
50+
is_release=$is_release" | tee -a "$GITHUB_OUTPUT"
51+
outputs:
52+
is_release: ${{ steps.set.outputs.is_release }}
53+
tag: ${{ steps.set.outputs.tag }} # v<release version> | v<ci version>
54+
version: ${{ steps.set.outputs.version }} # <release version> | <ci version>+<build> e.g ↓
55+
# 主版本号.次版本号.修订号[-(alpha|beta|rc).预发布号]
56+
# [-post.发布后号[-ci.${{ github.run_id }}]+${commit_hash}.${dateY%m%d}]
57+
# 1.7.0
58+
# 1.7.0-beta.1
59+
# 1.7.0-post.6-ci.8678478007+gf5e12a1c.20240413

.github/workflows/test.yml

+15-52
Original file line numberDiff line numberDiff line change
@@ -28,33 +28,7 @@ on:
2828

2929
jobs:
3030
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
5832

5933
windows:
6034
needs: meta
@@ -185,13 +159,13 @@ jobs:
185159
186160
- name: Build MAA
187161
env:
188-
CC: ${{ matrix.arch == 'x86_64' && 'ccache gcc' || 'ccache aarch64-linux-gnu-gcc' }}
189-
CXX: ${{ matrix.arch == 'x86_64' && 'ccache g++' || 'ccache aarch64-linux-gnu-g++' }}
162+
CC: ${{ matrix.arch == 'x86_64' && 'gcc' || 'aarch64-linux-gnu-gcc' }}
163+
CXX: ${{ matrix.arch == 'x86_64' && 'g++' || 'aarch64-linux-gnu-g++' }}
190164
run: |
191165
cmake --preset 'NinjaMulti' \
192166
-DMAADEPS_TRIPLET='maa-${{ matrix.arch == 'x86_64' && 'x64' || 'arm64' }}-linux' \
193167
-DMAA_HASH_VERSION='${{ needs.meta.outputs.tag }}' \
194-
-DBUILD_HTTP_CLI=OFF -DBUILD_PIPELINE_TESTING=ON -DBUILD_DLOPEN_TESTING=ON
168+
-DBUILD_PIPELINE_TESTING=ON -DBUILD_DLOPEN_TESTING=ON
195169
196170
cmake --build build --preset 'NinjaMulti - Release' -j 16
197171
@@ -253,43 +227,32 @@ jobs:
253227

254228
- name: Install dep
255229
run: |
256-
brew install cmake ninja
257-
# ccache?
230+
brew install cmake ninja ccache
258231
259232
- name: Install compiler
260233
run: |
261234
brew install llvm
262-
# 17
235+
236+
- name: Setup ccache
237+
uses: Chocobo1/setup-ccache-action@v1
238+
with:
239+
remove_stale_cache: false
263240

264241
- name: Bootstrap MaaDeps
265242
env:
266243
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
267244
run: |
268245
python3 tools/maadeps-download.py ${{ matrix.arch == 'x86_64' && 'x64' || 'arm64' }}-osx
269246
270-
- name: Build MAA for x86_64
271-
if: ${{ matrix.arch == 'x86_64' }}
272-
env:
273-
CC: "/usr/local/opt/llvm/bin/clang"
274-
CXX: "/usr/local/opt/llvm/bin/clang++"
275-
run: |
276-
cmake --preset 'NinjaMulti' \
277-
-DMAADEPS_TRIPLET='maa-${{ matrix.arch == 'x86_64' && 'x64' || 'arm64' }}-osx' \
278-
-DMAA_HASH_VERSION='${{ needs.meta.outputs.tag }}' \
279-
-DBUILD_HTTP_CLI=OFF -DBUILD_PIPELINE_TESTING=ON -DBUILD_DLOPEN_TESTING=ON
280-
281-
cmake --build build --preset 'NinjaMulti - Release' -j 16
282-
283-
- name: Build MAA for aarch64
284-
if: ${{ matrix.arch == 'aarch64' }}
285-
env:
286-
CC: "/opt/homebrew/opt/llvm/bin/clang"
287-
CXX: "/opt/homebrew/opt/llvm/bin/clang++"
247+
- name: Build MAA
288248
run: |
249+
LLVM_PREFIX=$(brew --prefix llvm)
289250
cmake --preset 'NinjaMulti' \
290251
-DMAADEPS_TRIPLET='maa-${{ matrix.arch == 'x86_64' && 'x64' || 'arm64' }}-osx' \
291252
-DMAA_HASH_VERSION='${{ needs.meta.outputs.tag }}' \
292-
-DBUILD_HTTP_CLI=OFF -DBUILD_PIPELINE_TESTING=ON -DBUILD_DLOPEN_TESTING=ON
253+
-DBUILD_PIPELINE_TESTING=ON -DBUILD_DLOPEN_TESTING=ON \
254+
-DCMAKE_C_COMPILER=${LLVM_PREFIX}/bin/clang \
255+
-DCMAKE_CXX_COMPILER=${LLVM_PREFIX}/bin/clang++
293256
294257
cmake --build build --preset 'NinjaMulti - Release' -j 16
295258

.gitignore

+5
Original file line numberDiff line numberDiff line change
@@ -442,3 +442,8 @@ FodyWeavers.xsd
442442
# Chore
443443
.DS_Store
444444
.nuke/temp/*
445+
446+
!include/MaaToolkit/Win32
447+
448+
export_targets.cmake
449+
maa_pi_config.json

0 commit comments

Comments
 (0)