-
Notifications
You must be signed in to change notification settings - Fork 0
181 lines (153 loc) · 5.89 KB
/
Copy pathbuild-and-release.yml
File metadata and controls
181 lines (153 loc) · 5.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
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'
shell: pwsh
run: |
choco install -y 7zip
Write-Host "Cloning vcpkg into $env:RUNNER_TEMP\vcpkg"
git clone https://github.com/microsoft/vcpkg.git "$env:RUNNER_TEMP\vcpkg"
& "$env:RUNNER_TEMP\vcpkg\bootstrap-vcpkg.bat"
$vcpkgExe = "$env:RUNNER_TEMP\vcpkg\vcpkg.exe"
# Install HDF5 with C++ support and Boost
& $vcpkgExe install hdf5[core,cpp]:x64-windows boost:x64-windows
if ($LASTEXITCODE -ne 0) { throw "vcpkg install failed" }
Add-Content -Path $env:GITHUB_ENV -Value "HDF5_ROOT=$env:RUNNER_TEMP\vcpkg\installed\x64-windows"
Add-Content -Path $env:GITHUB_ENV -Value "BOOST_ROOT=$env:RUNNER_TEMP\vcpkg\installed\x64-windows"
Add-Content -Path $env:GITHUB_ENV -Value "CMAKE_TOOLCHAIN_FILE=$env:RUNNER_TEMP\vcpkg\scripts\buildsystems\vcpkg.cmake"
# 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'
shell: pwsh
run: |
$vcpkgRoot = $env:RUNNER_TEMP + "\vcpkg"
$instPrefix = "$vcpkgRoot\installed\x64-windows" -replace '\\','/'
$vcpkgToolchain = "$vcpkgRoot\scripts\buildsystems\vcpkg.cmake" -replace '\\','/'
& cmake -S . -B build -G "Visual Studio 17 2022" -A x64 `
-DCMAKE_BUILD_TYPE=Release `
-DCMAKE_TOOLCHAIN_FILE="$vcpkgToolchain" `
-DVCPKG_TARGET_TRIPLET="x64-windows" `
-DCMAKE_PREFIX_PATH="$instPrefix" `
-DHDF5_ROOT="$instPrefix" `
-DBOOST_ROOT="$instPrefix"
if ($LASTEXITCODE -ne 0) { throw "CMake configuration failed" }
- 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 " - {}" \;