build.yml 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  1. name: Kernel Build Process
  2. permissions:
  3. contents: write
  4. actions: write
  5. on:
  6. workflow_call:
  7. inputs:
  8. kernel_version:
  9. required: true
  10. type: string
  11. variant:
  12. required: false
  13. type: string
  14. ksu_commit:
  15. required: false
  16. type: string
  17. anykernel_commit:
  18. required: false
  19. type: string
  20. patches_commit:
  21. required: false
  22. type: string
  23. susfs_commit:
  24. required: false
  25. type: string
  26. feature_set:
  27. required: true
  28. type: string
  29. jobs:
  30. build-gki:
  31. name: "${{ inputs.kernel_version }} (${{ matrix.variant }})"
  32. strategy:
  33. fail-fast: false
  34. matrix:
  35. variant: ${{ (inputs.variant == 'All' && 'Normal,Bypass,Wild' || inputs.variant) .split(',') }}
  36. runs-on: ubuntu-latest
  37. timeout-minutes: 60
  38. steps:
  39. - name: Checkout Repository
  40. uses: actions/checkout@v5
  41. - name: Parse kernel version
  42. id: parse
  43. uses: ./.github/actions/parse-kernel-version
  44. with:
  45. kernel_version: ${{ inputs.kernel_version }}
  46. - name: Free Disk Space
  47. if: true
  48. uses: endersonmenezes/free-disk-space@v3 # Use @main for latest, @v3 for stable
  49. with:
  50. remove_android: true
  51. remove_dotnet: true
  52. remove_haskell: true
  53. remove_tool_cache: true
  54. remove_packages: "azure-cli google-cloud-cli microsoft-edge-stable google-chrome-stable firefox postgresql* temurin-* *llvm* mysql* dotnet-sdk-*"
  55. remove_packages_one_command: true
  56. 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"
  57. rm_cmd: "rmz" # Use 'rmz' for faster deletion (default: 'rm')
  58. rmz_version: "3.1.1" # Required when rm_cmd is 'rmz'
  59. testing: false
  60. - name: Setup more Swap (for LTO)
  61. uses: thejerrybao/setup-swap-space@v1 # or pierotofy/set-swap-space
  62. with:
  63. swap-size-gb: 25 # 10-24 GB is common for heavy LTO
  64. # swap-space-path: /mnt/swapfile # optional
  65. - name: Setup Build Environment
  66. uses: ./.github/actions/setup-build-environment
  67. env:
  68. BOOT_SIGN_KEY: ${{ secrets.BOOT_SIGN_KEY }}
  69. with:
  70. patches_commit: ${{ inputs.patches_commit }}
  71. anykernel_commit: ${{ inputs.anykernel_commit }}
  72. - name: Download Kernel Repository
  73. uses: ./.github/actions/download-kernel
  74. with:
  75. android_version: ${{ steps.parse.outputs.android_version }}
  76. kernel_version: ${{ steps.parse.outputs.kernel_version }}
  77. os_patch_level: ${{ steps.parse.outputs.os_patch_level }}
  78. - name: Extract Sublevel and Set File Name
  79. id: extract
  80. uses: ./.github/actions/extract-sublevel-file-name
  81. with:
  82. variant: ${{ matrix.variant }}
  83. - name: Kernel Fixes
  84. uses: ./.github/actions/kernel-fixes
  85. with:
  86. android_version: ${{ steps.parse.outputs.android_version }}
  87. kernel_version: ${{ steps.parse.outputs.kernel_version }}
  88. sublevel: ${{ steps.extract.outputs.sublevel }}
  89. os_patch_level: ${{ steps.parse.outputs.os_patch_level }}
  90. - name: Setup KernelSU-Next
  91. if: contains(inputs.feature_set, 'KSUN') || inputs.feature_set == 'all'
  92. uses: ./.github/actions/kernelsu
  93. with:
  94. ksu_commit: ${{ inputs.ksu_commit }}
  95. - name: SUSFS
  96. if: contains(inputs.feature_set, 'SUSFS') || inputs.feature_set == 'all'
  97. uses: ./.github/actions/susfs
  98. with:
  99. android_version: ${{ steps.parse.outputs.android_version }}
  100. kernel_version: ${{ steps.parse.outputs.kernel_version }}
  101. os_patch_level: ${{ steps.parse.outputs.os_patch_level }}
  102. sublevel: ${{ steps.extract.outputs.sublevel }}
  103. susfs_commit: ${{ inputs.susfs_commit }}
  104. - name: Baseband Guard
  105. if: contains(inputs.feature_set, 'BBG') || inputs.feature_set == 'all'
  106. uses: ./.github/actions/bbg
  107. - name: Setup Networking
  108. if: contains(inputs.feature_set, 'NET') || inputs.feature_set == 'all'
  109. uses: ./.github/actions/networking
  110. with:
  111. kernel_version: ${{ steps.parse.outputs.kernel_version }}
  112. android_version: ${{ steps.parse.outputs.android_version }}
  113. - name: Apply Module Check Bypass
  114. if: ${{ matrix.variant == 'Bypass' }}
  115. uses: ./.github/actions/module-check-bypass
  116. with:
  117. kernel_version: ${{ steps.parse.outputs.kernel_version }}
  118. - name: Apply Device-Specific Patches
  119. uses: ./.github/actions/apply-device-patches
  120. with:
  121. kernel_version: ${{ steps.parse.outputs.kernel_version }}
  122. - name: Setup Networking Configs
  123. uses: ./.github/actions/networking
  124. with:
  125. kernel_version: ${{ steps.parse.outputs.kernel_version }}
  126. android_version: ${{ steps.parse.outputs.android_version }}
  127. - name: Setup Misc Configs
  128. uses: ./.github/actions/misc
  129. with:
  130. kernel_version: ${{ steps.parse.outputs.kernel_version }}
  131. android_version: ${{ steps.parse.outputs.android_version }}
  132. - name: Apply ABI Compare Bypass
  133. if: false
  134. working-directory: ${{ github.workspace }}/kernel
  135. run: |
  136. # ABI compare bypass per kernel/android version
  137. # Edit each block as needed per version
  138. if [[ "$ANDROID_VERSION" == "android12" && "$KERNEL_VERSION" == "5.10" ]]; then
  139. sed -i 's/^\s*exit 1$/ echo "Who Cares? Bypassing Now!"/' build/abi/compare_to_symbol_list
  140. elif [[ "$ANDROID_VERSION" == "android13" && "$KERNEL_VERSION" == "5.10" ]]; then
  141. sed -i 's/^\s*exit 1$/ echo "Who Cares? Bypassing Now!"/' build/kernel/abi/compare_to_symbol_list
  142. elif [[ "$ANDROID_VERSION" == "android13" && "$KERNEL_VERSION" == "5.15" ]]; then
  143. sed -i 's/^\s*exit 1$/ echo "Who Cares? Bypassing Now!"/' build/kernel/abi/compare_to_symbol_list
  144. elif [[ "$ANDROID_VERSION" == "android14" && "$KERNEL_VERSION" == "5.15" ]]; then
  145. 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
  146. elif [[ "$ANDROID_VERSION" == "android14" && "$KERNEL_VERSION" == "6.1" ]]; then
  147. 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
  148. elif [[ "$ANDROID_VERSION" == "android15" && "$KERNEL_VERSION" == "6.6" ]]; then
  149. 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
  150. fi
  151. - name: Apply Kernel Branding
  152. uses: ./.github/actions/apply-kernel-branding
  153. with:
  154. variant: ${{ matrix.variant }}
  155. kernel_version: ${{ steps.parse.outputs.kernel_version }}
  156. android_version: ${{ steps.parse.outputs.android_version }}
  157. sublevel: ${{ steps.extract.outputs.sublevel }}
  158. - name: Remove Protected Exports
  159. uses: ./.github/actions/remove-protected-exports
  160. - name: Clean Kernel Flags
  161. uses: ./.github/actions/clean-kernel-flags
  162. - name: Scan and collect patch rejects
  163. id: scan
  164. if: ${{ always() && matrix.variant == 'Normal' }}
  165. uses: ./.github/actions/scan-patch-rejects
  166. - name: Upload Rejects
  167. if: ${{ always() && matrix.variant == 'Normal' }}
  168. uses: actions/upload-artifact@v7
  169. with:
  170. name: ${{ steps.extract.outputs.file_name }}-Rejects
  171. path: patch-rejects/
  172. if-no-files-found: ignore
  173. compression-level: 9
  174. - name: Build Kernel
  175. env:
  176. SOURCE_DATE_EPOCH: ${{ env.SOURCE_DATE_EPOCH }}
  177. KBUILD_BUILD_TIMESTAMP: ${{ env.KBUILD_BUILD_TIMESTAMP }}
  178. uses: ./.github/actions/build-kernel
  179. - name: Create Bootimgs Folder and Build Boot Images
  180. uses: ./.github/actions/build-boot-images
  181. - name: Upload Boot Image (boot.img)
  182. uses: actions/upload-artifact@v7
  183. with:
  184. path: ${{ github.workspace }}/boot-artifacts/${{ steps.extract.outputs.file_name }}-boot.img
  185. if-no-files-found: error
  186. archive: false
  187. - name: Upload Boot Image (boot-gz.img)
  188. uses: actions/upload-artifact@v7
  189. with:
  190. path: ${{ github.workspace }}/boot-artifacts/${{ steps.extract.outputs.file_name }}-boot-gz.img
  191. if-no-files-found: error
  192. archive: false
  193. - name: Upload Boot Image (boot-lz4.img)
  194. uses: actions/upload-artifact@v7
  195. with:
  196. path: ${{ github.workspace }}/boot-artifacts/${{ steps.extract.outputs.file_name }}-boot-lz4.img
  197. if-no-files-found: error
  198. archive: false
  199. - name: Prepare AnyKernel3 Zip
  200. uses: ./.github/actions/prepare-anykernel3
  201. - name: Upload Artifacts
  202. uses: actions/upload-artifact@v7
  203. with:
  204. name: ${{ steps.extract.outputs.file_name }}-AnyKernel3
  205. path: ${{ github.workspace }}/AnyKernel3/**
  206. if-no-files-found: ignore
  207. compression-level: 9