custom.yml 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  1. name: Build Custom Kernels
  2. permissions:
  3. contents: write
  4. actions: write
  5. on:
  6. workflow_call:
  7. inputs:
  8. ksu_commit:
  9. type: string
  10. required: false
  11. default: ''
  12. feature_set:
  13. type: string
  14. required: false
  15. default: 'WKSU+SUSFS+BBG'
  16. jobs:
  17. build:
  18. runs-on: ubuntu-latest
  19. strategy:
  20. fail-fast: false
  21. matrix:
  22. kernel_version:
  23. - "5.10.226-android12-2024-11"
  24. - "6.1.145-android14-2025-09"
  25. - "6.1.157-android14-2025-12"
  26. - "6.1.128-android14-2025-03"
  27. name: "${{ matrix.kernel_version }}"
  28. timeout-minutes: 60
  29. steps:
  30. - name: Checkout Repository
  31. uses: actions/checkout@v4
  32. - name: Parse kernel version
  33. id: parse
  34. run: |
  35. INPUT_VERSION="${{ matrix.kernel_version }}"
  36. KERNEL_BASE="${INPUT_VERSION%%-*}"
  37. KERNEL_VERSION="${KERNEL_BASE%.*}"
  38. SUB_LEVEL="${KERNEL_BASE##*.}"
  39. ANDROID_VERSION="${INPUT_VERSION#*-}"
  40. ANDROID_VERSION="${ANDROID_VERSION%%-*}"
  41. OS_PATCH_LEVEL="${INPUT_VERSION#*-}"
  42. OS_PATCH_LEVEL="${OS_PATCH_LEVEL#*-}"
  43. echo "ANDROID_VERSION=$ANDROID_VERSION" >> "$GITHUB_ENV"
  44. echo "KERNEL_VERSION=$KERNEL_VERSION" >> "$GITHUB_ENV"
  45. echo "SUB_LEVEL=$SUB_LEVEL" >> "$GITHUB_ENV"
  46. echo "OS_PATCH_LEVEL=$OS_PATCH_LEVEL" >> "$GITHUB_ENV"
  47. echo "android_version=$ANDROID_VERSION" >> $GITHUB_OUTPUT
  48. echo "kernel_version=$KERNEL_VERSION" >> $GITHUB_OUTPUT
  49. echo "sub_level=$SUB_LEVEL" >> $GITHUB_OUTPUT
  50. echo "os_patch_level=$OS_PATCH_LEVEL" >> $GITHUB_OUTPUT
  51. - name: Free Disk Space
  52. if: true
  53. uses: endersonmenezes/free-disk-space@v3
  54. with:
  55. remove_android: true
  56. remove_dotnet: true
  57. remove_haskell: true
  58. remove_tool_cache: true
  59. remove_swap: true
  60. remove_packages: "azure-cli google-cloud-cli microsoft-edge-stable google-chrome-stable firefox postgresql* temurin-* *llvm* mysql* dotnet-sdk-*"
  61. remove_packages_one_command: true
  62. 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"
  63. rm_cmd: "rmz"
  64. rmz_version: "3.1.1"
  65. testing: false
  66. - name: Download Build Dependencies
  67. uses: actions/download-artifact@v4
  68. with:
  69. name: build-dependencies
  70. path: .
  71. - name: Setup Build Environment
  72. run: |
  73. mkdir -p "$GITHUB_WORKSPACE/kernel"
  74. chmod +x "$GITHUB_WORKSPACE/git-repo/repo"
  75. echo "$GITHUB_WORKSPACE/git-repo" >> "$GITHUB_PATH"
  76. - name: Download Kernel Repository
  77. uses: ./.github/actions/download-kernel
  78. with:
  79. android_version: ${{ steps.parse.outputs.android_version }}
  80. kernel_version: ${{ steps.parse.outputs.kernel_version }}
  81. os_patch_level: ${{ steps.parse.outputs.os_patch_level }}
  82. - name: Extract Sublevel and Set File Name
  83. id: extract
  84. run: |
  85. SUBLEVEL="$SUB_LEVEL"
  86. if [[ -f "$GITHUB_WORKSPACE/kernel/common/Makefile" ]]; then
  87. EXTRACTED=$(grep '^SUBLEVEL = ' "$GITHUB_WORKSPACE/kernel/common/Makefile" | awk '{print $3}')
  88. [[ -n "$EXTRACTED" ]] && SUBLEVEL="$EXTRACTED"
  89. fi
  90. FILE_NAME="$KERNEL_VERSION.$SUBLEVEL-$ANDROID_VERSION-$OS_PATCH_LEVEL"
  91. echo "SUBLEVEL=$SUBLEVEL" >> $GITHUB_ENV
  92. echo "FILE_NAME=$FILE_NAME" >> $GITHUB_ENV
  93. echo "file_name=$FILE_NAME" >> $GITHUB_OUTPUT
  94. echo "sublevel=$SUBLEVEL" >> $GITHUB_OUTPUT
  95. - name: Setup Wild KSU
  96. if: contains(inputs.feature_set, 'WKSU')
  97. uses: ./.github/actions/wksu
  98. - name: Setup SUSFS
  99. if: contains(inputs.feature_set, 'SUSFS')
  100. uses: ./.github/actions/susfs
  101. with:
  102. android_version: ${{ steps.parse.outputs.android_version }}
  103. kernel_version: ${{ steps.parse.outputs.kernel_version }}
  104. os_patch_level: ${{ steps.parse.outputs.os_patch_level }}
  105. sublevel: ${{ steps.parse.outputs.sub_level }}
  106. - name: Setup Baseband Guard
  107. if: contains(inputs.feature_set, 'BBG')
  108. uses: ./.github/actions/bbg
  109. - name: Apply Device-Specific Patches
  110. uses: ./.github/actions/apply-device-patches
  111. with:
  112. kernel_version: ${{ steps.parse.outputs.kernel_version }}
  113. - name: Configure Kernel Options
  114. uses: ./.github/actions/configure-kernel
  115. - name: Apply ABI Compare Bypass
  116. working-directory: ${{ github.workspace }}/kernel
  117. run: |
  118. if [[ "$ANDROID_VERSION" == "android12" && "$KERNEL_VERSION" == "5.10" ]]; then
  119. sed -i 's/^\s*exit 1$/ echo "Who Cares? Bypassing Now!"/' build/abi/compare_to_symbol_list
  120. elif [[ "$ANDROID_VERSION" == "android13" && "$KERNEL_VERSION" == "5.10" ]]; then
  121. sed -i 's/^\s*exit 1$/ echo "Who Cares? Bypassing Now!"/' build/kernel/abi/compare_to_symbol_list
  122. elif [[ "$ANDROID_VERSION" == "android13" && "$KERNEL_VERSION" == "5.15" ]]; then
  123. sed -i 's/^\s*exit 1$/ echo "Who Cares? Bypassing Now!"/' build/kernel/abi/compare_to_symbol_list
  124. elif [[ "$ANDROID_VERSION" == "android14" && "$KERNEL_VERSION" == "5.15" ]]; then
  125. 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
  126. elif [[ "$ANDROID_VERSION" == "android14" && "$KERNEL_VERSION" == "6.1" ]]; then
  127. 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
  128. elif [[ "$ANDROID_VERSION" == "android15" && "$KERNEL_VERSION" == "6.6" ]]; then
  129. 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
  130. fi
  131. - name: Apply Kernel Branding
  132. uses: ./.github/actions/apply-kernel-branding
  133. with:
  134. build_type: 'Custom'
  135. kernel_version: ${{ steps.parse.outputs.kernel_version }}
  136. - name: Clean Kernel Flags
  137. uses: ./.github/actions/clean-kernel-flags
  138. - name: Build Kernel
  139. working-directory: ${{ github.workspace }}/kernel
  140. run: |
  141. set -ex
  142. if [ -f "build/build.sh" ]; then
  143. GKI_DEFCONFIG_FRAGMENT="$GITHUB_WORKSPACE/wild_gki.fragment" LTO=thin BUILD_CONFIG=common/build.config.gki.aarch64 build/build.sh || exit 1
  144. else
  145. cp "$GITHUB_WORKSPACE/wild_gki.fragment" common/arch/arm64/configs/wild_gki.fragment
  146. if [[ "$ANDROID_VERSION" == "android14" ]]; then
  147. tools/bazel build --config=fast --lto=thin --defconfig_fragment=//common:arch/arm64/configs/wild_gki.fragment //common:kernel_aarch64_dist || exit 1
  148. else
  149. tools/bazel build --config=fast --lto=none --defconfig_fragment=//common:arch/arm64/configs/wild_gki.fragment //common:kernel_aarch64_dist || exit 1
  150. fi
  151. fi
  152. - name: Prepare AnyKernel3 Zip
  153. run: |
  154. if [ -f "$GITHUB_WORKSPACE/kernel/out/$ANDROID_VERSION-$KERNEL_VERSION/dist/Image" ]; then
  155. cp "$GITHUB_WORKSPACE/kernel/out/$ANDROID_VERSION-$KERNEL_VERSION/dist/Image" "$GITHUB_WORKSPACE/AnyKernel3/Image"
  156. elif [ -f "$GITHUB_WORKSPACE/kernel/bazel-bin/common/kernel_aarch64/Image" ]; then
  157. cp "$GITHUB_WORKSPACE/kernel/bazel-bin/common/kernel_aarch64/Image" "$GITHUB_WORKSPACE/AnyKernel3/Image"
  158. else
  159. echo "Error: Image file not found in any expected location"
  160. exit 1
  161. fi
  162. - name: Scan and collect patch rejects
  163. id: scan
  164. if: ${{ always() }}
  165. run: |
  166. set -e
  167. CONFIG_DIR="$GITHUB_WORKSPACE/kernel"
  168. REJECTS_DIR="$GITHUB_WORKSPACE/patch-rejects"
  169. mkdir -p "$REJECTS_DIR"
  170. mapfile -t REJS < <(find "$CONFIG_DIR" -type f -name '*.rej')
  171. REJ_COUNT=${#REJS[@]}
  172. echo "Found $REJ_COUNT .rej files under $CONFIG_DIR"
  173. echo "REJ_COUNT=$REJ_COUNT" >> $GITHUB_ENV
  174. echo "rej_count=$REJ_COUNT" >> $GITHUB_OUTPUT
  175. if [ "$REJ_COUNT" -gt 0 ]; then
  176. for REJ in "${REJS[@]}"; do
  177. REL="${REJ#"$CONFIG_DIR"/}"
  178. DEST="$REJECTS_DIR/$REL"
  179. mkdir -p "$(dirname "$DEST")"
  180. cp "$REJ" "$DEST"
  181. ORIG="${REJ%.rej}"
  182. if [ -f "$ORIG" ]; then
  183. ORIG_DEST="$REJECTS_DIR/${REL%.rej}"
  184. mkdir -p "$(dirname "$ORIG_DEST")"
  185. cp "$ORIG" "$ORIG_DEST"
  186. fi
  187. echo "$REL" >> "$REJECTS_DIR/index.txt"
  188. done
  189. fi
  190. - name: Upload Artifacts
  191. uses: actions/upload-artifact@v4
  192. with:
  193. name: ${{ steps.extract.outputs.file_name }}-AnyKernel3
  194. path: ${{ github.workspace }}/AnyKernel3/**
  195. if-no-files-found: ignore
  196. compression-level: 9
  197. - name: Upload Rejects
  198. if: ${{ always() && steps.scan.outputs.rej_count > 0 }}
  199. uses: actions/upload-artifact@v4
  200. with:
  201. name: ${{ steps.extract.outputs.file_name }}-Rejects
  202. path: patch-rejects/
  203. if-no-files-found: ignore
  204. compression-level: 9
  205. - name: Build Summary
  206. if: ${{ always() }}
  207. run: |
  208. echo "Android Version : $ANDROID_VERSION"
  209. echo "Kernel Version : $KERNEL_VERSION"
  210. echo "Sub Level : $SUB_LEVEL"
  211. echo "Sub level (Makefile): $SUBLEVEL"
  212. echo "Patch Level : $OS_PATCH_LEVEL"
  213. echo "Build Type : Custom"
  214. echo "Features : ${{ inputs.feature_set || 'None' }}"
  215. echo "WKSU Commit : ${{ inputs.ksu_commit || 'canary' }}"