diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 000000000..85184856c --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,181 @@ +name: build +on: [push, pull_request, workflow_dispatch] + +jobs: + build: + strategy: + matrix: + include: + - configurePreset: msvc-x64 + buildPreset: msvc-x64-release + executable: "ezquake-amd64.exe" + os: windows-latest + should_upload: true + double_zip: false + + - configurePreset: msbuild-x64 + buildPreset: msbuild-x64-release + executable: "ezquake-amd64.exe" + os: windows-latest + should_upload: false + double_zip: false + + - configurePreset: mingw64-i686-cross + buildPreset: mingw64-i686-cross-release + packages: "binutils-mingw-w64-i686 gcc-mingw-w64-i686 g++-mingw-w64-i686" + executable: "ezquake-i686.exe" + os: ubuntu-latest + should_upload: true + double_zip: false + + - configurePreset: mingw64-x64-cross + buildPreset: mingw64-x64-cross-release + packages: "binutils-mingw-w64-x86-64 gcc-mingw-w64-x86-64 g++-mingw-w64-x86-64" + executable: "ezquake-x86_64.exe" + os: ubuntu-latest + should_upload: true + double_zip: false + + - configurePreset: dynamic + buildPreset: dynamic-release + packages: "libcurl4-openssl-dev libexpat1-dev libfreetype-dev libjpeg-dev libjansson-dev libminizip-dev libpcre2-dev libpng-dev libsdl2-dev libsndfile1-dev libspeex-dev libspeexdsp-dev zlib1g-dev" + executable: "ezquake-linux-x86_64" + os: ubuntu-latest + should_upload: false + double_zip: true + + - configurePreset: static + buildPreset: static-release + packages: "autoconf automake libtool libxinerama-dev libxcursor-dev xorg-dev libwayland-dev libxkbcommon-dev libegl1-mesa-dev" + executable: "ezquake-linux-x86_64" + os: ubuntu-latest + should_upload: true + double_zip: true + cflags: "-march=nehalem" + + - configurePreset: macos-arm64-release-ci + buildPreset: macos-arm64-release-ci + packages: "autoconf automake libtool" + executable: "build-macos-arm64-release-ci/Release/ezQuake.app" + os: macos-latest + should_upload: true + double_zip: true + + - configurePreset: macos-x64-release-ci + buildPreset: macos-x64-release-ci + packages: "autoconf automake libtool" + executable: "build-macos-x64-release-ci/Release/ezQuake.app" + os: macos-latest + should_upload: true + double_zip: true + + name: ${{ matrix.configurePreset }} + runs-on: ${{ matrix.os }} + timeout-minutes: 60 + + outputs: + version: ${{ steps.version.outputs.sha }} + + steps: + - name: Check out code + uses: actions/checkout@v4 + with: + submodules: true + fetch-depth: 0 + + - name: Fetch upstream tags for version metadata + run: | + git remote add upstream https://github.com/QW-Group/ezquake-source.git + git fetch --tags --no-recurse-submodules upstream + if: github.repository != 'QW-Group/ezquake-source' + + - name: Install Linux build dependencies + run: | + sudo dpkg --add-architecture i386 + sudo apt-get update -qq + sudo apt-get install -qq ${{ matrix.packages }} + if: matrix.os == 'ubuntu-latest' + + - name: Install macOS build dependencies + run: brew install ${{ matrix.packages }} + if: matrix.os == 'macos-latest' + + - uses: lukka/get-cmake@latest + + - name: Setup vcpkg + uses: lukka/run-vcpkg@v11 + + - name: Run CMake + uses: lukka/run-cmake@v10 + with: + configurePreset: ${{ matrix.configurePreset }} + buildPreset: ${{ matrix.buildPreset }} + env: + CFLAGS: ${{ matrix.cflags }} + + - name: Pre-zip to preserve executable bit + run: zip -r -9 ezQuake.zip ${{ matrix.executable }} + if: ${{ matrix.should_upload && matrix.double_zip }} + + - name: Collect version + id: version + run: echo "sha=$(git rev-parse --short HEAD)" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append + shell: pwsh + + - name: Upload Build Artifact + uses: actions/upload-artifact@v4 + with: + name: ezQuake-${{ matrix.buildPreset }}-${{ steps.version.outputs.sha }} + path: ezQuake.zip + compression-level: 9 + if: ${{ matrix.should_upload && matrix.double_zip }} + + - name: Upload Build Artifact + uses: actions/upload-artifact@v4 + with: + name: ezQuake-${{ matrix.configurePreset }}-${{ steps.version.outputs.sha }} + path: ${{ matrix.executable }} + compression-level: 9 + if: ${{ matrix.should_upload && !matrix.double_zip }} + + macos-universal: + needs: build + runs-on: macos-latest + steps: + - name: Check out code + uses: actions/checkout@v4 + + - name: Download Intel Build + uses: actions/download-artifact@v4 + with: + name: ezQuake-macos-arm64-release-ci-${{ needs.build.outputs.version }} + path: artifacts/arm64 + + - name: Download ARM64 Build + uses: actions/download-artifact@v4 + with: + name: ezQuake-macos-x64-release-ci-${{ needs.build.outputs.version }} + path: artifacts/x64 + + - uses: geekyeggo/delete-artifact@v5 + with: + name: | + ezQuake-macos-arm64-release-ci-${{ needs.build.outputs.version }} + ezQuake-macos-x64-release-ci-${{ needs.build.outputs.version }} + + - name: Create Universal Binary + run: | + (cd artifacts/x64 && unzip -qq ezQuake.zip) && (cd artifacts/arm64 && unzip -qq ezQuake.zip) + cp -r artifacts/arm64/build-macos-arm64-release-ci/Release/ezQuake.app . + lipo -create -output ezQuake.app/Contents/MacOS/ezQuake \ + artifacts/x64/build-macos-x64-release-ci/Release/ezQuake.app/Contents/MacOS/ezQuake \ + artifacts/arm64/build-macos-arm64-release-ci/Release/ezQuake.app/Contents/MacOS/ezQuake + codesign --force --sign - --entitlements misc/install/ezquake.entitlements.plist --options runtime --timestamp ezQuake.app + zip -r ezQuake.zip ezQuake.app + + - name: Upload Build Artifact + uses: actions/upload-artifact@v4 + with: + name: ezQuake-macOS-${{ needs.build.outputs.version }} + path: ezQuake.zip + compression-level: 9