From 712c3f1f47878a1e42e060a291619f09c86cbd0f Mon Sep 17 00:00:00 2001 From: JuiceyDev Date: Tue, 10 Mar 2026 10:41:56 +0100 Subject: [PATCH] better ci --- .github/workflows/build-linux.yml | 256 ------------------------------ .github/workflows/ci.yml | 201 ++++++++++++++++++++--- 2 files changed, 180 insertions(+), 277 deletions(-) delete mode 100644 .github/workflows/build-linux.yml diff --git a/.github/workflows/build-linux.yml b/.github/workflows/build-linux.yml deleted file mode 100644 index 8b56d1895..000000000 --- a/.github/workflows/build-linux.yml +++ /dev/null @@ -1,256 +0,0 @@ -name: Build Linux Release -# document this later, while that, put both release & debug in parallel -# debug still always comes second and that's sad. -on: - push: - paths: - - '**.cpp' - - '**.h' - - '**.c' - - '**/meson.build' - - 'meson.build' - - '**/CMakeLists.txt' - - 'CMakeLists.txt' - - '.github/workflows/build-linux.yml' - pull_request: - paths: - - '**.cpp' - - '**.h' - - '**.c' - - '**/meson.build' - - 'meson.build' - - '**/CMakeLists.txt' - - 'CMakeLists.txt' - - '.github/workflows/build-linux.yml' - -jobs: - build-release: - runs-on: ubuntu-latest - concurrency: - group: build-linux-release-${{ github.ref }} - cancel-in-progress: true - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Install system dependencies - run: | - sudo apt-get update - sudo apt-get install -y build-essential python3 python3-pip python3-setuptools libgl1-mesa-dev libglu1-mesa-dev libglfw3-dev libpng-dev pkg-config clang lld ccache libssl-dev patchelf - ccache -M 5G || true - - - name: Setup Python - uses: actions/setup-python@v4 - with: - python-version: '3.x' - - - name: Cache pip packages - uses: actions/cache@v4 - with: - path: ~/.cache/pip - key: ${{ runner.os }}-pip-${{ hashFiles('.github/workflows/build-linux.yml') }} - - - name: Install Meson and Ninja - run: | - python -m pip install --upgrade pip - pip install meson ninja - - - name: Restore ccache - uses: actions/cache@v4 - with: - path: ~/.ccache - key: ${{ runner.os }}-ccache-release-${{ hashFiles('**/meson.build') }} - - - name: Restore meson cache - uses: actions/cache@v4 - with: - path: ~/.cache/meson - key: ${{ runner.os }}-meson-${{ hashFiles('**/meson.build') }} - - - name: Configure Meson - env: - CC: "ccache clang" - CXX: "ccache clang++" - CCACHE_DIR: ${{ runner.temp }}/ccache - run: | - mkdir -p "$CCACHE_DIR" - meson setup build_meson --wipe --buildtype=release - - - name: Build with Ninja - env: - CC: "ccache clang" - CXX: "ccache clang++" - CCACHE_DIR: ${{ runner.temp }}/ccache - run: | - export CCACHE_DIR="${{ runner.temp }}/ccache" - ninja -C build_meson -j$(nproc) -v - - - name: Bundle executable + libraries - env: - GITHUB_SHA: ${{ github.sha }} - run: | - set -euo pipefail - EXE_PATH=build_meson/Minecraft.Client/Minecraft.Client - if [ ! -f "$EXE_PATH" ]; then - echo "ERROR: expected executable at $EXE_PATH" >&2 - ls -la build_meson || true - exit 1 - fi - - SHORT_SHA=$(echo "$GITHUB_SHA" | cut -c1-8) - BUNDLE=out/minecraft-client-linux-${SHORT_SHA} - mkdir -p "$BUNDLE/lib" - - cp "$EXE_PATH" "$BUNDLE/Minecraft.Client" - - ldd "$EXE_PATH" \ - | awk '/=>/ { print $3 }' \ - | grep -v '^(' \ - | grep -Ev '/(libc|libm|libdl|libpthread|librt|libgcc_s|libstdc\+\+|ld-linux)[^/]*\.so' \ - | sort -u \ - | while read -r lib; do - [ -f "$lib" ] && cp "$lib" "$BUNDLE/lib/" || true - done - - patchelf --set-rpath '$ORIGIN/lib' "$BUNDLE/Minecraft.Client" - - cat > "$BUNDLE/run.sh" << 'RUNEOF' - #!/usr/bin/env bash - DIR="$(cd "$(dirname "$0")" && pwd)" - if [ ! -d "$DIR/Common" ]; then - echo "ERROR: Missing 'Common' assets folder." - echo "Download LCEWindows64.zip from:" - echo " https://github.com/smartcmd/MinecraftConsoles/releases/tag/nightly" - echo "Extract it and copy the 'Common' folder next to this run.sh file." - exit 1 - fi - cd "$DIR" - exec ./Minecraft.Client "$@" - RUNEOF - chmod +x "$BUNDLE/run.sh" - - cat > "$BUNDLE/README.txt" << 'EOF' - 4JCraft Linux Build - =================== - This bundle contains: - Minecraft.Client - compiled Linux binary - lib/ - all required shared libraries (GL, GLFW, png, zlib, X11 etc.) - run.sh - launcher script - - To run: - 1. Download LCEWindows64.zip from the MinecraftConsoles nightly release: - https://github.com/smartcmd/MinecraftConsoles/releases/tag/nightly - 2. Extract it and copy the "Common" folder into this directory - (so you have Common/ sitting next to run.sh) - 3. Run: ./run.sh [--width W] [--height H] [--fullscreen] - EOF - - echo "Bundle ready: $BUNDLE" - ls -lh "$BUNDLE" "$BUNDLE/lib" - - - name: Upload artifact - uses: actions/upload-artifact@v4 - with: - name: minecraft-client-linux-${{ github.sha }} - path: out/minecraft-client-linux-*/ - retention-days: 7 - - build-debug: - runs-on: ubuntu-latest - concurrency: - group: build-linux-debug-${{ github.ref }} - cancel-in-progress: true - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Install system dependencies - run: | - sudo apt-get update - sudo apt-get install -y build-essential python3 python3-pip python3-setuptools libgl1-mesa-dev libglu1-mesa-dev libglfw3-dev libpng-dev pkg-config clang lld ccache libssl-dev patchelf - ccache -M 5G || true - - - name: Setup Python - uses: actions/setup-python@v4 - with: - python-version: '3.x' - - - name: Cache pip packages - uses: actions/cache@v4 - with: - path: ~/.cache/pip - key: ${{ runner.os }}-pip-${{ hashFiles('.github/workflows/build-linux.yml') }} - - - name: Install Meson and Ninja - run: | - python -m pip install --upgrade pip - pip install meson ninja - - - name: Restore ccache - uses: actions/cache@v4 - with: - path: ~/.ccache - key: ${{ runner.os }}-ccache-debug-${{ hashFiles('**/meson.build') }} - - - name: Restore meson cache - uses: actions/cache@v4 - with: - path: ~/.cache/meson - key: ${{ runner.os }}-meson-${{ hashFiles('**/meson.build') }} - - - name: Configure Meson - env: - CC: "ccache clang" - CXX: "ccache clang++" - CCACHE_DIR: ${{ runner.temp }}/ccache - run: | - mkdir -p "$CCACHE_DIR" - meson setup build_debug --wipe --buildtype=debug - - - name: Build with Ninja - env: - CC: "ccache clang" - CXX: "ccache clang++" - CCACHE_DIR: ${{ runner.temp }}/ccache - run: | - export CCACHE_DIR="${{ runner.temp }}/ccache" - ninja -C build_debug -j$(nproc) -v - - - name: Bundle debug executable + libraries - env: - GITHUB_SHA: ${{ github.sha }} - run: | - set -euo pipefail - EXE_PATH=build_debug/Minecraft.Client/Minecraft.Client - if [ ! -f "$EXE_PATH" ]; then - echo "ERROR: expected debug executable at $EXE_PATH" >&2 - ls -la build_debug || true - exit 1 - fi - - SHORT_SHA=$(echo "$GITHUB_SHA" | cut -c1-8) - BUNDLE=out/minecraft-client-linux-${SHORT_SHA}-debug - mkdir -p "$BUNDLE/lib" - - cp "$EXE_PATH" "$BUNDLE/Minecraft.Client.debug" - - ldd "$EXE_PATH" \ - | awk '/=>/ { print $3 }' \ - | grep -v '^(' \ - | grep -Ev '/(libc|libm|libdl|libpthread|librt|libgcc_s|libstdc\+\+|ld-linux)[^/]*\.so' \ - | sort -u \ - | while read -r lib; do - [ -f "$lib" ] && cp "$lib" "$BUNDLE/lib/" || true - done - - patchelf --set-rpath '$ORIGIN/lib' "$BUNDLE/Minecraft.Client.debug" - - echo "Debug bundle ready: $BUNDLE" - ls -lh "$BUNDLE" "$BUNDLE/lib" - - - name: Upload artifact - uses: actions/upload-artifact@v4 - with: - name: minecraft-client-linux-${{ github.sha }}-debug - path: out/minecraft-client-linux-*-debug/ - retention-days: 7 \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bcfa32d7d..acf60e5bb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,49 +1,208 @@ -name: CI Build - +name: CI +# remade the CI now not broken anymore on: push: branches: [ main, master ] + paths: + - '**.cpp' + - '**.h' + - '**.c' + - '**/meson.build' + - 'meson.build' + - '**/CMakeLists.txt' + - 'CMakeLists.txt' + - '.github/workflows/ci.yml' pull_request: branches: [ main, master ] + paths: + - '**.cpp' + - '**.h' + - '**.c' + - '**/meson.build' + - 'meson.build' + - '**/CMakeLists.txt' + - 'CMakeLists.txt' + - '.github/workflows/ci.yml' jobs: - build: + build-release: runs-on: ubuntu-latest + env: + BUILD_DIR: build_meson + BUNDLE_DIR: out/minecraft-client + concurrency: + group: build-linux-release-${{ github.ref }} + cancel-in-progress: true steps: - name: Checkout repository uses: actions/checkout@v4 + - name: Install system dependencies + run: | + sudo apt-get update -qq + sudo apt-get install -y -qq build-essential python3 python3-pip \ + libgl1-mesa-dev libglu1-mesa-dev libsdl2-dev libglfw3-dev libpng-dev \ + zlib1g-dev pkg-config clang lld ccache libssl-dev patchelf > /dev/null + - name: Setup Python - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: '3.x' - - name: Install system dependencies - run: | - sudo apt-get update - sudo apt-get install -y build-essential pkg-config ca-certificates curl git \ - libgl1-mesa-dev libglu1-mesa-dev libglfw3-dev libpng-dev libx11-dev \ - libxrandr-dev libxinerama-dev libxcursor-dev libxi-dev libudev-dev + - name: Install Meson and Ninja + run: pip install meson ninja -q - - name: Install Meson and Ninja (pip) - run: | - python -m pip install --upgrade pip - pip install meson ninja + - name: Restore ccache + uses: actions/cache@v4 + with: + path: ~/.ccache + key: ${{ runner.os }}-ccache-release-${{ hashFiles('**/meson.build') }} - name: Configure Meson run: | - meson setup build_meson --wipe --buildtype=release + mkdir -p ${{ runner.temp }}/ccache + CC="ccache clang" CXX="ccache clang++" CCACHE_DIR="${{ runner.temp }}/ccache" \ + meson setup ${{ env.BUILD_DIR }} --buildtype=release -Dwarning_level=0 > /dev/null - - name: Build with Ninja + - name: Build run: | - ninja -C build_meson -v + CCACHE_DIR="${{ runner.temp }}/ccache" \ + ninja -C ${{ env.BUILD_DIR }} -j$(nproc) > /dev/null - - name: Package build output + - name: Prepare bundle directory + run: mkdir -p ${{ env.BUNDLE_DIR }}/lib + + - name: Copy binary + run: cp ${{ env.BUILD_DIR }}/Minecraft.Client/Minecraft.Client ${{ env.BUNDLE_DIR }}/ + + - name: Copy source assets run: | - tar -czf minecraft-binaries.tar.gz -C build_meson . + cp -r Minecraft.Assets/Common ${{ env.BUNDLE_DIR }}/ + cp -r Minecraft.Assets/Common/music ${{ env.BUNDLE_DIR }}/ + cp -r Minecraft.Assets/DurangoMedia/Sound ${{ env.BUNDLE_DIR }}/ + + - name: Copy built assets + run: | + mkdir -p ${{ env.BUNDLE_DIR }}/Common/Media + cp ${{ env.BUILD_DIR }}/Minecraft.Assets/MediaLinux.arc ${{ env.BUNDLE_DIR }}/Common/Media/ + cp ${{ env.BUILD_DIR }}/Minecraft.Assets/languages.loc ${{ env.BUNDLE_DIR }}/Common/ + + - name: Collect shared libraries + run: | + EXE="${{ env.BUNDLE_DIR }}/Minecraft.Client" + ldd "$EXE" | awk '/=>/ { print $3 }' | grep -v '^(' | \ + grep -Ev '/(libc|libm|libdl|libpthread|librt|libgcc_s|libstdc\+\+|ld-linux)[^/]*\.so' | \ + sort -u | xargs -I{} cp -L {} ${{ env.BUNDLE_DIR }}/lib/ || true + + - name: Fix RPATH + run: patchelf --set-rpath '$ORIGIN/lib' ${{ env.BUNDLE_DIR }}/Minecraft.Client + ## useless but still good + - name: Generate launcher and readme + run: | + cat > ${{ env.BUNDLE_DIR }}/run.sh << 'EOF' + #!/usr/bin/env bash + DIR="$(cd "$(dirname "$0")" && pwd)" + cd "$DIR" + export LD_LIBRARY_PATH="$DIR/lib:$LD_LIBRARY_PATH" + exec ./Minecraft.Client "$@" + EOF + chmod +x ${{ env.BUNDLE_DIR }}/run.sh + + echo -e "4JCraft Linux Build\nRun via ./run.sh" > ${{ env.BUNDLE_DIR }}/README.txt - name: Upload artifact uses: actions/upload-artifact@v4 with: - name: minecraft-binaries - path: minecraft-binaries.tar.gz + name: minecraft-client-linux + path: ${{ env.BUNDLE_DIR }} + retention-days: 7 + + build-debug: + runs-on: ubuntu-latest + env: + BUILD_DIR: build_debug + BUNDLE_DIR: out/minecraft-client-debug + concurrency: + group: build-linux-debug-${{ github.ref }} + cancel-in-progress: true + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Install system dependencies + run: | + sudo apt-get update -qq + sudo apt-get install -y -qq build-essential python3 python3-pip \ + libgl1-mesa-dev libglu1-mesa-dev libsdl2-dev libglfw3-dev libpng-dev \ + zlib1g-dev pkg-config clang lld ccache libssl-dev patchelf > /dev/null + + - name: Setup Python + uses: actions/setup-python@v5 + with: + python-version: '3.x' + + - name: Install Meson and Ninja + run: pip install meson ninja -q + + - name: Restore ccache + uses: actions/cache@v4 + with: + path: ~/.ccache + key: ${{ runner.os }}-ccache-debug-${{ hashFiles('**/meson.build') }} + + - name: Configure Meson + run: | + mkdir -p ${{ runner.temp }}/ccache + CC="ccache clang" CXX="ccache clang++" CCACHE_DIR="${{ runner.temp }}/ccache" \ + meson setup ${{ env.BUILD_DIR }} --buildtype=debug -Dwarning_level=0 > /dev/null + + - name: Build + run: | + CCACHE_DIR="${{ runner.temp }}/ccache" \ + ninja -C ${{ env.BUILD_DIR }} -j$(nproc) > /dev/null + + - name: Prepare bundle directory + run: mkdir -p ${{ env.BUNDLE_DIR }}/lib + + - name: Copy binary + run: cp ${{ env.BUILD_DIR }}/Minecraft.Client/Minecraft.Client ${{ env.BUNDLE_DIR }}/Minecraft.Client.debug + + - name: Copy source assets + run: | + cp -r Minecraft.Assets/Common ${{ env.BUNDLE_DIR }}/ + cp -r Minecraft.Assets/Common/music ${{ env.BUNDLE_DIR }}/ + cp -r Minecraft.Assets/DurangoMedia/Sound ${{ env.BUNDLE_DIR }}/ + + - name: Copy built assets + run: | + mkdir -p ${{ env.BUNDLE_DIR }}/Common/Media + cp ${{ env.BUILD_DIR }}/Minecraft.Assets/MediaLinux.arc ${{ env.BUNDLE_DIR }}/Common/Media/ + cp ${{ env.BUILD_DIR }}/Minecraft.Assets/languages.loc ${{ env.BUNDLE_DIR }}/Common/ + + - name: Collect shared libraries + run: | + EXE="${{ env.BUNDLE_DIR }}/Minecraft.Client.debug" + ldd "$EXE" | awk '/=>/ { print $3 }' | grep -v '^(' | \ + grep -Ev '/(libc|libm|libdl|libpthread|librt|libgcc_s|libstdc\+\+|ld-linux)[^/]*\.so' | \ + sort -u | xargs -I{} cp -L {} ${{ env.BUNDLE_DIR }}/lib/ || true + + - name: Fix RPATH + run: patchelf --set-rpath '$ORIGIN/lib' ${{ env.BUNDLE_DIR }}/Minecraft.Client.debug + + - name: Generate launcher + run: | + cat > ${{ env.BUNDLE_DIR }}/run_debug.sh << 'EOF' + #!/usr/bin/env bash + DIR="$(cd "$(dirname "$0")" && pwd)" + cd "$DIR" + export LD_LIBRARY_PATH="$DIR/lib:$LD_LIBRARY_PATH" + exec ./Minecraft.Client.debug "$@" + EOF + chmod +x ${{ env.BUNDLE_DIR }}/run_debug.sh + + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: minecraft-client-linux-debug + path: ${{ env.BUNDLE_DIR }} + retention-days: 7