build.yml 9.0 KB

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