build.yml 8.9 KB

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