|
| 1 | +# This starter workflow is for a CMake project running on multiple platforms. There is a different starter workflow if you just want a single platform. |
| 2 | +# See: https://github.com/actions/starter-workflows/blob/main/ci/cmake-single-platform.yml |
| 3 | +name: Build XC Reader for multi platforms. |
| 4 | + |
| 5 | +on: |
| 6 | + push: |
| 7 | + branches: [ "main" ] |
| 8 | + pull_request: |
| 9 | + branches: [ "main" ] |
| 10 | + workflow_dispatch: |
| 11 | + |
| 12 | +jobs: |
| 13 | + build: |
| 14 | + runs-on: ${{ matrix.os }} |
| 15 | + strategy: |
| 16 | + # Set fail-fast to false to ensure that feedback is delivered for all matrix combinations. Consider changing this to true when your workflow is stable. |
| 17 | + fail-fast: false |
| 18 | + |
| 19 | + # Set up a matrix to run the following 3 configurations: |
| 20 | + # 1. <Windows, Release, latest MSVC compiler toolchain on the default runner image, default generator> |
| 21 | + # 2. <Linux, Release, latest Clang compiler toolchain on the default runner image, default generator> |
| 22 | + # |
| 23 | + # To add more build types (Release, Debug, RelWithDebInfo, etc.) customize the build_type list. |
| 24 | + matrix: |
| 25 | + os: [ ubuntu-latest, windows-latest, macos-latest ] |
| 26 | + arch: [ x86_64, aarch64 ] |
| 27 | + build_type: [ Release ] |
| 28 | + c_compiler: [ clang, cl ] |
| 29 | + include: |
| 30 | + - os: windows-latest |
| 31 | + c_compiler: cl |
| 32 | + cpp_compiler: cl |
| 33 | + - os: ubuntu-latest |
| 34 | + c_compiler: clang |
| 35 | + exclude: |
| 36 | + - os: windows-latest |
| 37 | + c_compiler: clang |
| 38 | + - os: windows-latest |
| 39 | + arch: aarch64 |
| 40 | + - os: ubuntu-latest |
| 41 | + c_compiler: cl |
| 42 | + - os: macos-latest |
| 43 | + c_compiler: cl |
| 44 | + - os: macos-latest |
| 45 | + arch: aarch64 |
| 46 | + |
| 47 | + steps: |
| 48 | + - uses: actions/checkout@v4 |
| 49 | + |
| 50 | + - name: Set reusable strings |
| 51 | + id: strings |
| 52 | + shell: bash |
| 53 | + run: | |
| 54 | + echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT" |
| 55 | + echo >> $GITHUB_ENV |
| 56 | +
|
| 57 | + - name: Configure Compiler |
| 58 | + if: ${{ matrix.os == 'ubuntu-latest' }} |
| 59 | + run: | |
| 60 | + sudo apt install gcc-aarch64-linux-gnu |
| 61 | + echo -e \\nset\(CMAKE_C_FLAGS "--target=${{ matrix.arch }}-linux-gnu"\) \\n >> ${{ github.workspace }}/CMakeLists.txt |
| 62 | +
|
| 63 | + - name: Configure CMake |
| 64 | + run: > |
| 65 | + cmake -B ${{ steps.strings.outputs.build-output-dir }} |
| 66 | + -DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }} |
| 67 | + -DCMAKE_C_COMPILER=${{ matrix.c_compiler }} |
| 68 | + -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} |
| 69 | + -S ${{ github.workspace }} |
| 70 | +
|
| 71 | + - name: Build Patcher. |
| 72 | + run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }} --target xcreader |
| 73 | + |
| 74 | + - name: Upload Windows x64 Artifact |
| 75 | + uses: actions/upload-artifact@v4 |
| 76 | + if: ${{ matrix.arch == 'x86_64' && matrix.os == 'windows-latest' }} |
| 77 | + with: |
| 78 | + name: XCReader-Windows-x64 |
| 79 | + path: | |
| 80 | + ${{ steps.strings.outputs.build-output-dir }}/**/xcreader.exe |
| 81 | +
|
| 82 | + - name: Upload Linux x64 Artifact |
| 83 | + uses: actions/upload-artifact@v4 |
| 84 | + if: ${{ matrix.arch == 'x86_64' && matrix.os == 'ubuntu-latest' }} |
| 85 | + with: |
| 86 | + name: XCReader-Linux-x64 |
| 87 | + path: | |
| 88 | + ${{ steps.strings.outputs.build-output-dir }}/xcreader |
| 89 | +
|
| 90 | + - name: Upload MacOS x64 Artifact |
| 91 | + uses: actions/upload-artifact@v4 |
| 92 | + if: ${{ matrix.arch == 'x86_64' && matrix.os == 'macos-latest' }} |
| 93 | + with: |
| 94 | + name: XCReader-MacOS-x64 |
| 95 | + path: | |
| 96 | + ${{ steps.strings.outputs.build-output-dir }}/xcreader |
| 97 | +
|
| 98 | + - name: Upload Linux arm64 Artifact |
| 99 | + uses: actions/upload-artifact@v4 |
| 100 | + if: ${{ matrix.arch == 'aarch64' && matrix.os == 'ubuntu-latest' }} |
| 101 | + with: |
| 102 | + name: XCReader-Linux-arm64 |
| 103 | + path: | |
| 104 | + ${{ steps.strings.outputs.build-output-dir }}/xcreader |
0 commit comments