MUSICardio on macOS #35
This file contains 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
# This starter workflow is for a CMake project running on a single platform. There is a different starter workflow if you need cross-platform coverage. | |
# See: https://github.com/actions/starter-workflows/blob/main/ci/cmake-multi-platform.yml | |
name: MUSICardio on macOS | |
on: | |
push: | |
branches: [ "master" ] | |
pull_request: | |
branches: [ "master" ] | |
workflow_dispatch: | |
inputs: | |
EXPIRATION_TIME: | |
description: 'Expiration time in month' | |
required: true | |
default: '12' | |
type: string | |
schedule: | |
- cron: '0 0 * * 1' # Each monday at 0h00, MIN HOUR DAY_IN_MONTH MONTH WEEK_DAY | |
env: | |
BUILD_TYPE: Release | |
QT5_DIR: "/usr/local/opt/qt@5/lib/cmake/Qt5" | |
OpenMP_ROOT: "/usr/local/Cellar/libomp/19.1.0" | |
MSC_SSH_PLUGINS: ${{ secrets.MSC_SSH_PLUGINS }} | |
MSC_TOKEN: ${{ secrets.MSC_TOKEN }} | |
jobs: | |
build: | |
# https://docs.github.com/en/actions/using-jobs/choosing-the-runner-for-a-job#standard-github-hosted-runners-for-public-repositories | |
runs-on: macos-12 | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Set up SSH | |
run: | | |
mkdir -p ~/.ssh | |
echo "$MSC_SSH_PLUGINS" > ~/.ssh/id_rsa | |
chmod 600 ~/.ssh/id_rsa | |
ssh-keyscan github.com >> ~/.ssh/known_hosts | |
- name: Install dependencies | |
run: | | |
# brew info cmake | |
brew install qt@5 | |
brew install boost | |
# brew info swig | |
brew info libomp | |
pip3 install dmgbuild | |
- name: Set default EXPIRATION_TIME if not provided (with non manual workflow) | |
run: echo "EXPIRATION_TIME=${{ inputs.EXPIRATION_TIME || '12' }}" >> $GITHUB_ENV | |
- name: Configure CMake | |
run: | | |
cmake -B ${{github.workspace}}/build \ | |
-DUSE_GITHUB_SSH:BOOL=TRUE \ | |
-DmedInria_BUILD_TYPE:STRING=$BUILD_TYPE \ | |
-Dmusic-plugins_BUILD_TYPE:STRING=$BUILD_TYPE \ | |
-DEP_CHECKBOX_CUSTOM_DIRS:BOOL=ON \ | |
-DEP_CHECKBOX_ON_TOP_LEVEL:BOOL=OFF \ | |
-DEP_CHECKBOX_SIDE_BY_SIDE:BOOL=OFF \ | |
-DQt5_DIR=$QT5_DIR \ | |
-DOpenMP_ROOT=$OpenMP_ROOT \ | |
-DUSE_FFmpeg=ON \ | |
-DEXPIRATION_TIME:STRING=$EXPIRATION_TIME \ | |
-DUSE_RealTimeWorkspace=OFF | |
- name: Build | |
run: | | |
CORES_TO_USE=$(($(sysctl -n hw.ncpu) - 1)) # Limit the number of used core otherwise the compilation crashes sometimes | |
echo "Using $CORES_TO_USE cores for the build" | |
cmake --build ${{github.workspace}}/build --config $BUILD_TYPE --parallel $CORES_TO_USE | |
- name: Package | |
run: | | |
cd ${{github.workspace}}/build | |
cpack -C $BUILD_TYPE | |
- name: Prepare DMG and update design | |
run: | | |
cd ${{github.workspace}}/build | |
dmg=$(ls *.dmg) | |
echo "The current package to adapt: $dmg" | |
if [ -n "$dmg" ]; then | |
# Attach to read-write format and retrieve mount path | |
path=$(hdiutil attach -owners on $dmg -shadow | grep -i 'Volumes' | cut -f 3) | |
echo "The current path: $path" | |
# Navigate to correct directory | |
cd "$path/MUSICardio.app/Contents/" | |
pathPluginsLegacy="${{github.workspace}}/build/medInria-build/bin/plugins_legacy" | |
# Change library paths for plugins | |
for f in PlugIns/*.dylib; do | |
install_name_tool -change $pathPluginsLegacy/libAAMeshInteractorPlugin.dylib @executable_path/../PlugIns/libAAMeshInteractorPlugin.dylib $f | |
install_name_tool -change $pathPluginsLegacy/libAAAMeshUtilityPlugin.dylib @executable_path/../PlugIns/libAAAMeshUtilityPlugin.dylib $f | |
install_name_tool -change $pathPluginsLegacy/libAAAmedPipelinePlugin.dylib @executable_path/../PlugIns/libAAAmedPipelinePlugin.dylib $f | |
install_name_tool -change $pathPluginsLegacy/libmscPipelinesPlugin.dylib @executable_path/../PlugIns/libmscPipelinesPlugin.dylib $f | |
install_name_tool -change $pathPluginsLegacy/libAAAEPMapPlugin.dylib @executable_path/../PlugIns/libAAAEPMapPlugin.dylib $f | |
install_name_tool -change $pathPluginsLegacy/libAAMFSSimulationPlugin.dylib @executable_path/../PlugIns/libAAMFSSimulationPlugin.dylib $f | |
install_name_tool -change $pathPluginsLegacy/libFEMForwardProblemPlugin.dylib @executable_path/../PlugIns/libFEMForwardProblemPlugin.dylib $f | |
done | |
# Go back to original path | |
cd "${{github.workspace}}/build" | |
# Update dmg design | |
echo "### Now we are going to update the dmg design" | |
volumeName=$(basename "$path") | |
dmgbuild -s ../packaging/apple/settings.json "$volumeName" MUSICardio.dmg | |
echo "End of the processes" | |
else | |
echo "A problem happened in MSC compilation, no dmg is built" | |
fi | |
- name: Install Git LFS | |
run: git lfs install | |
- name: Transfer binary to external repository | |
run: | | |
if [ -z "$MSC_TOKEN" ]; then | |
echo "MSC_TOKEN is not set" | |
exit 1 | |
fi | |
git clone https://[email protected]/Inria-Asclepios/msc_binaries.git | |
cd msc_binaries | |
cp ../build/MUSICardio.dmg . | |
git lfs track "*.dmg" | |
git add .gitattributes MUSICardio.dmg | |
git commit -m "Add new DMG file" | |
git push |