Build and Release #123
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 and Release | |
| # Builds the native standalone MovingBoundarySolver executable (+ static lib) | |
| # and attaches them to a GitHub Release on each v* tag. | |
| # | |
| # Native source builds are exercised on Linux, macOS, and Windows here. | |
| # Python wheels are also built for Windows by wheels.yml (via cibuildwheel + | |
| # vcpkg), which publishes redistributable wheels across all three platforms. | |
| # | |
| # Windows: all configure/build/test logic is delegated to build-windows.ps1 so | |
| # that the CMake flags stay in one authoritative place and don't drift between | |
| # the developer script and CI. | |
| on: | |
| push: | |
| tags: | |
| - 'v*' | |
| workflow_dispatch: | |
| jobs: | |
| build: | |
| name: Build on ${{ matrix.os }} | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ubuntu-latest, macos-14, windows-latest] | |
| include: | |
| - os: ubuntu-latest | |
| artifact_prefix: linux | |
| - os: macos-14 | |
| artifact_prefix: macos | |
| - os: windows-latest | |
| artifact_prefix: windows | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: '24' | |
| - name: Cache vcpkg artifacts | |
| if: runner.os == 'Windows' | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ${{ github.workspace }}/vcpkg_installed | |
| key: vcpkg-${{ runner.os }}-${{ hashFiles('vcpkg.json') }} | |
| restore-keys: | | |
| vcpkg-${{ runner.os }}- | |
| - name: Configure git for private submodules | |
| shell: bash | |
| run: | | |
| git config --global url."https://x-access-token:${{ secrets.SUBMODULE_TOKEN }}@github.com/".insteadOf "https://github.com/" | |
| - name: Initialize submodules | |
| shell: bash | |
| run: git submodule update --init --recursive | |
| # ----------------------------------------------------------------------- | |
| # Unix dependency installation | |
| # ----------------------------------------------------------------------- | |
| - name: Install Ubuntu dependencies | |
| if: runner.os == 'Linux' | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y cmake libhdf5-dev python3-dev python3-pip pybind11-dev libboost-dev libcurl4-openssl-dev | |
| pip3 install pybind11 | |
| - name: Install macOS dependencies | |
| if: runner.os == 'macOS' | |
| run: | | |
| brew install cmake hdf5 python pybind11 boost curl | |
| # ----------------------------------------------------------------------- | |
| # Windows: install Strawberry Perl (needed by some vcpkg ports) and run | |
| # vcpkg in manifest mode to populate vcpkg_installed/. The configure, | |
| # build, and test steps are all handled by build-windows.ps1 below. | |
| # ----------------------------------------------------------------------- | |
| - name: Install Windows system prerequisites | |
| if: runner.os == 'Windows' | |
| shell: pwsh | |
| run: choco install strawberryperl -y | |
| - name: Install Windows vcpkg dependencies | |
| if: runner.os == 'Windows' | |
| shell: pwsh | |
| run: | | |
| $vcpkgRoot = if ($env:VCPKG_INSTALLATION_ROOT -and (Test-Path (Join-Path $env:VCPKG_INSTALLATION_ROOT 'vcpkg.exe'))) { | |
| $env:VCPKG_INSTALLATION_ROOT | |
| } elseif (Test-Path 'C:\vcpkg\vcpkg.exe') { | |
| 'C:\vcpkg' | |
| } else { | |
| throw 'vcpkg.exe not found on the runner' | |
| } | |
| Set-Location "$env:GITHUB_WORKSPACE" | |
| & (Join-Path $vcpkgRoot 'vcpkg.exe') install --triplet x64-windows | |
| # ----------------------------------------------------------------------- | |
| # Unix configure + build | |
| # ----------------------------------------------------------------------- | |
| - name: Configure CMake (Unix) | |
| if: runner.os != 'Windows' | |
| run: cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DOPTION_TARGET_MESSAGING=ON | |
| - name: Build (Unix) | |
| if: runner.os != 'Windows' | |
| run: cmake --build build --parallel | |
| # ----------------------------------------------------------------------- | |
| # Windows configure + build via build-windows.ps1 | |
| # (-SkipVcpkg: vcpkg install was already done above for caching purposes) | |
| # ----------------------------------------------------------------------- | |
| - name: Configure, build, and test (Windows) | |
| if: runner.os == 'Windows' | |
| shell: pwsh | |
| run: | | |
| .\build-windows.ps1 -SkipVcpkg -Test -Config Release | |
| # ----------------------------------------------------------------------- | |
| # Unix tests | |
| # ----------------------------------------------------------------------- | |
| - name: Run tests (Unix) | |
| if: runner.os != 'Windows' | |
| shell: bash | |
| run: | | |
| cd build | |
| ctest --output-on-failure -j"$(getconf _NPROCESSORS_ONLN)" | |
| # ----------------------------------------------------------------------- | |
| # Gather artifacts | |
| # ----------------------------------------------------------------------- | |
| - name: Prepare artifacts | |
| shell: bash | |
| run: | | |
| mkdir -p artifacts | |
| if [ "${{ runner.os }}" = "Windows" ]; then | |
| cp build/bin/Release/MovingBoundarySolver.exe artifacts/MovingBoundarySolver-${{ matrix.artifact_prefix }}.exe | |
| cp build/bin/Release/MovingBoundaryLib.lib artifacts/MovingBoundaryLib-${{ matrix.artifact_prefix }}.lib | |
| else | |
| cp build/bin/MovingBoundarySolver artifacts/MovingBoundarySolver-${{ matrix.artifact_prefix }} | |
| cp build/bin/libMovingBoundaryLib.a artifacts/libMovingBoundaryLib-${{ matrix.artifact_prefix }}.a | |
| fi | |
| - name: Upload artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ${{ matrix.artifact_prefix }}-artifacts | |
| path: artifacts/ | |
| retention-days: 1 | |
| release: | |
| name: Create Release | |
| needs: build | |
| runs-on: ubuntu-latest | |
| if: startsWith(github.ref, 'refs/tags/') | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Download all artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: all-artifacts | |
| - name: Create Release | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| files: all-artifacts/**/* | |
| draft: false | |
| prerelease: false | |
| generate_release_notes: true | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Display release info | |
| run: | | |
| echo "Release created successfully!" | |
| find all-artifacts -type f -exec echo " - {}" \; |