1- name : CI
2-
31on :
42 push :
53 branches :
64 - main
75 - master
8-
6+ tags :
7+ - ' v*' # release tags in format of e.g: 'v25.12.00'
8+
99 pull_request :
1010 types : [opened, synchronize, reopened, labeled]
1111
12+ workflow_dispatch :
13+ inputs :
14+ full_build :
15+ description : " Run full build (including macOS)"
16+ required : false
17+ default : false
18+ type : boolean
19+
1220jobs :
21+ prepare :
22+ runs-on : ubuntu-latest
23+ outputs :
24+ os_list : ${{ steps.set.outputs.os_list }}
25+ steps :
26+ - id : set
27+ run : |
28+ if [[ "${{ github.event_name }}" == "pull_request" ]] ||
29+ [[ "${{ github.event_name }}" == "push" && "${{ github.ref }}" != refs/tags/v* ]] ||
30+ [[ "${{ github.event_name }}" == "workflow_dispatch" && "${{ inputs.full_build }}" != "true" ]]; then
31+ echo 'os_list=["ubuntu-22.04","windows-2022"]' >> $GITHUB_OUTPUT
32+ else
33+ echo 'os_list=["ubuntu-22.04","windows-2022","macos-14"]' >> $GITHUB_OUTPUT
34+ fi
35+
36+ - name : Debug
37+ run : echo '${{ steps.set.outputs.os_list }}'
38+
39+
1340 build-and-test :
41+ needs : prepare
1442 name : Run on ${{ matrix.os }} with SOFA ${{ matrix.sofa_branch }}
43+
1544 if : >
16- github.event_name == 'push' ||
45+ github.event_name == 'push' || github.event_name == 'workflow_dispatch' || startsWith(github.ref, 'refs/tags/v') ||
1746 (
1847 github.event_name == 'pull_request' &&
1948 (
@@ -24,14 +53,18 @@ jobs:
2453 )
2554 )
2655 )
56+
2757 runs-on : ${{ matrix.os }}
58+
2859 strategy :
2960 fail-fast : false
61+
3062 matrix :
31- os : [ubuntu-22.04, macos-14, windows-2022]
63+ os : ${{ fromJSON(needs.prepare.outputs.os_list) }}
3264 sofa_branch : [master]
3365
3466 steps :
67+ # ###################### Setup SOFA #######################
3568 - name : Setup SOFA and environment
3669 id : sofa
3770 uses : sofa-framework/sofa-setup-action@v5
@@ -40,23 +73,26 @@ jobs:
4073 sofa_version : ${{ matrix.sofa_branch }}
4174 sofa_scope : ' full'
4275
76+ # ################ Checkout current repository ##############
4377 - name : Checkout CollisionAlgorithm
44- uses : actions/checkout@v2
78+ uses : actions/checkout@v4
4579 with :
4680 path : ${{ env.WORKSPACE_SRC_PATH }}
4781
82+ # ############### Build and install current plugin ##############
4883 - name : Build and install CollisionAlgorithm
4984 id : build-install
5085 shell : bash
5186 run : |
5287 if [[ "$RUNNER_OS" == "Windows" ]]; then
5388 cmd //c "${{ steps.sofa.outputs.vs_vsdevcmd }} \
54- && cd /d $WORKSPACE_BUILD_PATH \
89+ && cd /d %GITHUB_WORKSPACE%/build \
5590 && cmake \
5691 -GNinja \
5792 -DCMAKE_PREFIX_PATH="$SOFA_ROOT/lib/cmake" \
5893 -DCMAKE_BUILD_TYPE=Release \
5994 -DCMAKE_INSTALL_PREFIX="$WORKSPACE_INSTALL_PATH" \
95+ -DCMAKE_RUNTIME_OUTPUT_DIRECTORY=%WORKSPACE_BUILD_PATH% \
6096 ../src \
6197 && ninja install"
6298 else
@@ -108,7 +144,8 @@ jobs:
108144 ..
109145 ninja install
110146 fi
111-
147+
148+ # ################## Artifact naming ##############
112149 - name : Sanitize artifact name
113150 id : sanitize
114151 # This step removes special characters from the artifact name to ensure compatibility with upload-artifact
@@ -120,7 +157,8 @@ jobs:
120157 $originalName = "CollisionAlgorithm_${{ steps.sofa.outputs.run_branch }}_for-SOFA-${{ steps.sofa.outputs.sofa_version }}_${{ runner.os }}"
121158 $artifact_name = $originalName -replace '[":;<>|*?\r\n\\/]', '' -replace ' ', '_'
122159 echo "artifact_name=$artifact_name" >> $env:GITHUB_OUTPUT
123-
160+
161+ # ################## Create and upload artifact ##############
124162 - name : Create artifact
125163 id : create-artifact
126164 uses : actions/upload-artifact@v4.4.0
@@ -135,6 +173,7 @@ jobs:
135173 name : ${{ steps.sanitize.outputs.artifact_name }}
136174 path : ${{ env.WORKSPACE_ARTIFACT_PATH }}
137175
176+ # ################## Tests ##############
138177 - name : Launch test
139178 id : tests
140179 uses : sofa-framework/sofa-test-action@v1.0
@@ -147,12 +186,14 @@ jobs:
147186 output_dir : ${{ github.workspace }}/tests-results_dir
148187 nb_parallel_threads : ' 4'
149188
189+ # ################## Create plugin artifacts ##############
150190 deploy :
151191 name : Deploy artifacts
152- if : always() && startsWith(github.ref, 'refs/heads/main') # we are on a branch (not a PR )
192+ if : always() && startsWith(github.ref, 'refs/tags/v' )
153193 needs : [build-and-test]
154194 runs-on : ubuntu-latest
155195 continue-on-error : true
196+
156197 steps :
157198 - name : Get artifacts
158199 uses : actions/download-artifact@v4.1.7
@@ -166,6 +207,7 @@ jobs:
166207 for artifact in *; do
167208 zip $artifact.zip -r $artifact/*
168209 done
210+
169211 - name : Upload release
170212 uses : softprops/action-gh-release@v1
171213 with :
@@ -176,4 +218,3 @@ jobs:
176218 artifacts/CollisionAlgorithm_*_Linux.zip
177219 artifacts/CollisionAlgorithm_*_Windows.zip
178220 artifacts/CollisionAlgorithm_*_macOS.zip
179-
0 commit comments