| 1 | name: Build |
| 2 | on: [push, pull_request] |
| 3 | |
| 4 | jobs: |
| 5 | version: |
| 6 | name: Extract Version |
| 7 | runs-on: ubuntu-latest |
| 8 | outputs: |
| 9 | version: ${{ steps.extract-version.outputs.result }} |
| 10 | steps: |
| 11 | - uses: actions/checkout@v4 |
| 12 | - name: CMake Configure |
| 13 | id: extract-version |
| 14 | run: | |
| 15 | cmake -S . -B build -G Ninja -DBUILD_CLIENT=NO |
| 16 | VERSION=$(cat build/version.txt) |
| 17 | echo "VERSION: ${VERSION}" |
| 18 | echo "result=${VERSION}" >> $GITHUB_OUTPUT |
| 19 | |
| 20 | linux: |
| 21 | name: Linux |
| 22 | runs-on: ubuntu-22.04 |
| 23 | needs: version |
| 24 | steps: |
| 25 | - uses: actions/checkout@v4 |
| 26 | - name: Install Dependencies |
| 27 | run: | |
| 28 | sudo apt-get update |
| 29 | sudo apt-get install libsdl2-dev |
| 30 | - name: Compile |
| 31 | run: | |
| 32 | cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release |
| 33 | cmake --build build |
| 34 | cpack --config build/CPackConfig.cmake -B build/installer --verbose |
| 35 | mv build/installer/*.deb build/Release |
| 36 | - name: Upload |
| 37 | uses: actions/upload-artifact@v4 |
| 38 | with: |
| 39 | name: ${{ github.event.repository.name }}-linux-${{ needs.version.outputs.version }} |
| 40 | path: | |
| 41 | build/Release/**/* |
| 42 | windows-msvc: |
| 43 | name: Windows MSVC |
| 44 | runs-on: windows-2022 |
| 45 | needs: version |
| 46 | steps: |
| 47 | - uses: actions/checkout@v4 |
| 48 | - name: Compile |
| 49 | run: | |
| 50 | cmake -S . -B build -G "Visual Studio 17 2022" |
| 51 | cmake --build build --config Release |
| 52 | cpack --config build/CPackConfig.cmake -B build/installer --verbose |
| 53 | Move-Item -Path "build/installer/*.exe" -Destination "build/Release" |
| 54 | - name: Upload |
| 55 | uses: actions/upload-artifact@v4 |
| 56 | with: |
| 57 | name: ${{ github.event.repository.name }}-windows-msvc-${{ needs.version.outputs.version }} |
| 58 | path: | |
| 59 | build/Release/**/*.dll |
| 60 | build/Release/**/*.exe |
| 61 | build/Release/**/*.qvm |
| 62 | windows-mingw: |
| 63 | name: Windows MinGW |
| 64 | runs-on: windows-2022 |
| 65 | needs: version |
| 66 | steps: |
| 67 | - uses: actions/checkout@v4 |
| 68 | - name: Compile |
| 69 | run: | |
| 70 | cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release |
| 71 | cmake --build build |
| 72 | cpack --config build/CPackConfig.cmake -B build/installer --verbose |
| 73 | Move-Item -Path "build/installer/*.exe" -Destination "build/Release" |
| 74 | - name: Upload |
| 75 | uses: actions/upload-artifact@v4 |
| 76 | with: |
| 77 | name: ${{ github.event.repository.name }}-windows-mingw-${{ needs.version.outputs.version }} |
| 78 | path: | |
| 79 | build/Release/**/*.dll |
| 80 | build/Release/**/*.exe |
| 81 | build/Release/**/*.qvm |
| 82 | macos: |
| 83 | name: macOS |
| 84 | runs-on: macos-15 |
| 85 | needs: version |
| 86 | steps: |
| 87 | - uses: actions/checkout@v4 |
| 88 | - name: Import Code Signing Certificate |
| 89 | if: github.ref_name == 'main' |
| 90 | run: | |
| 91 | misc/macos/ci-macos-import-codesign-cert.sh |
| 92 | echo "APPLE_CERTIFICATE_ID=${{ secrets.APPLE_CERTIFICATE_ID }}" >> $GITHUB_ENV |
| 93 | env: |
| 94 | APPLE_CERTIFICATE_P12_BASE64: ${{ secrets.APPLE_CERTIFICATE_P12_BASE64 }} |
| 95 | APPLE_CERTIFICATE_PASSWORD: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }} |
| 96 | - name: Compile |
| 97 | run: | |
| 98 | cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release |
| 99 | cmake --build build |
| 100 | # DMG creation on macOS occasionally fails, so try multiple times |
| 101 | # https://gitlab.kitware.com/cmake/cmake/-/issues/25671 |
| 102 | success=0 |
| 103 | max_tries=10 |
| 104 | for i in $(seq $max_tries); do |
| 105 | cpack --config build/CPackConfig.cmake -B build/installer --verbose && success=1 |
| 106 | if test $success = 1; then |
| 107 | break |
| 108 | fi |
| 109 | echo "Package creation failed. Sleep 1 second and try again." |
| 110 | sleep 1 |
| 111 | done |
| 112 | if test $success = 0; then |
| 113 | echo "Package creation failed after $max_tries attempts." |
| 114 | exit 1 |
| 115 | fi |
| 116 | mv build/installer/*.dmg build/Release |
| 117 | - name: Notarize |
| 118 | if: github.ref_name == 'main' |
| 119 | run: | |
| 120 | misc/macos/ci-macos-notarize.sh build/Release/*.dmg |
| 121 | env: |
| 122 | APPLE_NOTARIZATION_USERNAME: ${{ secrets.APPLE_NOTARIZATION_USERNAME }} |
| 123 | APPLE_NOTARIZATION_PASSWORD: ${{ secrets.APPLE_NOTARIZATION_PASSWORD }} |
| 124 | APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }} |
| 125 | - name: Upload |
| 126 | uses: actions/upload-artifact@v4 |
| 127 | with: |
| 128 | name: ${{ github.event.repository.name }}-macOS-${{ needs.version.outputs.version }} |
| 129 | path: | |
| 130 | build/Release/**/* |
| 131 | emscripten: |
| 132 | name: Emscripten |
| 133 | runs-on: ubuntu-22.04 |
| 134 | needs: version |
| 135 | steps: |
| 136 | - uses: actions/checkout@v4 |
| 137 | - name: Install emsdk |
| 138 | uses: mymindstorm/setup-emsdk@v13 |
| 139 | with: |
| 140 | version: 3.1.58 |
| 141 | - name: Compile |
| 142 | run: | |
| 143 | emcmake cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release |
| 144 | cmake --build build |
| 145 | - name: Upload |
| 146 | uses: actions/upload-artifact@v4 |
| 147 | with: |
| 148 | name: ${{ github.event.repository.name }}-emscripten-${{ needs.version.outputs.version }} |
| 149 | path: | |
| 150 | build/Release/**/* |
| 151 | linux-external-libraries: |
| 152 | name: Linux (USE_INTERNAL_LIBS OFF) |
| 153 | runs-on: ubuntu-22.04 |
| 154 | steps: |
| 155 | - uses: actions/checkout@v4 |
| 156 | - name: Install Dependencies |
| 157 | run: | |
| 158 | sudo apt-get update |
| 159 | sudo apt-get install libsdl2-dev zlib1g-dev libjpeg-dev libopenal-dev \ |
| 160 | libogg-dev libvorbis-dev libopus-dev libopusfile-dev libcurl4-openssl-dev |
| 161 | - name: Compile |
| 162 | run: | |
| 163 | cmake -S . -B build -G Ninja -DUSE_INTERNAL_LIBS=OFF -DCMAKE_BUILD_TYPE=Release |
| 164 | cmake --build build |
| 165 | linux-32bit: |
| 166 | name: Linux 32-bit |
| 167 | runs-on: ubuntu-22.04 |
| 168 | steps: |
| 169 | - uses: actions/checkout@v4 |
| 170 | - name: Install Dependencies |
| 171 | run: | |
| 172 | sudo dpkg --add-architecture i386 |
| 173 | sudo apt-get update |
| 174 | sudo apt-get install gcc-multilib libsdl2-dev:i386 |
| 175 | - name: Compile |
| 176 | run: | |
| 177 | cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_FLAGS="-m32 -msse -msse2" |
| 178 | cmake --build build |
| 179 | freebsd: |
| 180 | name: FreeBSD |
| 181 | runs-on: ubuntu-latest |
| 182 | steps: |
| 183 | - uses: actions/checkout@v4 |
| 184 | - name: Compile |
| 185 | uses: vmactions/freebsd-vm@v1 |
| 186 | with: |
| 187 | prepare: | |
| 188 | pkg install -y cmake ninja devel/sdl20 |
| 189 | run: | |
| 190 | cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release |
| 191 | cmake --build build |
| 192 | openbsd: |
| 193 | name: OpenBSD |
| 194 | runs-on: ubuntu-latest |
| 195 | steps: |
| 196 | - uses: actions/checkout@v4 |
| 197 | - name: Compile |
| 198 | uses: vmactions/openbsd-vm@v1 |
| 199 | with: |
| 200 | prepare: | |
| 201 | pkg_add cmake ninja sdl2 |
| 202 | run: | |
| 203 | cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release |
| 204 | cmake --build build |
| 205 | |
| 206 | check-is-release: |
| 207 | if: github.event_name != 'pull_request' |
| 208 | name: Check For Release Tag |
| 209 | runs-on: ubuntu-latest |
| 210 | needs: version |
| 211 | outputs: |
| 212 | is-release: ${{ steps.is-release-test.outputs.result }} |
| 213 | steps: |
| 214 | - uses: actions/checkout@v4 |
| 215 | - name: Check Release Tag |
| 216 | id: is-release-test |
| 217 | run: | |
| 218 | GIT_TAG=$(git describe --exact-match --tags || true) |
| 219 | if [[ -z "${GIT_TAG}" || "${{ github.ref_type }}" != 'tag' ]] |
| 220 | then |
| 221 | echo "Not tagged" |
| 222 | echo "result=false" >> $GITHUB_OUTPUT |
| 223 | else |
| 224 | echo "GIT_TAG: ${GIT_TAG}"" |
| 225 | echo "needs.version.outputs.version: ${{ needs.version.outputs.version }}"" |
| 226 | if [[ "${GIT_TAG}" = "${{ needs.version.outputs.version }}" ]] |
| 227 | then |
| 228 | echo "'${GIT_TAG}' is a release" |
| 229 | echo "result=true" >> $GITHUB_OUTPUT |
| 230 | else |
| 231 | echo "'${GIT_TAG}' is not a release" |
| 232 | echo "result=false" >> $GITHUB_OUTPUT |
| 233 | fi |
| 234 | fi |
| 235 | |
| 236 | release: |
| 237 | name: Release |
| 238 | if: github.event_name != 'pull_request' && needs.check-is-release.outputs.is-release == 'true' |
| 239 | runs-on: ubuntu-latest |
| 240 | needs: |
| 241 | - version |
| 242 | - check-is-release |
| 243 | - windows-msvc |
| 244 | - macos |
| 245 | - linux |
| 246 | - emscripten |
| 247 | steps: |
| 248 | - uses: actions/download-artifact@v4 |
| 249 | - name: Prepare Release Artifacts |
| 250 | run: | |
| 251 | mkdir release-artifacts |
| 252 | mv ${{ github.event.repository.name }}-linux-${{ needs.version.outputs.version }}/${{ github.event.repository.name }}-${{ needs.version.outputs.version }}.deb \ |
| 253 | release-artifacts |
| 254 | zip -r9 release-artifacts/${{ github.event.repository.name }}-linux-${{ needs.version.outputs.version }}.zip \ |
| 255 | ${{ github.event.repository.name }}-linux-${{ needs.version.outputs.version }} |
| 256 | mv ${{ github.event.repository.name }}-windows-msvc-${{ needs.version.outputs.version }}/${{ github.event.repository.name }}-${{ needs.version.outputs.version }}.exe \ |
| 257 | release-artifacts |
| 258 | mv ${{ github.event.repository.name }}-macOS-${{ needs.version.outputs.version }}/${{ github.event.repository.name }}-${{ needs.version.outputs.version }}.dmg \ |
| 259 | release-artifacts |
| 260 | zip -r9 release-artifacts/${{ github.event.repository.name }}-emscripten-${{ needs.version.outputs.version }}.zip \ |
| 261 | ${{ github.event.repository.name }}-emscripten-${{ needs.version.outputs.version }} |
| 262 | - name: Publish Release Artifacts |
| 263 | uses: softprops/action-gh-release@v1 |
| 264 | with: |
| 265 | tag_name: ${{ github.ref }} |
| 266 | name: Release ${{ needs.version.outputs.version }} |
| 267 | files: release-artifacts/* |
| 268 | env: |
| 269 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |