From b0a252353d655e5dc014656c9c4aac743749afab Mon Sep 17 00:00:00 2001 From: MistEO Date: Fri, 20 Dec 2024 17:23:55 +0800 Subject: [PATCH] ci: add build_config (#487) --- .github/workflows/build.yml | 25 +++++++++++++------ .github/workflows/meta.yml | 18 +++++++++++-- .github/workflows/test.yml | 2 +- CMakePresets.json | 50 ++++++++++++++++++------------------- 4 files changed, 59 insertions(+), 36 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4a4da4069..6b1449c76 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -25,6 +25,15 @@ on: - "source/**" - "CMakeLists.txt" workflow_dispatch: + inputs: + build_config: + required: true + default: 'Debug' + type: choice + options: + - Debug + - RelWithDebInfo + - Release jobs: meta: @@ -91,13 +100,13 @@ jobs: run: | cmake --preset "${{ matrix.arch == 'x86_64' && 'MSVC 2022' || 'MSVC 2022 ARM' }}" -DCMAKE_SYSTEM_VERSION="10.0.26100.0" -DMAADEPS_TRIPLET="maa-${{ matrix.arch == 'x86_64' && 'x64' || 'arm64' }}-windows" -DMAA_HASH_VERSION='${{ needs.meta.outputs.tag }}' -DBUILD_NODEJS_BINDING=ON - cmake --build build --preset "${{ matrix.arch == 'x86_64' && 'MSVC 2022' || 'MSVC 2022 ARM' }} - RelWithDebInfo" -j 16 + cmake --build build --preset "${{ matrix.arch == 'x86_64' && 'MSVC 2022' || 'MSVC 2022 ARM' }} - ${{ inputs.build_config || needs.meta.outputs.build_config }}" -j 16 - name: Install shell: bash if: always() run: | - cmake --install build --prefix install --config RelWithDebInfo + cmake --install build --prefix install --config ${{ inputs.build_config || needs.meta.outputs.build_config }} rm -rf install/bin/msvc-debug cp -r docs install @@ -180,13 +189,13 @@ jobs: -DMAA_HASH_VERSION='${{ needs.meta.outputs.tag }}' \ -DBUILD_NODEJS_BINDING=ON - cmake --build build --preset 'NinjaMulti - RelWithDebInfo' -j 16 + cmake --build build --preset 'NinjaMulti - ${{ inputs.build_config || needs.meta.outputs.build_config }}' -j 16 - name: Install shell: bash if: always() run: | - cmake --install build --prefix install --config RelWithDebInfo + cmake --install build --prefix install --config ${{ inputs.build_config || needs.meta.outputs.build_config }} cp -r docs install cp README*.md install @@ -262,13 +271,13 @@ jobs: -DCMAKE_CXX_COMPILER=${LLVM_PREFIX}/bin/clang++ \ -DBUILD_NODEJS_BINDING=ON - cmake --build build --preset 'NinjaMulti - RelWithDebInfo' -j 16 + cmake --build build --preset 'NinjaMulti - ${{ inputs.build_config || needs.meta.outputs.build_config }}' -j 16 - name: Install shell: bash if: always() run: | - cmake --install build --prefix install --config RelWithDebInfo + cmake --install build --prefix install --config ${{ inputs.build_config || needs.meta.outputs.build_config }} cp -r docs install cp README*.md install @@ -328,13 +337,13 @@ jobs: -DMAADEPS_TRIPLET='maa-${{ matrix.arch == 'x86_64' && 'x64' || 'arm64' }}-android' \ -DMAA_HASH_VERSION='${{ needs.meta.outputs.tag }}' - cmake --build build --preset 'NinjaMulti - RelWithDebInfo' -j 16 + cmake --build build --preset 'NinjaMulti - ${{ inputs.build_config || needs.meta.outputs.build_config }}' -j 16 - name: Install shell: bash if: always() run: | - cmake --install build --prefix install --config RelWithDebInfo + cmake --install build --prefix install --config ${{ inputs.build_config || needs.meta.outputs.build_config }} cp -r docs install cp README*.md install diff --git a/.github/workflows/meta.yml b/.github/workflows/meta.yml index 5a7448216..82e80825c 100644 --- a/.github/workflows/meta.yml +++ b/.github/workflows/meta.yml @@ -11,7 +11,8 @@ on: value: ${{ jobs.set.outputs.tag }} version: value: ${{ jobs.set.outputs.version }} - + build_config: + value: ${{ jobs.set.outputs.build_config }} jobs: set: runs-on: ubuntu-latest @@ -49,15 +50,28 @@ jobs: version=${tag#v}+${commit_hash}.$(date +%Y%m%d) fi + if $is_release; then + if $is_pre_release; then + build_config="RelWithDebInfo" + else + build_config="Release" + fi + else + build_config="Debug" + fi + echo "tag=$tag version=$version is_release=$is_release - is_pre_release=$is_pre_release" | tee -a "$GITHUB_OUTPUT" + is_pre_release=$is_pre_release + build_config=$build_config" | tee -a "$GITHUB_OUTPUT" + outputs: is_release: ${{ steps.set.outputs.is_release }} is_pre_release: ${{ steps.set.outputs.is_pre_release }} tag: ${{ steps.set.outputs.tag }} # v | v version: ${{ steps.set.outputs.version }} # | + e.g ↓ + build_config: ${{ steps.set.outputs.build_config }} # Release | RelWithDebInfo | Debug # 主版本号.次版本号.修订号[-(alpha|beta|rc).预发布号] diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index aa2f324f4..e424b6fa4 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -336,7 +336,7 @@ jobs: -DMAA_HASH_VERSION='${{ needs.meta.outputs.tag }}' \ -DCMAKE_C_COMPILER=${LLVM_PREFIX}/bin/clang \ -DCMAKE_CXX_COMPILER=${LLVM_PREFIX}/bin/clang++ \ - -DBUILD_NODEJS_BINDING=ON \ + -DBUILD_NODEJS_BINDING=ON \ -DBUILD_PIPELINE_TESTING=ON -DBUILD_DLOPEN_TESTING=ON cmake --build build --preset 'NinjaMulti - Debug' -j 16 diff --git a/CMakePresets.json b/CMakePresets.json index 729b8d53b..115ed7614 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -69,14 +69,6 @@ "configuration": "Debug", "jobs": 16 }, - { - "name": "NinjaMulti - Release", - "displayName": "Ninja MultiConfig Release", - "description": "Ninja MultiConfig Release", - "configurePreset": "NinjaMulti", - "configuration": "Release", - "jobs": 16 - }, { "name": "NinjaMulti - RelWithDebInfo", "displayName": "Ninja MultiConfig RelWithDebInfo", @@ -85,6 +77,14 @@ "configuration": "RelWithDebInfo", "jobs": 16 }, + { + "name": "NinjaMulti - Release", + "displayName": "Ninja MultiConfig Release", + "description": "Ninja MultiConfig Release", + "configurePreset": "NinjaMulti", + "configuration": "Release", + "jobs": 16 + }, { "name": "MSVC 2022 - Debug", "displayName": "MSVC 2022 Debug", @@ -93,14 +93,6 @@ "configuration": "Debug", "jobs": 16 }, - { - "name": "MSVC 2022 - Release", - "displayName": "MSVC 2022 Release", - "description": "MSVC 2022 Release", - "configurePreset": "MSVC 2022", - "configuration": "Release", - "jobs": 16 - }, { "name": "MSVC 2022 - RelWithDebInfo", "displayName": "MSVC 2022 RelWithDebInfo", @@ -109,6 +101,14 @@ "configuration": "RelWithDebInfo", "jobs": 16 }, + { + "name": "MSVC 2022 - Release", + "displayName": "MSVC 2022 Release", + "description": "MSVC 2022 Release", + "configurePreset": "MSVC 2022", + "configuration": "Release", + "jobs": 16 + }, { "name": "MSVC 2022 ARM - Debug", "displayName": "MSVC 2022 ARM Debug", @@ -117,14 +117,6 @@ "configuration": "Debug", "jobs": 16 }, - { - "name": "MSVC 2022 ARM - Release", - "displayName": "MSVC 2022 ARM Release", - "description": "MSVC 2022 ARM Release", - "configurePreset": "MSVC 2022 ARM", - "configuration": "Release", - "jobs": 16 - }, { "name": "MSVC 2022 ARM - RelWithDebInfo", "displayName": "MSVC 2022 ARM RelWithDebInfo", @@ -132,6 +124,14 @@ "configurePreset": "MSVC 2022 ARM", "configuration": "RelWithDebInfo", "jobs": 16 + }, + { + "name": "MSVC 2022 ARM - Release", + "displayName": "MSVC 2022 ARM Release", + "description": "MSVC 2022 ARM Release", + "configurePreset": "MSVC 2022 ARM", + "configuration": "Release", + "jobs": 16 } ] -} +} \ No newline at end of file