build.yml 9.2 KB

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