|
| 1 | +name: Editor Desktop |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - '*' |
| 7 | + release: |
| 8 | + types: [published] |
| 9 | + |
| 10 | +env: |
| 11 | + BUILD_TYPE: Release |
| 12 | + TARGET: doriax-editor |
| 13 | + GLFW_VERSION: 3.4 |
| 14 | + SDL2_VERSION: 2.30.11 |
| 15 | + |
| 16 | +jobs: |
| 17 | + build: |
| 18 | + name: Build for ${{ matrix.config.name }} |
| 19 | + runs-on: ${{ matrix.config.os }} |
| 20 | + strategy: |
| 21 | + fail-fast: false |
| 22 | + matrix: |
| 23 | + config: |
| 24 | + - { |
| 25 | + name: "Windows Latest MSVC", |
| 26 | + os: windows-latest, |
| 27 | + artifact: "windows_msvc", |
| 28 | + cc: "cl", |
| 29 | + cxx: "cl", |
| 30 | + generators: "Visual Studio 17 2022" |
| 31 | + } |
| 32 | + - { |
| 33 | + name: "Windows Latest MinGW", |
| 34 | + os: windows-latest, |
| 35 | + artifact: "windows_mingw", |
| 36 | + cc: "gcc", |
| 37 | + cxx: "g++", |
| 38 | + generators: "Ninja" |
| 39 | + } |
| 40 | + - { |
| 41 | + name: "Ubuntu Latest GCC", |
| 42 | + os: ubuntu-latest, |
| 43 | + artifact: "ubuntu_gcc", |
| 44 | + cc: "gcc", |
| 45 | + cxx: "g++", |
| 46 | + generators: "Ninja" |
| 47 | + } |
| 48 | + - { |
| 49 | + name: "macOS Latest Clang", |
| 50 | + os: macos-latest, |
| 51 | + artifact: "macos_clang", |
| 52 | + cc: "clang", |
| 53 | + cxx: "clang++", |
| 54 | + generators: "Ninja" |
| 55 | + } |
| 56 | + |
| 57 | + steps: |
| 58 | + - uses: actions/checkout@v6 |
| 59 | + with: |
| 60 | + submodules: true |
| 61 | + |
| 62 | + - name: Print env |
| 63 | + run: | |
| 64 | + echo github.event.action: ${{ github.event.action }} |
| 65 | + echo github.event_name: ${{ github.event_name }} |
| 66 | +
|
| 67 | + - name: Install dependencies on Windows |
| 68 | + if: startsWith(matrix.config.os, 'windows') |
| 69 | + run: | |
| 70 | + choco install ninja cmake |
| 71 | + ninja --version |
| 72 | + cmake --version |
| 73 | +
|
| 74 | + - name: Install dependencies on Ubuntu |
| 75 | + if: startsWith(matrix.config.os, 'ubuntu') |
| 76 | + run: | |
| 77 | + sudo apt-get update |
| 78 | + sudo apt-get install ninja-build cmake libxi-dev libxcursor-dev libwayland-dev libxkbcommon-dev libxrandr-dev libxinerama-dev libglw1-mesa-dev wayland-protocols extra-cmake-modules libgtk-3-dev libdbus-1-dev |
| 79 | + ninja --version |
| 80 | + cmake --version |
| 81 | + gcc --version |
| 82 | +
|
| 83 | + - name: Install dependencies on macOS |
| 84 | + if: startsWith(matrix.config.os, 'macos') |
| 85 | + run: | |
| 86 | + # cmake is already installed |
| 87 | + brew install ninja |
| 88 | + ninja --version |
| 89 | + cmake --version |
| 90 | +
|
| 91 | + - name: Download and install GLFW |
| 92 | + shell: bash |
| 93 | + env: |
| 94 | + CC: ${{ matrix.config.cc }} |
| 95 | + CXX: ${{ matrix.config.cxx }} |
| 96 | + run: | |
| 97 | + glfwFile=glfw-${{env.GLFW_VERSION}} |
| 98 | + SUDO_CMD=$([ "$RUNNER_OS" != "Windows" ] && echo "sudo" || echo "") |
| 99 | + curl -L https://github.com/glfw/glfw/releases/download/${{env.GLFW_VERSION}}/$glfwFile.zip -o $glfwFile.zip |
| 100 | + unzip $glfwFile.zip |
| 101 | + mv $glfwFile glfw |
| 102 | + mkdir -p glfw/build |
| 103 | + cmake \ |
| 104 | + -S glfw \ |
| 105 | + -B glfw/build \ |
| 106 | + -G "${{ matrix.config.generators }}" \ |
| 107 | + -DGLFW_BUILD_DOCS=OFF \ |
| 108 | + -DGLFW_BUILD_TESTS=OFF \ |
| 109 | + -DGLFW_BUILD_EXAMPLES=OFF \ |
| 110 | + -DBUILD_SHARED_LIBS=OFF \ |
| 111 | + -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} \ |
| 112 | + -DCMAKE_MSVC_RUNTIME_LIBRARY="MultiThreaded" \ |
| 113 | + -DCMAKE_OSX_ARCHITECTURES="x86_64;arm64" \ |
| 114 | + ${{ startsWith(matrix.config.artifact, 'windows_msvc') && '-A x64' || '' }} |
| 115 | + cmake --build glfw/build --config ${{env.BUILD_TYPE}} |
| 116 | + $SUDO_CMD cmake --install glfw/build --config ${{env.BUILD_TYPE}} |
| 117 | +
|
| 118 | + - name: Download and install SDL2 |
| 119 | + shell: bash |
| 120 | + env: |
| 121 | + CC: ${{ matrix.config.cc }} |
| 122 | + CXX: ${{ matrix.config.cxx }} |
| 123 | + run: | |
| 124 | + sdlFile=SDL2-${{env.SDL2_VERSION}} |
| 125 | + SUDO_CMD=$([ "$RUNNER_OS" != "Windows" ] && echo "sudo" || echo "") |
| 126 | + curl -L https://github.com/libsdl-org/SDL/releases/download/release-${{env.SDL2_VERSION}}/$sdlFile.tar.gz -o $sdlFile.tar.gz |
| 127 | + tar xzf $sdlFile.tar.gz |
| 128 | + mv $sdlFile sdl2 |
| 129 | + mkdir -p sdl2/build |
| 130 | + cmake \ |
| 131 | + -S sdl2 \ |
| 132 | + -B sdl2/build \ |
| 133 | + -G "${{ matrix.config.generators }}" \ |
| 134 | + -DBUILD_SHARED_LIBS=OFF \ |
| 135 | + -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} \ |
| 136 | + -DCMAKE_MSVC_RUNTIME_LIBRARY="MultiThreaded" \ |
| 137 | + -DCMAKE_OSX_ARCHITECTURES="x86_64;arm64" \ |
| 138 | + ${{ startsWith(matrix.config.artifact, 'windows_msvc') && '-A x64' || '' }} |
| 139 | + cmake --build sdl2/build --config ${{env.BUILD_TYPE}} |
| 140 | + $SUDO_CMD cmake --install sdl2/build --config ${{env.BUILD_TYPE}} |
| 141 | +
|
| 142 | + - name: Set version |
| 143 | + shell: bash |
| 144 | + run: | |
| 145 | + VERSION=$(git rev-parse --short ${{ github.sha }})-${{ github.ref_name }} |
| 146 | + if [[ $VERSION == refs/tags/* ]]; then |
| 147 | + VERSION=${VERSION#refs/tags/} |
| 148 | + fi |
| 149 | + echo "DORIAX_VERSION=$VERSION" >> $GITHUB_ENV |
| 150 | + |
| 151 | + - name: Configure |
| 152 | + shell: bash |
| 153 | + env: |
| 154 | + CC: ${{ matrix.config.cc }} |
| 155 | + CXX: ${{ matrix.config.cxx }} |
| 156 | + run: | |
| 157 | + mkdir build |
| 158 | + mkdir instdir |
| 159 | + cmake \ |
| 160 | + -S . \ |
| 161 | + -B build \ |
| 162 | + -DDORIAXEDITOR_VERSION:STRING="\"${{env.DORIAX_VERSION}}\"" \ |
| 163 | + -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} \ |
| 164 | + -G "${{ matrix.config.generators }}" \ |
| 165 | + -DCMAKE_INSTALL_PREFIX:PATH=instdir \ |
| 166 | + -DCMAKE_OSX_ARCHITECTURES="x86_64;arm64" |
| 167 | +
|
| 168 | + - name: Build |
| 169 | + shell: bash |
| 170 | + env: |
| 171 | + CC: ${{ matrix.config.cc }} |
| 172 | + CXX: ${{ matrix.config.cxx }} |
| 173 | + run: cmake --build build --config ${{env.BUILD_TYPE}} --target ${{env.TARGET}} |
| 174 | + |
| 175 | + - name: Install Strip |
| 176 | + shell: bash |
| 177 | + run: cmake --install build --config ${{env.BUILD_TYPE}} --strip |
| 178 | + |
| 179 | + - name: List directories |
| 180 | + shell: bash |
| 181 | + working-directory: instdir |
| 182 | + run: ls -laR |
| 183 | + |
| 184 | + - name: Upload |
| 185 | + uses: actions/upload-artifact@v4 |
| 186 | + with: |
| 187 | + name: ${{ matrix.config.artifact }} |
| 188 | + path: ./instdir/bin/* |
| 189 | + if-no-files-found: error |
0 commit comments