name: Build Custom Kernels permissions: contents: write actions: write on: workflow_call: inputs: ksu_commit: type: string required: false default: '' feature_set: type: string required: false default: 'WKSU+SUSFS+BBG' jobs: build: runs-on: ubuntu-latest strategy: fail-fast: false matrix: kernel_version: - "5.10.226-android12-2024-11" - "6.1.145-android14-2025-09" - "6.1.157-android14-2025-12" - "6.1.128-android14-2025-03" name: "${{ matrix.kernel_version }}" timeout-minutes: 60 steps: - name: Checkout Repository uses: actions/checkout@v4 - name: Parse kernel version id: parse run: | INPUT_VERSION="${{ matrix.kernel_version }}" KERNEL_BASE="${INPUT_VERSION%%-*}" KERNEL_VERSION="${KERNEL_BASE%.*}" SUB_LEVEL="${KERNEL_BASE##*.}" ANDROID_VERSION="${INPUT_VERSION#*-}" ANDROID_VERSION="${ANDROID_VERSION%%-*}" OS_PATCH_LEVEL="${INPUT_VERSION#*-}" OS_PATCH_LEVEL="${OS_PATCH_LEVEL#*-}" echo "ANDROID_VERSION=$ANDROID_VERSION" >> "$GITHUB_ENV" echo "KERNEL_VERSION=$KERNEL_VERSION" >> "$GITHUB_ENV" echo "SUB_LEVEL=$SUB_LEVEL" >> "$GITHUB_ENV" echo "OS_PATCH_LEVEL=$OS_PATCH_LEVEL" >> "$GITHUB_ENV" echo "android_version=$ANDROID_VERSION" >> $GITHUB_OUTPUT echo "kernel_version=$KERNEL_VERSION" >> $GITHUB_OUTPUT echo "sub_level=$SUB_LEVEL" >> $GITHUB_OUTPUT echo "os_patch_level=$OS_PATCH_LEVEL" >> $GITHUB_OUTPUT - name: Free Disk Space if: true uses: endersonmenezes/free-disk-space@v3 with: remove_android: true remove_dotnet: true remove_haskell: true remove_tool_cache: true remove_swap: true remove_packages: "azure-cli google-cloud-cli microsoft-edge-stable google-chrome-stable firefox postgresql* temurin-* *llvm* mysql* dotnet-sdk-*" remove_packages_one_command: true remove_folders: "/usr/share/swift /usr/share/miniconda /usr/share/az* /usr/local/lib/node_modules /usr/local/share/chromium /usr/local/share/powershell /usr/local/julia /usr/local/aws-cli /usr/local/aws-sam-cli /usr/share/gradle" rm_cmd: "rmz" rmz_version: "3.1.1" testing: false - name: Download Build Dependencies uses: actions/download-artifact@v4 with: name: build-dependencies path: . - name: Setup Build Environment run: | mkdir -p "$GITHUB_WORKSPACE/kernel" chmod +x "$GITHUB_WORKSPACE/git-repo/repo" echo "$GITHUB_WORKSPACE/git-repo" >> "$GITHUB_PATH" - name: Download Kernel Repository uses: ./.github/actions/download-kernel with: android_version: ${{ steps.parse.outputs.android_version }} kernel_version: ${{ steps.parse.outputs.kernel_version }} os_patch_level: ${{ steps.parse.outputs.os_patch_level }} - name: Extract Sublevel and Set File Name id: extract run: | SUBLEVEL="$SUB_LEVEL" if [[ -f "$GITHUB_WORKSPACE/kernel/common/Makefile" ]]; then EXTRACTED=$(grep '^SUBLEVEL = ' "$GITHUB_WORKSPACE/kernel/common/Makefile" | awk '{print $3}') [[ -n "$EXTRACTED" ]] && SUBLEVEL="$EXTRACTED" fi FILE_NAME="$KERNEL_VERSION.$SUBLEVEL-$ANDROID_VERSION-$OS_PATCH_LEVEL" echo "SUBLEVEL=$SUBLEVEL" >> $GITHUB_ENV echo "FILE_NAME=$FILE_NAME" >> $GITHUB_ENV echo "file_name=$FILE_NAME" >> $GITHUB_OUTPUT echo "sublevel=$SUBLEVEL" >> $GITHUB_OUTPUT - name: Setup Wild KSU if: contains(inputs.feature_set, 'WKSU') uses: ./.github/actions/wksu - name: Setup SUSFS if: contains(inputs.feature_set, 'SUSFS') uses: ./.github/actions/susfs with: android_version: ${{ steps.parse.outputs.android_version }} kernel_version: ${{ steps.parse.outputs.kernel_version }} os_patch_level: ${{ steps.parse.outputs.os_patch_level }} sublevel: ${{ steps.parse.outputs.sub_level }} - name: Setup Baseband Guard if: contains(inputs.feature_set, 'BBG') uses: ./.github/actions/bbg - name: Apply Device-Specific Patches uses: ./.github/actions/apply-device-patches with: kernel_version: ${{ steps.parse.outputs.kernel_version }} - name: Configure Kernel Options uses: ./.github/actions/configure-kernel - name: Apply ABI Compare Bypass working-directory: ${{ github.workspace }}/kernel run: | if [[ "$ANDROID_VERSION" == "android12" && "$KERNEL_VERSION" == "5.10" ]]; then sed -i 's/^\s*exit 1$/ echo "Who Cares? Bypassing Now!"/' build/abi/compare_to_symbol_list elif [[ "$ANDROID_VERSION" == "android13" && "$KERNEL_VERSION" == "5.10" ]]; then sed -i 's/^\s*exit 1$/ echo "Who Cares? Bypassing Now!"/' build/kernel/abi/compare_to_symbol_list elif [[ "$ANDROID_VERSION" == "android13" && "$KERNEL_VERSION" == "5.15" ]]; then sed -i 's/^\s*exit 1$/ echo "Who Cares? Bypassing Now!"/' build/kernel/abi/compare_to_symbol_list elif [[ "$ANDROID_VERSION" == "android14" && "$KERNEL_VERSION" == "5.15" ]]; then perl -i -pe 's/^(\s*)return 1$/$1print("Who Cares? Bypassing Now!")\n$1return 0/g if /if missing_symbols:/../return 1/' build/kernel/abi/check_buildtime_symbol_protection.py elif [[ "$ANDROID_VERSION" == "android14" && "$KERNEL_VERSION" == "6.1" ]]; then perl -i -pe 's/^(\s*)return 1$/$1print("Who Cares? Bypassing Now!")\n$1return 0/g if /if missing_symbols:/../return 1/' build/kernel/abi/check_buildtime_symbol_protection.py elif [[ "$ANDROID_VERSION" == "android15" && "$KERNEL_VERSION" == "6.6" ]]; then perl -i -pe 's/^(\s*)return 1$/$1print("Who Cares? Bypassing Now!")\n$1return 0/g if /if missing_symbols:/../return 1/' build/kernel/abi/check_buildtime_symbol_protection.py fi - name: Apply Kernel Branding uses: ./.github/actions/apply-kernel-branding with: build_type: 'Custom' kernel_version: ${{ steps.parse.outputs.kernel_version }} - name: Clean Kernel Flags uses: ./.github/actions/clean-kernel-flags - name: Build Kernel working-directory: ${{ github.workspace }}/kernel run: | set -ex if [ -f "build/build.sh" ]; then GKI_DEFCONFIG_FRAGMENT="$GITHUB_WORKSPACE/wild_gki.fragment" LTO=thin BUILD_CONFIG=common/build.config.gki.aarch64 build/build.sh || exit 1 else cp "$GITHUB_WORKSPACE/wild_gki.fragment" common/arch/arm64/configs/wild_gki.fragment if [[ "$ANDROID_VERSION" == "android14" ]]; then tools/bazel build --config=fast --lto=thin --defconfig_fragment=//common:arch/arm64/configs/wild_gki.fragment //common:kernel_aarch64_dist || exit 1 else tools/bazel build --config=fast --lto=none --defconfig_fragment=//common:arch/arm64/configs/wild_gki.fragment //common:kernel_aarch64_dist || exit 1 fi fi - name: Prepare AnyKernel3 Zip run: | if [ -f "$GITHUB_WORKSPACE/kernel/out/$ANDROID_VERSION-$KERNEL_VERSION/dist/Image" ]; then cp "$GITHUB_WORKSPACE/kernel/out/$ANDROID_VERSION-$KERNEL_VERSION/dist/Image" "$GITHUB_WORKSPACE/AnyKernel3/Image" elif [ -f "$GITHUB_WORKSPACE/kernel/bazel-bin/common/kernel_aarch64/Image" ]; then cp "$GITHUB_WORKSPACE/kernel/bazel-bin/common/kernel_aarch64/Image" "$GITHUB_WORKSPACE/AnyKernel3/Image" else echo "Error: Image file not found in any expected location" exit 1 fi - name: Scan and collect patch rejects id: scan if: ${{ always() }} run: | set -e CONFIG_DIR="$GITHUB_WORKSPACE/kernel" REJECTS_DIR="$GITHUB_WORKSPACE/patch-rejects" mkdir -p "$REJECTS_DIR" mapfile -t REJS < <(find "$CONFIG_DIR" -type f -name '*.rej') REJ_COUNT=${#REJS[@]} echo "Found $REJ_COUNT .rej files under $CONFIG_DIR" echo "REJ_COUNT=$REJ_COUNT" >> $GITHUB_ENV echo "rej_count=$REJ_COUNT" >> $GITHUB_OUTPUT if [ "$REJ_COUNT" -gt 0 ]; then for REJ in "${REJS[@]}"; do REL="${REJ#"$CONFIG_DIR"/}" DEST="$REJECTS_DIR/$REL" mkdir -p "$(dirname "$DEST")" cp "$REJ" "$DEST" ORIG="${REJ%.rej}" if [ -f "$ORIG" ]; then ORIG_DEST="$REJECTS_DIR/${REL%.rej}" mkdir -p "$(dirname "$ORIG_DEST")" cp "$ORIG" "$ORIG_DEST" fi echo "$REL" >> "$REJECTS_DIR/index.txt" done fi - name: Upload Artifacts uses: actions/upload-artifact@v4 with: name: ${{ steps.extract.outputs.file_name }}-AnyKernel3 path: ${{ github.workspace }}/AnyKernel3/** if-no-files-found: ignore compression-level: 9 - name: Upload Rejects if: ${{ always() && steps.scan.outputs.rej_count > 0 }} uses: actions/upload-artifact@v4 with: name: ${{ steps.extract.outputs.file_name }}-Rejects path: patch-rejects/ if-no-files-found: ignore compression-level: 9 - name: Build Summary if: ${{ always() }} run: | echo "Android Version : $ANDROID_VERSION" echo "Kernel Version : $KERNEL_VERSION" echo "Sub Level : $SUB_LEVEL" echo "Sub level (Makefile): $SUBLEVEL" echo "Patch Level : $OS_PATCH_LEVEL" echo "Build Type : Custom" echo "Features : ${{ inputs.feature_set || 'None' }}" echo "WKSU Commit : ${{ inputs.ksu_commit || 'canary' }}"