build.yml 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  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: ['Normal', 'Bypass', 'Wild']
  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')
  92. uses: ./.github/actions/kernelsu
  93. with:
  94. ksu_commit: ${{ inputs.ksu_commit }}
  95. - name: Setup SUSFS
  96. if: contains(inputs.feature_set, 'SUSFS')
  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: Setup Baseband Guard
  105. if: contains(inputs.feature_set, 'BBG')
  106. uses: ./.github/actions/bbg
  107. - name: Apply Module Check Bypass
  108. if: ${{ matrix.variant == 'Bypass' }}
  109. uses: ./.github/actions/module-check-bypass
  110. with:
  111. kernel_version: ${{ steps.parse.outputs.kernel_version }}
  112. - name: Apply Device-Specific Patches
  113. uses: ./.github/actions/apply-device-patches
  114. with:
  115. kernel_version: ${{ steps.parse.outputs.kernel_version }}
  116. - name: Setup Networking Configs
  117. uses: ./.github/actions/networking
  118. with:
  119. kernel_version: ${{ steps.parse.outputs.kernel_version }}
  120. android_version: ${{ steps.parse.outputs.android_version }}
  121. - name: Setup Misc Configs
  122. uses: ./.github/actions/misc
  123. with:
  124. kernel_version: ${{ steps.parse.outputs.kernel_version }}
  125. android_version: ${{ steps.parse.outputs.android_version }}
  126. - name: Apply ABI Compare Bypass
  127. if: false
  128. working-directory: ${{ github.workspace }}/kernel
  129. run: |
  130. # ABI compare bypass per kernel/android version
  131. # Edit each block as needed per version
  132. if [[ "$ANDROID_VERSION" == "android12" && "$KERNEL_VERSION" == "5.10" ]]; then
  133. sed -i 's/^\s*exit 1$/ echo "Who Cares? Bypassing Now!"/' build/abi/compare_to_symbol_list
  134. elif [[ "$ANDROID_VERSION" == "android13" && "$KERNEL_VERSION" == "5.10" ]]; then
  135. sed -i 's/^\s*exit 1$/ echo "Who Cares? Bypassing Now!"/' build/kernel/abi/compare_to_symbol_list
  136. elif [[ "$ANDROID_VERSION" == "android13" && "$KERNEL_VERSION" == "5.15" ]]; then
  137. sed -i 's/^\s*exit 1$/ echo "Who Cares? Bypassing Now!"/' build/kernel/abi/compare_to_symbol_list
  138. elif [[ "$ANDROID_VERSION" == "android14" && "$KERNEL_VERSION" == "5.15" ]]; then
  139. 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
  140. elif [[ "$ANDROID_VERSION" == "android14" && "$KERNEL_VERSION" == "6.1" ]]; 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" == "android15" && "$KERNEL_VERSION" == "6.6" ]]; 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. fi
  145. - name: Apply Kernel Branding
  146. uses: ./.github/actions/apply-kernel-branding
  147. with:
  148. variant: ${{ matrix.variant }}
  149. kernel_version: ${{ steps.parse.outputs.kernel_version }}
  150. android_version: ${{ steps.parse.outputs.android_version }}
  151. - name: Remove Protected Exports
  152. uses: ./.github/actions/remove-protected-exports
  153. - name: Clean Kernel Flags
  154. uses: ./.github/actions/clean-kernel-flags
  155. - name: Scan and collect patch rejects
  156. id: scan
  157. if: ${{ always() }}
  158. uses: ./.github/actions/scan-patch-rejects
  159. - name: Upload Rejects
  160. if: ${{ always() }}
  161. uses: actions/upload-artifact@v7
  162. with:
  163. name: ${{ steps.extract.outputs.file_name }}-Rejects
  164. path: patch-rejects/
  165. if-no-files-found: ignore
  166. compression-level: 9
  167. - name: Build Kernel
  168. env:
  169. SOURCE_DATE_EPOCH: ${{ env.SOURCE_DATE_EPOCH }}
  170. KBUILD_BUILD_TIMESTAMP: ${{ env.KBUILD_BUILD_TIMESTAMP }}
  171. uses: ./.github/actions/build-kernel
  172. - name: Create Bootimgs Folder and Build Boot Images
  173. uses: ./.github/actions/build-boot-images
  174. - name: Upload Boot Image (boot.img)
  175. uses: actions/upload-artifact@v7
  176. with:
  177. path: ${{ github.workspace }}/boot-artifacts/${{ steps.extract.outputs.file_name }}-boot.img
  178. if-no-files-found: error
  179. archive: false
  180. - name: Upload Boot Image (boot-gz.img)
  181. uses: actions/upload-artifact@v7
  182. with:
  183. path: ${{ github.workspace }}/boot-artifacts/${{ steps.extract.outputs.file_name }}-boot-gz.img
  184. if-no-files-found: error
  185. archive: false
  186. - name: Upload Boot Image (boot-lz4.img)
  187. uses: actions/upload-artifact@v7
  188. with:
  189. path: ${{ github.workspace }}/boot-artifacts/${{ steps.extract.outputs.file_name }}-boot-lz4.img
  190. if-no-files-found: error
  191. archive: false
  192. - name: Prepare AnyKernel3 Zip
  193. uses: ./.github/actions/prepare-anykernel3
  194. - name: Upload Artifacts
  195. uses: actions/upload-artifact@v7
  196. with:
  197. name: ${{ steps.extract.outputs.file_name }}-AnyKernel3
  198. path: ${{ github.workspace }}/AnyKernel3/**
  199. if-no-files-found: ignore
  200. compression-level: 9