|
| 1 | +# .github/workflows/cmake-multi-platform.yml |
| 2 | +name: CMake build (multi-platform) |
| 3 | + |
| 4 | +on: |
| 5 | + push: |
| 6 | + branches: [ "v21-dev" ] |
| 7 | + pull_request: |
| 8 | + branches: [ "v21-dev" ] |
| 9 | + |
| 10 | +jobs: |
| 11 | + build: |
| 12 | + runs-on: ${{ matrix.os }} |
| 13 | + strategy: |
| 14 | + fail-fast: false |
| 15 | + matrix: |
| 16 | + include: |
| 17 | + - os: ubuntu-latest |
| 18 | + cpp_compiler: g++ |
| 19 | + c_compiler: gcc |
| 20 | + - os: ubuntu-latest |
| 21 | + cpp_compiler: clang++ |
| 22 | + c_compiler: clang |
| 23 | + - os: windows-latest |
| 24 | + cpp_compiler: cl |
| 25 | + c_compiler: cl |
| 26 | + |
| 27 | + steps: |
| 28 | + - uses: actions/checkout@v4 |
| 29 | + |
| 30 | + - name: Install Linux dependencies (FLTK/X11/fontconfig) |
| 31 | + if: runner.os == 'Linux' |
| 32 | + run: | |
| 33 | + sudo apt-get update |
| 34 | + sudo apt-get install -y \ |
| 35 | + make cmake binutils \ |
| 36 | + gcc g++ \ |
| 37 | + clang \ |
| 38 | + libfontconfig1-dev libxft-dev libx11-dev \ |
| 39 | + libfltk1.3-dev |
| 40 | +
|
| 41 | + - name: Set build directory |
| 42 | + id: dirs |
| 43 | + shell: bash |
| 44 | + run: | |
| 45 | + echo "build-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT" |
| 46 | +
|
| 47 | + - name: Configure CMake |
| 48 | + shell: bash |
| 49 | + run: > |
| 50 | + cmake -S "${{ github.workspace }}" |
| 51 | + -B "${{ steps.dirs.outputs.build-dir }}" |
| 52 | + -DCMAKE_BUILD_TYPE=Release |
| 53 | + -DCMAKE_CXX_STANDARD=17 |
| 54 | + -DCMAKE_CXX_STANDARD_REQUIRED=ON |
| 55 | + -DCMAKE_C_COMPILER=${{ matrix.c_compiler }} |
| 56 | + -DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }} |
| 57 | +
|
| 58 | + - name: Build |
| 59 | + shell: bash |
| 60 | + run: > |
| 61 | + cmake --build "${{ steps.dirs.outputs.build-dir }}" |
| 62 | + --config Release |
| 63 | +
|
| 64 | + - name: Locate built binary (Linux) |
| 65 | + if: runner.os == 'Linux' |
| 66 | + id: binlinux |
| 67 | + shell: bash |
| 68 | + run: | |
| 69 | + if [ -f "${{ steps.dirs.outputs.build-dir }}/obsidian" ]; then |
| 70 | + echo "path=${{ steps.dirs.outputs.build-dir }}/obsidian" >> "$GITHUB_OUTPUT" |
| 71 | + else |
| 72 | + found="$(find "${{ steps.dirs.outputs.build-dir }}" -maxdepth 4 -type f -name 'obsidian' | head -n 1)" |
| 73 | + echo "path=$found" >> "$GITHUB_OUTPUT" |
| 74 | + fi |
| 75 | +
|
| 76 | + - name: Locate built binary (Windows) |
| 77 | + if: runner.os == 'Windows' |
| 78 | + id: binwin |
| 79 | + shell: pwsh |
| 80 | + run: | |
| 81 | + $candidates = @( |
| 82 | + "${{ steps.dirs.outputs.build-dir }}\Release\obsidian.exe", |
| 83 | + "${{ steps.dirs.outputs.build-dir }}\obsidian.exe" |
| 84 | + ) |
| 85 | + $found = $candidates | Where-Object { Test-Path $_ } | Select-Object -First 1 |
| 86 | + if (-not $found) { |
| 87 | + $found = Get-ChildItem -Path "${{ steps.dirs.outputs.build-dir }}" -Recurse -Filter "obsidian.exe" | Select-Object -First 1 |
| 88 | + if ($found) { $found = $found.FullName } |
| 89 | + } |
| 90 | + "path=$found" | Out-File -FilePath $env:GITHUB_OUTPUT -Append |
| 91 | +
|
| 92 | + - name: Upload artifact (Linux) |
| 93 | + if: runner.os == 'Linux' |
| 94 | + uses: actions/upload-artifact@v4 |
| 95 | + with: |
| 96 | + name: obsidian-linux |
| 97 | + path: ${{ steps.binlinux.outputs.path }} |
| 98 | + if-no-files-found: error |
| 99 | + |
| 100 | + - name: Upload artifact (Windows) |
| 101 | + if: runner.os == 'Windows' |
| 102 | + uses: actions/upload-artifact@v4 |
| 103 | + with: |
| 104 | + name: obsidian-windows |
| 105 | + path: ${{ steps.binwin.outputs.path }} |
| 106 | + if-no-files-found: error |
0 commit comments