Skip to content

Build and Release

Build and Release #27

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
# 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
pip3 install pybind11
# macOS dependencies
- name: Install macOS dependencies
if: runner.os == 'macOS'
run: |
brew install cmake hdf5 python pybind11 boost
# Windows dependencies
- name: Install Windows dependencies
if: runner.os == 'Windows'
run: |
pip install pybind11 pytest
shell: pwsh
- name: Install HDF5 and Boost (Windows pre-built binaries)
if: runner.os == 'Windows'
run: |
# HDF5 pre-built
$hdf5_url = "https://github.com/HDFGroup/hdf5/releases/download/2.1.1/hdf5-2.1.1-win-vs2022_intel.zip"
$hdf5_zip = "${{ runner.temp }}\HDF5-2.1.1-win64.zip"
$hdf5_root = "${{ runner.temp }}\hdf5"
Write-Host "Downloading HDF5..."
Invoke-WebRequest -Uri $hdf5_url -OutFile $hdf5_zip -MaximumRetryCount 3
Expand-Archive -Path $hdf5_zip -DestinationPath $hdf5_root -Force
# Boost headers only (minimal)
$boost_url = "https://github.com/boostorg/boost/releases/download/boost-1.84.0/boost-1.84.0.tar.gz"
$boost_tar = "${{ runner.temp }}\boost.tar.gz"
$boost_root = "${{ runner.temp }}\boost"
Write-Host "Downloading Boost headers..."
Invoke-WebRequest -Uri $boost_url -OutFile $boost_tar -MaximumRetryCount 3
tar -xzf $boost_tar -C "${{ runner.temp }}"
Rename-Item -Path "${{ runner.temp }}\boost-1.84.0" -NewName "boost"
# Set environment variables using the proper method
Add-Content $env:GITHUB_ENV "HDF5_ROOT=$hdf5_root"
Add-Content $env:GITHUB_ENV "BOOST_ROOT=$boost_root"
shell: pwsh
# Configure CMake
- name: Configure CMake (Ubuntu/macOS)
if: runner.os != 'Windows'
run: |
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
- name: Configure CMake (Windows)
if: runner.os == 'Windows'
run: |
cmake -S . -B build `
-DCMAKE_BUILD_TYPE=Release `
-DHDF5_ROOT="${{ env.HDF5_ROOT }}" `
-DBOOST_ROOT="${{ env.BOOST_ROOT }}"
shell: pwsh
# 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 --config Release --parallel
shell: cmd
# 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'
run: |
cd build
ctest --output-on-failure --parallel %NUMBER_OF_PROCESSORS%
shell: cmd
# 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'
run: |
mkdir artifacts
copy build\bin\Release\MovingBoundarySolver.exe artifacts\MovingBoundarySolver-${{ matrix.artifact_prefix }}.exe
copy build\bin\Release\MovingBoundaryLib.lib artifacts\MovingBoundaryLib-${{ matrix.artifact_prefix }}.lib
copy build\bin\Release\vcellmbsolver_py*.pyd artifacts\ 2>nul || true
shell: cmd
# 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 " - {}" \;