diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index e5d889d2d6..00faa26e8c 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -120,29 +120,14 @@ jobs: repository: ${{ github.event.pull_request.head.repo.full_name || github.repository }} submodules: recursive - - name: Check if C++ build needed - id: check-cpp - run: | - if [ "${{ needs.check-changes.outputs.should-build }}" != "true" ]; then - echo "No C++ changes detected, skipping build steps" - echo "skip=true" >> $GITHUB_OUTPUT - else - echo "C++ changes detected, proceeding with build" - echo "skip=false" >> $GITHUB_OUTPUT - fi - shell: bash - - uses: ilammy/msvc-dev-cmd@v1.10.0 - if: steps.check-cpp.outputs.skip != 'true' - name: Setup vcpkg - if: steps.check-cpp.outputs.skip != 'true' uses: lukka/run-vcpkg@v11.5 with: vcpkgJsonGlob: vcpkg.json - name: Cache CMake build output - if: steps.check-cpp.outputs.skip != 'true' uses: actions/cache@v4 with: path: build/ALL @@ -152,7 +137,6 @@ jobs: ${{ runner.os }}-cmake- - name: Build using run-cmake - if: steps.check-cpp.outputs.skip != 'true' uses: lukka/run-cmake@v10 with: configurePreset: ALL @@ -160,19 +144,22 @@ jobs: - name: Extract version from CMake id: get_version - shell: bash + shell: pwsh run: | - if [ "${{ steps.check-cpp.outputs.skip }}" == "true" ]; then - # When skipping build, extract version from CMakeLists.txt - VERSION=$(grep 'project(.*VERSION' CMakeLists.txt | sed -E 's/.*VERSION ([0-9]+\.[0-9]+\.[0-9]+).*/\1/') - else - # When building, extract version from CMakeCache.txt - VERSION=$(grep 'CMAKE_PROJECT_VERSION:STATIC' build/ALL/CMakeCache.txt | cut -d= -f2) - fi - echo "version=$VERSION" >> $GITHUB_OUTPUT + $content = Get-Content build/ALL/CMakeCache.txt + $versionLine = $content | Select-String -Pattern 'CMAKE_PROJECT_VERSION:STATIC' + if ($versionLine) { + $version = ($versionLine -replace '.*=([0-9]+\.[0-9]+\.[0-9]+).*', '$1').ToString() + } else { + Write-Error "Version extraction failed: CMAKE_PROJECT_VERSION not found in CMakeCache.txt" -ErrorAction Stop + } + if (-not $version -or $version -eq "") { + Write-Error "Version extraction failed: no version found" -ErrorAction Stop + } + "version=$version" | Out-File -FilePath $env:GITHUB_OUTPUT -Append - name: Upload dist artifacts - if: success() && steps.check-cpp.outputs.skip != 'true' + if: success() uses: actions/upload-artifact@v4 with: name: dist-artifacts