fix(ci): only deploy GitHub Pages from main/master branches #4
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build | |
| on: | |
| push: | |
| tags: | |
| - "*" | |
| branches: | |
| - main | |
| - master | |
| - refactor | |
| pull_request: | |
| branches: | |
| - main | |
| - master | |
| - refactor | |
| permissions: | |
| contents: read | |
| checks: write | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| env: | |
| BUILD_TYPE: Release | |
| jobs: | |
| build: | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - os: ubuntu-24.04 | |
| triplet: x64-linux | |
| onnxruntime_ep: cpu | |
| dml: OFF | |
| artifact_name: linux-x64 | |
| archive_ext: tar.gz | |
| - os: macos-14 | |
| triplet: arm64-osx | |
| onnxruntime_ep: cpu | |
| dml: OFF | |
| artifact_name: macos-arm64 | |
| archive_ext: zip | |
| - os: windows-latest | |
| triplet: x64-windows | |
| onnxruntime_ep: dml | |
| dml: ON | |
| artifact_name: msvc2022-x64 | |
| archive_ext: zip | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| - name: Install system dependencies | |
| if: runner.os == 'Linux' | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y libgl1-mesa-dev libxkbcommon-dev libxkbcommon-x11-0 ccache | |
| - name: Setup ccache | |
| if: runner.os != 'Windows' | |
| uses: hendrikmuhs/ccache-action@v1.2 | |
| with: | |
| key: ${{ matrix.triplet }} | |
| max-size: 500M | |
| - name: Install Qt | |
| uses: jurplel/install-qt-action@v4 | |
| with: | |
| version: '6.9.3' | |
| - name: Initialize MSVC environment | |
| if: runner.os == 'Windows' | |
| uses: ilammy/msvc-dev-cmd@v1 | |
| with: | |
| arch: amd64 | |
| - name: Configure Qt6 path (Unix) | |
| if: runner.os != 'Windows' | |
| run: | | |
| echo "QT_DIR=$QT_ROOT_DIR" >> $GITHUB_ENV | |
| echo "QT6_DIR=$QT_ROOT_DIR" >> $GITHUB_ENV | |
| echo "GH_WORKSPACE=${{github.workspace}}" >> $GITHUB_ENV | |
| - name: Configure Qt6 path (Windows) | |
| if: runner.os == 'Windows' | |
| shell: bash | |
| run: | | |
| echo "QT_DIR=$QT_ROOT_DIR" | sed 's/\\/\//g' >> $GITHUB_ENV | |
| echo "QT6_DIR=$QT_ROOT_DIR" | sed 's/\\/\//g' >> $GITHUB_ENV | |
| echo "GH_WORKSPACE=${{github.workspace}}" | sed 's/\\/\//g' >> $GITHUB_ENV | |
| - name: Verify Qt Installation | |
| if: runner.os == 'Windows' | |
| shell: bash | |
| run: | | |
| echo "QT_DIR: $QT6_DIR" | |
| ls -l "$QT6_DIR/lib/cmake/Qt6" | |
| - name: Install vcpkg | |
| uses: lukka/run-vcpkg@v11 | |
| with: | |
| vcpkgGitCommitId: 14bb451131ccf6be50a63a8d9dfe7980e46b5958 | |
| - name: Cache vcpkg installed packages | |
| uses: actions/cache@v4 | |
| with: | |
| path: ${{github.workspace}}/vcpkg/installed | |
| key: vcpkg-installed-${{ matrix.triplet }}-${{ hashFiles('scripts/vcpkg-manifest/vcpkg.json') }} | |
| restore-keys: | | |
| vcpkg-installed-${{ matrix.triplet }}- | |
| - name: Install Ninja | |
| uses: seanmiddleditch/gha-setup-ninja@v4 | |
| - name: Build Vcpkg packages (Unix) | |
| if: runner.os != 'Windows' | |
| working-directory: ${{github.workspace}}/vcpkg | |
| run: | | |
| ./vcpkg install \ | |
| --x-manifest-root=../scripts/vcpkg-manifest \ | |
| --x-install-root=./installed \ | |
| --triplet=${{ matrix.triplet }} | |
| env: | |
| CMAKE_PREFIX_PATH: ${{env.QT_DIR}} | |
| QT_DIR: ${{env.QT_DIR}} | |
| Qt6_DIR: ${{env.QT_DIR}} | |
| VCPKG_KEEP_ENV_VARS: 'CMAKE_PREFIX_PATH;QT_DIR;Qt6_DIR' | |
| - name: Build Vcpkg packages (Windows) | |
| if: runner.os == 'Windows' | |
| shell: cmd | |
| working-directory: ${{github.workspace}}/vcpkg | |
| run: | | |
| vcpkg.exe install --x-manifest-root=../scripts/vcpkg-manifest --x-install-root=./installed --triplet=${{ matrix.triplet }} | |
| env: | |
| CMAKE_PREFIX_PATH: ${{env.QT_DIR}} | |
| QT_DIR: ${{env.QT_DIR}} | |
| Qt6_DIR: ${{env.QT_DIR}} | |
| VCPKG_KEEP_ENV_VARS: 'CMAKE_PREFIX_PATH;QT_DIR;Qt6_DIR' | |
| - name: Install OnnxRuntime (Unix) | |
| if: runner.os != 'Windows' | |
| working-directory: ${{github.workspace}}/src/infer | |
| run: | | |
| cmake -Dep=${{ matrix.onnxruntime_ep }} -P ../../cmake/setup-onnxruntime.cmake | |
| - name: Install OnnxRuntime (Windows) | |
| if: runner.os == 'Windows' | |
| shell: cmd | |
| working-directory: ${{github.workspace}}/src/infer | |
| run: | | |
| cmake -Dep=${{ matrix.onnxruntime_ep }} -P ../../cmake/setup-onnxruntime.cmake | |
| - name: Configure CMake | |
| shell: bash | |
| run: | | |
| EXTRA_CMAKE_ARGS="" | |
| if [ "$RUNNER_OS" != "Windows" ]; then | |
| EXTRA_CMAKE_ARGS="-DCMAKE_CXX_COMPILER_LAUNCHER=ccache" | |
| fi | |
| cmake -B ${{github.workspace}}/build -G Ninja \ | |
| -DBUILD_TESTS:BOOL=ON \ | |
| -DGAME_INFER_BUILD_TESTS:BOOL=ON \ | |
| -DRMVPE_INFER_BUILD_TESTS:BOOL=ON \ | |
| -DAUDIO_UTIL_BUILD_TESTS:BOOL=ON \ | |
| -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} \ | |
| -DCMAKE_INSTALL_PREFIX=${{github.workspace}}/deploy \ | |
| -DCMAKE_PREFIX_PATH=${{env.QT_DIR}}/lib/cmake/Qt6/ \ | |
| -DCMAKE_TOOLCHAIN_FILE=${{github.workspace}}/vcpkg/scripts/buildsystems/vcpkg.cmake \ | |
| -DONNXRUNTIME_ENABLE_DML=${{ matrix.dml }} \ | |
| $EXTRA_CMAKE_ARGS | |
| - name: Build | |
| run: cmake --build ${{github.workspace}}/build --target all | |
| - name: Run tests | |
| working-directory: ${{github.workspace}}/build | |
| run: ctest --output-on-failure --output-junit test-results.xml -C ${{env.BUILD_TYPE}} --timeout 120 | |
| - name: Upload test results | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: test-results-${{ matrix.artifact_name }} | |
| path: ${{github.workspace}}/build/test-results.xml | |
| if-no-files-found: ignore | |
| - name: Test Report | |
| if: always() && github.event_name == 'push' | |
| uses: dorny/test-reporter@v1 | |
| with: | |
| name: Test Results (${{ matrix.artifact_name }}) | |
| path: ${{github.workspace}}/build/test-results.xml | |
| reporter: java-junit | |
| fail-on-empty: 'false' | |
| - name: Verify build outputs | |
| shell: bash | |
| run: | | |
| echo "=== Verifying build outputs ===" | |
| FAILED=0 | |
| for app in DatasetPipeline MinLabel PhonemeLabeler PitchLabeler GameInfer DiffSingerLabeler; do | |
| if [ "$RUNNER_OS" = "Windows" ]; then | |
| EXE="${{github.workspace}}/build/bin/${app}.exe" | |
| else | |
| EXE="${{github.workspace}}/build/bin/${app}" | |
| fi | |
| if [ -f "$EXE" ]; then | |
| echo " [OK] $app" | |
| else | |
| echo " [FAIL] $app (not found)" | |
| FAILED=1 | |
| fi | |
| done | |
| for test_target in TestAudioUtil TestGame TestRmvpe; do | |
| if [ "$RUNNER_OS" = "Windows" ]; then | |
| EXE="${{github.workspace}}/build/bin/${test_target}.exe" | |
| else | |
| EXE="${{github.workspace}}/build/bin/${test_target}" | |
| fi | |
| if [ -f "$EXE" ]; then | |
| echo " [OK] $test_target" | |
| else | |
| echo " [FAIL] $test_target (not found)" | |
| FAILED=1 | |
| fi | |
| done | |
| if [ $FAILED -ne 0 ]; then | |
| echo "::error::Some expected build outputs are missing" | |
| exit 1 | |
| fi | |
| - name: Deploy | |
| run: cmake --build ${{github.workspace}}/build --target install | |
| - name: Verify find_package(dsfw) | |
| shell: bash | |
| run: | | |
| cmake -B tests/test-find-package/build -S tests/test-find-package -G Ninja \ | |
| -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} \ | |
| -DCMAKE_PREFIX_PATH="${{github.workspace}}/deploy;${{env.QT_DIR}}/lib/cmake/Qt6/" \ | |
| -DCMAKE_TOOLCHAIN_FILE=${{github.workspace}}/vcpkg/scripts/buildsystems/vcpkg.cmake | |
| cmake --build tests/test-find-package/build | |
| - name: Set Commit ID | |
| shell: bash | |
| run: | | |
| BUILD_DATE=$(TZ='Asia/Shanghai' date +'%Y-%m-%d') | |
| SHORT_HASH=$(git log --format="%H" -n 1 | head -c 7) | |
| VERSION="${BUILD_DATE}-${SHORT_HASH}" | |
| echo "VERSION=$VERSION" >> $GITHUB_ENV | |
| - name: Upload Artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: dataset-tools-${{ matrix.artifact_name }}-${{env.VERSION}} | |
| path: ${{github.workspace}}/deploy | |
| - name: Compress release archive (Linux) | |
| if: startsWith(github.ref, 'refs/tags/') && runner.os == 'Linux' | |
| working-directory: ${{github.workspace}}/deploy | |
| run: | | |
| tar czf dataset-tools-${{ matrix.artifact_name }}-${{env.VERSION}}.tar.gz . | |
| - name: Compress release archive (macOS) | |
| if: startsWith(github.ref, 'refs/tags/') && runner.os == 'macOS' | |
| working-directory: ${{github.workspace}}/deploy | |
| run: | | |
| zip -r dataset-tools-${{ matrix.artifact_name }}-${{env.VERSION}}.zip . | |
| - name: Compress release archive (Windows) | |
| if: startsWith(github.ref, 'refs/tags/') && runner.os == 'Windows' | |
| shell: bash | |
| working-directory: ${{github.workspace}}/deploy | |
| run: | | |
| 7z a dataset-tools-${{ matrix.artifact_name }}-${{env.VERSION}}.zip ./* | |
| - name: Release | |
| if: startsWith(github.ref, 'refs/tags/') | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| files: | | |
| ${{github.workspace}}/deploy/dataset-tools-${{ matrix.artifact_name }}-${{env.VERSION }}.${{ matrix.archive_ext }} | |
| clang-tidy: | |
| runs-on: ubuntu-24.04 | |
| if: github.event_name == 'pull_request' | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| - name: Install system dependencies | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y libgl1-mesa-dev libxkbcommon-dev libxkbcommon-x11-0 clang-tidy | |
| - name: Install Qt | |
| uses: jurplel/install-qt-action@v4 | |
| with: | |
| version: '6.9.3' | |
| - name: Install vcpkg | |
| uses: lukka/run-vcpkg@v11 | |
| with: | |
| vcpkgGitCommitId: 14bb451131ccf6be50a63a8d9dfe7980e46b5958 | |
| - name: Cache vcpkg installed packages | |
| uses: actions/cache@v4 | |
| with: | |
| path: ${{github.workspace}}/vcpkg/installed | |
| key: vcpkg-installed-x64-linux-${{ hashFiles('scripts/vcpkg-manifest/vcpkg.json') }} | |
| restore-keys: | | |
| vcpkg-installed-x64-linux- | |
| - name: Install Ninja | |
| uses: seanmiddleditch/gha-setup-ninja@v4 | |
| - name: Build Vcpkg packages | |
| working-directory: ${{github.workspace}}/vcpkg | |
| run: | | |
| ./vcpkg install \ | |
| --x-manifest-root=../scripts/vcpkg-manifest \ | |
| --x-install-root=./installed \ | |
| --triplet=x64-linux | |
| env: | |
| CMAKE_PREFIX_PATH: ${{env.QT_ROOT_DIR}} | |
| QT_DIR: ${{env.QT_ROOT_DIR}} | |
| Qt6_DIR: ${{env.QT_ROOT_DIR}} | |
| VCPKG_KEEP_ENV_VARS: 'CMAKE_PREFIX_PATH;QT_DIR;Qt6_DIR' | |
| - name: Install OnnxRuntime | |
| working-directory: ${{github.workspace}}/src/infer | |
| run: cmake -Dep=cpu -P ../../cmake/setup-onnxruntime.cmake | |
| - name: Configure CMake | |
| run: | | |
| cmake -B ${{github.workspace}}/build -G Ninja \ | |
| -DBUILD_TESTS:BOOL=OFF \ | |
| -DCMAKE_BUILD_TYPE=Release \ | |
| -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \ | |
| -DCMAKE_PREFIX_PATH=${{env.QT_ROOT_DIR}}/lib/cmake/Qt6/ \ | |
| -DCMAKE_TOOLCHAIN_FILE=${{github.workspace}}/vcpkg/scripts/buildsystems/vcpkg.cmake \ | |
| -DONNXRUNTIME_ENABLE_DML=OFF | |
| - name: Run clang-tidy | |
| working-directory: ${{github.workspace}}/build | |
| run: | | |
| run-clang-tidy -p . -quiet 2>&1 | tee clang-tidy-results.txt | |
| if grep -qE "(warning|error):" clang-tidy-results.txt; then | |
| echo "::warning::clang-tidy found issues, see clang-tidy-results.txt" | |
| fi | |
| module-standalone: | |
| runs-on: ubuntu-24.04 | |
| if: github.event_name == 'pull_request' | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| - name: Install system dependencies | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y libgl1-mesa-dev libxkbcommon-dev libxkbcommon-x11-0 | |
| - name: Install Qt | |
| uses: jurplel/install-qt-action@v4 | |
| with: | |
| version: '6.9.3' | |
| - name: Install vcpkg | |
| uses: lukka/run-vcpkg@v11 | |
| with: | |
| vcpkgGitCommitId: 14bb451131ccf6be50a63a8d9dfe7980e46b5958 | |
| - name: Cache vcpkg installed packages | |
| uses: actions/cache@v4 | |
| with: | |
| path: ${{github.workspace}}/vcpkg/installed | |
| key: vcpkg-installed-x64-linux-${{ hashFiles('scripts/vcpkg-manifest/vcpkg.json') }} | |
| restore-keys: | | |
| vcpkg-installed-x64-linux- | |
| - name: Install Ninja | |
| uses: seanmiddleditch/gha-setup-ninja@v4 | |
| - name: Build Vcpkg packages | |
| working-directory: ${{github.workspace}}/vcpkg | |
| run: | | |
| ./vcpkg install \ | |
| --x-manifest-root=../scripts/vcpkg-manifest \ | |
| --x-install-root=./installed \ | |
| --triplet=x64-linux | |
| env: | |
| CMAKE_PREFIX_PATH: ${{env.QT_ROOT_DIR}} | |
| QT_DIR: ${{env.QT_ROOT_DIR}} | |
| Qt6_DIR: ${{env.QT_ROOT_DIR}} | |
| VCPKG_KEEP_ENV_VARS: 'CMAKE_PREFIX_PATH;QT_DIR;Qt6_DIR' | |
| - name: Install OnnxRuntime | |
| working-directory: ${{github.workspace}}/src/infer | |
| run: cmake -Dep=cpu -P ../../cmake/setup-onnxruntime.cmake | |
| - name: Configure CMake | |
| run: | | |
| cmake -B ${{github.workspace}}/build -G Ninja \ | |
| -DBUILD_TESTS:BOOL=ON \ | |
| -DCMAKE_BUILD_TYPE=Release \ | |
| -DCMAKE_PREFIX_PATH=${{env.QT_ROOT_DIR}}/lib/cmake/Qt6/ \ | |
| -DCMAKE_TOOLCHAIN_FILE=${{github.workspace}}/vcpkg/scripts/buildsystems/vcpkg.cmake \ | |
| -DONNXRUNTIME_ENABLE_DML=OFF | |
| - name: Verify framework modules build independently | |
| run: | | |
| echo "=== Verifying framework modules build independently ===" | |
| cmake --build build --target dsfw-base | |
| cmake --build build --target dsfw-core | |
| cmake --build build --target dstools-domain | |
| cmake --build build --target dstools-types | |
| cmake --build build --target slicer-lib | |
| cmake --build build --target minlabel-lib | |
| cmake --build build --target dsfw-audio | |
| cmake --build build --target dsfw-widgets | |
| echo "=== All framework modules built successfully ===" |