forked from medInria/medInria-public
-
Notifications
You must be signed in to change notification settings - Fork 0
163 lines (137 loc) · 6.43 KB
/
musicardio-macos.yml
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
# 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: [ "4.1" ]
pull_request:
branches: [ "4.1" ]
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"
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-13
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: 4.1
- 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 install qt@5
brew install boost
brew install swig
brew install libomp
echo "OpenMP_ROOT=$(brew --prefix libomp)" >> $GITHUB_ENV
pip3 install dmgbuild
# brew info cmake
- 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: Transfer binary to external repository
run: |
if [ -z "$MSC_TOKEN" ]; then
echo "MSC_TOKEN is not set"
exit 1
fi
OWNER="Inria-Asclepios"
REPO="msc_binaries"
ASSET_NAME="MUSICardio.dmg"
NEW_BINARY_PATH="MUSICardio.dmg"
# Get the release and asset (binary) ID
RELEASE_INFO=$(curl -s -H "Authorization: Bearer $MSC_TOKEN" \
"https://api.github.com/repos/$OWNER/$REPO/releases/latest")
echo "RELEASE_INFO: $RELEASE_INFO"
RELEASE_ID=$(echo $RELEASE_INFO | jq -r '.id')
ASSET_ID=$(echo $RELEASE_INFO | jq -r --arg NAME "$ASSET_NAME" '.assets[] | select(.name == $NAME) | .id')
if [ "$RELEASE_ID" == "null" ] || [ -z "$RELEASE_ID" ]; then
echo "No published release found. Please create a release first."
exit 1
fi
# Remove old asset if exist
if [ "$ASSET_ID" == "null" ] || [ -z "$ASSET_ID" ]; then
echo "No existing asset named $ASSET_NAME found in the release."
else
curl -X DELETE -H "Authorization: Bearer $MSC_TOKEN" \
"https://api.github.com/repos/$OWNER/$REPO/releases/assets/$ASSET_ID"
echo "Asset $ASSET_NAME deleted successfully."
fi
# Upload new binary
curl -X POST -H "Authorization: Bearer $MSC_TOKEN" \
-H "Content-Type: application/octet-stream" \
--data-binary @"$NEW_BINARY_PATH" \
"https://uploads.github.com/repos/$OWNER/$REPO/releases/$RELEASE_ID/assets?name=$ASSET_NAME"
echo "New binary uploaded successfully."