Build and Release #42
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 | |
| on: | |
| push: | |
| tags: | |
| - 'v*' | |
| workflow_dispatch: | |
| jobs: | |
| build: | |
| name: Build on ${{ matrix.os }} | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| matrix: | |
| os: [ubuntu-latest, macos-latest, windows-latest] | |
| include: | |
| - os: ubuntu-latest | |
| artifact_prefix: linux | |
| - os: macos-latest | |
| artifact_prefix: macos | |
| - os: windows-latest | |
| artifact_prefix: windows | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Configure git for private submodule | |
| run: | | |
| git config --global url."https://x-access-token:${{ secrets.SUBMODULE_TOKEN }}@github.com/".insteadOf "https://github.com/" | |
| shell: bash | |
| - name: Initialize submodules | |
| run: git submodule update --init --recursive | |
| shell: bash | |
| # Ubuntu dependencies | |
| - 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 | |
| # macOS dependencies | |
| - name: Install macOS dependencies | |
| if: runner.os == 'macOS' | |
| run: | | |
| brew install cmake hdf5 python pybind11 boost curl | |
| # Windows dependencies | |
| - name: Setup vcpkg and Ninja (Windows) | |
| if: runner.os == 'Windows' | |
| shell: pwsh | |
| run: | | |
| pip install pybind11 pytest | |
| choco install -y ninja | |
| git clone --depth 1 https://github.com/microsoft/vcpkg.git "$env:RUNNER_TEMP\vcpkg" | |
| & "$env:RUNNER_TEMP\vcpkg\bootstrap-vcpkg.bat" | |
| Add-Content -Path $env:GITHUB_ENV -Value "VCPKG_TOOLCHAIN=$env:RUNNER_TEMP\vcpkg\scripts\buildsystems\vcpkg.cmake" | |
| - name: Install dependencies with vcpkg (Windows) | |
| if: runner.os == 'Windows' | |
| shell: pwsh | |
| run: | | |
| $vcpkg = "$env:RUNNER_TEMP\vcpkg\vcpkg.exe" | |
| & $vcpkg install hdf5[core,cpp]:x64-windows boost:x64-windows pybind11:x64-windows pthread:x64-windows curl:x64-windows --clean-after-build | |
| if ($LASTEXITCODE -ne 0) { exit 1 } | |
| # Configure CMake | |
| - name: Configure CMake (Ubuntu/macOS) | |
| if: runner.os != 'Windows' | |
| run: | | |
| cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DOPTION_TARGET_MESSAGING=ON | |
| - name: Configure CMake (Windows) | |
| if: runner.os == 'Windows' | |
| shell: pwsh | |
| run: | | |
| cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DOPTION_TARGET_MESSAGING=ON -DCMAKE_TOOLCHAIN_FILE="$env:VCPKG_TOOLCHAIN" | |
| if ($LASTEXITCODE -ne 0) { exit 1 } | |
| # Build | |
| - name: Build (Ubuntu/macOS) | |
| if: runner.os != 'Windows' | |
| run: cmake --build build --parallel | |
| - name: Build (Windows) | |
| if: runner.os == 'Windows' | |
| run: cmake --build build --parallel | |
| shell: pwsh | |
| # Run tests | |
| - name: Install test dependencies | |
| run: pip install pytest | |
| shell: bash | |
| - name: Run tests (Ubuntu/macOS) | |
| if: runner.os != 'Windows' | |
| run: | | |
| cd build | |
| ctest --output-on-failure -j$(nproc) | |
| - name: Run tests (Windows) | |
| if: runner.os == 'Windows' | |
| shell: pwsh | |
| run: | | |
| cd build | |
| ctest --output-on-failure --parallel $env:NUMBER_OF_PROCESSORS | |
| if ($LASTEXITCODE -ne 0) { exit 1 } | |
| # Prepare artifacts | |
| - name: Prepare artifacts (Ubuntu/macOS) | |
| if: runner.os != 'Windows' | |
| run: | | |
| mkdir -p artifacts | |
| cp build/bin/MovingBoundarySolver artifacts/MovingBoundarySolver-${{ matrix.artifact_prefix }} | |
| cp build/bin/libMovingBoundaryLib.a artifacts/libMovingBoundaryLib-${{ matrix.artifact_prefix }}.a | |
| cp build/bin/vcellmbsolver_py*.so artifacts/ 2>/dev/null || true | |
| - name: Prepare artifacts (Windows) | |
| if: runner.os == 'Windows' | |
| shell: pwsh | |
| run: | | |
| New-Item -ItemType Directory -Path artifacts -Force | Out-Null | |
| Copy-Item -Path build\bin\MovingBoundarySolver.exe -Destination artifacts\MovingBoundarySolver-${{ matrix.artifact_prefix }}.exe -Force | |
| Copy-Item -Path build\bin\MovingBoundaryLib.lib -Destination artifacts\MovingBoundaryLib-${{ matrix.artifact_prefix }}.lib -Force | |
| Get-ChildItem -Path build\bin\vcellmbsolver_py*.pyd -ErrorAction SilentlyContinue | ForEach-Object { | |
| Copy-Item -Path $_.FullName -Destination artifacts\ -Force | |
| } | |
| # Upload artifacts | |
| - 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 " - {}" \; |