build.yml 8.6 KB

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