Enhance README #270
This file contains hidden or 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
| name: Cross-compile | |
| on: [push, workflow_dispatch] | |
| jobs: | |
| build: | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| matrix: | |
| os: [ ubuntu-22.04, windows-2022 ] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Configure and build (Linux) | |
| if: startsWith(runner.os, 'Linux') | |
| run: | | |
| cmake . -B build -DFMU4CPP_BUILD_TESTS=OFF | |
| cmake --build build | |
| - name: Configure and build (Windows) | |
| if: startsWith(runner.os, 'Windows') | |
| run: | | |
| cmake . -B build -DFMU4CPP_BUILD_TESTS=OFF -A x64 | |
| cmake --build build --config Release | |
| - name: "Stage models for upload (Linux)" | |
| if: startsWith(runner.os, 'Linux') | |
| run: | | |
| mkdir -p artifacts/models-${{ matrix.os }} | |
| rsync -a --exclude='*.fmu' build/models/ artifacts/models/ || true | |
| - name: "Stage models for upload (Windows)" | |
| if: startsWith(runner.os, 'Windows') | |
| shell: pwsh | |
| run: | | |
| $dst = Join-Path $env:GITHUB_WORKSPACE "artifacts\models" | |
| New-Item -ItemType Directory -Force -Path $dst | Out-Null | |
| $rc = robocopy "$env:GITHUB_WORKSPACE\build\models" $dst /S /XF *.fmu | |
| if ($rc -ge 8) { exit $rc } | |
| - name: Upload models | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: models-${{ matrix.os }} | |
| path: artifacts/models | |
| deploy: | |
| needs: build | |
| runs-on: ubuntu-22.04 | |
| steps: | |
| - name: "Download models" | |
| uses: actions/download-artifact@v4 | |
| with: | |
| pattern: models-* | |
| path: models | |
| merge-multiple: true | |
| - name: "Set permissions" | |
| run: | | |
| set -euo pipefail | |
| find models -type d -name binaries -print0 2>/dev/null | xargs -0 -r sudo chmod -R a+X || true | |
| - name: "Zip model folders" | |
| run: | | |
| set -euo pipefail | |
| shopt -s nullglob | |
| for dir in models/fmi*/*; do | |
| if [ -d "$dir" ]; then | |
| zip_path="$dir.fmu" | |
| echo "Zipping contents of $dir -> $zip_path" | |
| (cd "$dir" && zip -r "../$(basename "$dir").fmu" .) | |
| echo "Deleting folder: $dir" | |
| rm -rf "$dir" | |
| fi | |
| done | |
| - name: "Upload merged models" | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: models-merged | |
| path: models |