build.yml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  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. feature_set:
  15. required: true
  16. type: string
  17. use_repo:
  18. required: false
  19. type: boolean
  20. jobs:
  21. build-gki:
  22. name: "${{ inputs.kernel_version }} (${{ inputs.variant }})"
  23. runs-on: ubuntu-latest
  24. timeout-minutes: 60
  25. steps:
  26. - name: Checkout Repository
  27. uses: actions/checkout@v5
  28. - name: Parse kernel version
  29. id: parse
  30. uses: ./.github/actions/parse-kernel-version
  31. with:
  32. kernel_version: ${{ inputs.kernel_version }}
  33. - name: Free Disk Space
  34. if: false
  35. uses: endersonmenezes/free-disk-space@v3 # Use @main for latest, @v3 for stable
  36. with:
  37. remove_android: true
  38. remove_dotnet: true
  39. remove_haskell: true
  40. remove_tool_cache: true
  41. #remove_packages: "azure-cli google-cloud-cli microsoft-edge-stable google-chrome-stable firefox postgresql* temurin-* *llvm* mysql* dotnet-sdk-*"
  42. #remove_packages_one_command: true
  43. 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"
  44. rm_cmd: "rmz" # Use 'rmz' for faster deletion (default: 'rm')
  45. rmz_version: "3.1.1" # Required when rm_cmd is 'rmz'
  46. testing: false
  47. - name: Setup more Swap (for LTO)
  48. uses: thejerrybao/setup-swap-space@v1 # or pierotofy/set-swap-space
  49. with:
  50. swap-size-gb: 10 # 10-24 GB is common for heavy LTO
  51. # swap-space-path: /mnt/swapfile # optional
  52. - name: Setup Build Environment
  53. uses: ./.github/actions/setup-build-environment
  54. env:
  55. BOOT_SIGN_KEY: ${{ secrets.BOOT_SIGN_KEY }}
  56. - name: Download Kernel Repository
  57. uses: ./.github/actions/download-kernel
  58. with:
  59. android_version: ${{ steps.parse.outputs.android_version }}
  60. kernel_version: ${{ steps.parse.outputs.kernel_version }}
  61. os_patch_level: ${{ steps.parse.outputs.os_patch_level }}
  62. use_repo: ${{ inputs.use_repo }}
  63. - name: Extract Sublevel and Set File Name
  64. id: extract
  65. uses: ./.github/actions/extract-sublevel-file-name
  66. with:
  67. variant: ${{ inputs.variant }}
  68. - name: Kernel Fixes
  69. uses: ./.github/actions/kernel-fixes
  70. with:
  71. android_version: ${{ steps.parse.outputs.android_version }}
  72. kernel_version: ${{ steps.parse.outputs.kernel_version }}
  73. sublevel: ${{ steps.extract.outputs.sublevel }}
  74. os_patch_level: ${{ steps.parse.outputs.os_patch_level }}
  75. - name: Setup KernelSU-Next
  76. if: contains(inputs.feature_set, 'KSUN') || inputs.feature_set == 'FULL'
  77. uses: ./.github/actions/kernelsu
  78. - name: SUSFS
  79. if: contains(inputs.feature_set, 'SUSFS') || inputs.feature_set == 'FULL'
  80. uses: ./.github/actions/susfs
  81. with:
  82. android_version: ${{ steps.parse.outputs.android_version }}
  83. kernel_version: ${{ steps.parse.outputs.kernel_version }}
  84. os_patch_level: ${{ steps.parse.outputs.os_patch_level }}
  85. sublevel: ${{ steps.extract.outputs.sublevel }}
  86. - name: Baseband Guard
  87. if: contains(inputs.feature_set, 'BBG') || inputs.feature_set == 'FULL'
  88. uses: ./.github/actions/bbg
  89. - name: Setup Networking
  90. if: contains(inputs.feature_set, 'NET') || inputs.feature_set == 'FULL'
  91. uses: ./.github/actions/networking
  92. with:
  93. kernel_version: ${{ steps.parse.outputs.kernel_version }}
  94. android_version: ${{ steps.parse.outputs.android_version }}
  95. - name: DroidSpaces-OSS Patches
  96. if: contains(inputs.feature_set, 'DS') || inputs.feature_set == 'FULL'
  97. uses: ./.github/actions/droidspaces
  98. with:
  99. kernel_version: ${{ steps.parse.outputs.kernel_version }}
  100. - name: Setup Misc Configs
  101. uses: ./.github/actions/misc
  102. with:
  103. kernel_version: ${{ steps.parse.outputs.kernel_version }}
  104. android_version: ${{ steps.parse.outputs.android_version }}
  105. - name: Apply Module Check Bypass
  106. if: ${{ inputs.variant == 'Bypass' }}
  107. uses: ./.github/actions/module-check-bypass
  108. with:
  109. kernel_version: ${{ steps.parse.outputs.kernel_version }}
  110. - name: Apply Device-Specific Patches
  111. uses: ./.github/actions/apply-device-patches
  112. with:
  113. kernel_version: ${{ steps.parse.outputs.kernel_version }}
  114. - name: Apply ABI Compare Bypass
  115. if: false
  116. working-directory: ${{ github.workspace }}/kernel
  117. run: |
  118. # ABI compare bypass per kernel/android version
  119. # Edit each block as needed per version
  120. if [[ "$ANDROID_VERSION" == "android12" && "$KERNEL_VERSION" == "5.10" ]]; then
  121. sed -i 's/^\s*exit 1$/ echo "Who Cares? Bypassing Now!"/' build/abi/compare_to_symbol_list
  122. elif [[ "$ANDROID_VERSION" == "android13" && "$KERNEL_VERSION" == "5.10" ]]; then
  123. sed -i 's/^\s*exit 1$/ echo "Who Cares? Bypassing Now!"/' build/kernel/abi/compare_to_symbol_list
  124. elif [[ "$ANDROID_VERSION" == "android13" && "$KERNEL_VERSION" == "5.15" ]]; then
  125. sed -i 's/^\s*exit 1$/ echo "Who Cares? Bypassing Now!"/' build/kernel/abi/compare_to_symbol_list
  126. elif [[ "$ANDROID_VERSION" == "android14" && "$KERNEL_VERSION" == "5.15" ]]; then
  127. 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
  128. elif [[ "$ANDROID_VERSION" == "android14" && "$KERNEL_VERSION" == "6.1" ]]; then
  129. 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
  130. elif [[ "$ANDROID_VERSION" == "android15" && "$KERNEL_VERSION" == "6.6" ]]; then
  131. 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
  132. fi
  133. - name: Apply Kernel Branding
  134. uses: ./.github/actions/apply-kernel-branding
  135. with:
  136. variant: ${{ inputs.variant }}
  137. kernel_version: ${{ steps.parse.outputs.kernel_version }}
  138. android_version: ${{ steps.parse.outputs.android_version }}
  139. sublevel: ${{ steps.extract.outputs.sublevel }}
  140. - name: Remove Protected Exports
  141. uses: ./.github/actions/remove-protected-exports
  142. - name: Clean Kernel Flags
  143. uses: ./.github/actions/clean-kernel-flags
  144. - name: Scan and collect patch rejects
  145. id: scan
  146. if: ${{ always() && inputs.variant == 'Normal' }}
  147. uses: ./.github/actions/scan-patch-rejects
  148. - name: Upload Rejects
  149. if: ${{ always() && inputs.variant == 'Normal' }}
  150. uses: actions/upload-artifact@v7
  151. with:
  152. name: ${{ steps.extract.outputs.file_name }}-Rejects
  153. path: patch-rejects/
  154. if-no-files-found: ignore
  155. compression-level: 9
  156. - name: 'Setup Cache and Build Environment'
  157. uses: ./.github/actions/cache-setup
  158. with:
  159. android_version: ${{ steps.parse.outputs.android_version }}
  160. kernel_version: ${{ steps.parse.outputs.kernel_version }}
  161. os_patch_level: ${{ steps.parse.outputs.os_patch_level }}
  162. sublevel: ${{ steps.extract.outputs.sublevel }}
  163. - name: Restore build caches (ccache, bazel, bazel-disk, lto)
  164. id: restore-caches
  165. uses: ./.github/actions/cache-restore
  166. with:
  167. cache_paths: |
  168. /home/runner/.ccache
  169. /home/runner/.cache/bazel
  170. /home/runner/.ld_cache
  171. cache_keys: |
  172. buildcache-${{ inputs.kernel_version }}
  173. buildcache-${{ inputs.kernel_version }}
  174. buildcache-${{ inputs.kernel_version }}
  175. cache_buckets: |
  176. ccache-cache
  177. bazel-cache
  178. lto-cache
  179. compression_level: 9
  180. restore_keys: |
  181. buildcache-
  182. - name: Check cache hit
  183. run: |
  184. if [ "${{ steps.restore-caches.outputs.cache-hit }}" = "true" ]; then
  185. echo "✅ Cache HIT"
  186. IFS=',' read -ra KEYS <<< "${{ steps.restore-caches.outputs.cache-key }}"
  187. IFS=',' read -ra SIZES <<< "${{ steps.restore-caches.outputs.cache-size }}"
  188. for i in "${!KEYS[@]}"; do
  189. echo " [${i}] ${KEYS[$i]} (${SIZES[$i]})"
  190. done
  191. else
  192. echo "❌ No caches found - Fresh build"
  193. fi
  194. - name: Get Cache Stats
  195. uses: ./.github/actions/cache-stats
  196. with:
  197. clear_stats: true
  198. - name: Build Kernel
  199. env:
  200. SOURCE_DATE_EPOCH: ${{ env.SOURCE_DATE_EPOCH }}
  201. KBUILD_BUILD_TIMESTAMP: ${{ env.KBUILD_BUILD_TIMESTAMP }}
  202. uses: ./.github/actions/build-kernel
  203. - name: Get Cache Stats
  204. uses: ./.github/actions/cache-stats
  205. with:
  206. clear_stats: false
  207. - name: Save build caches (ccache, bazel, bazel-disk, lto)
  208. uses: ./.github/actions/cache-save
  209. with:
  210. cache_paths: |
  211. /home/runner/.ccache
  212. /home/runner/.cache/bazel
  213. /home/runner/.ld_cache
  214. cache_keys: |
  215. buildcache-${{ inputs.kernel_version }}
  216. buildcache-${{ inputs.kernel_version }}
  217. buildcache-${{ inputs.kernel_version }}
  218. cache_buckets: |
  219. ccache-cache
  220. bazel-cache
  221. lto-cache
  222. compression_level: 9
  223. github_token: ${{ secrets.GITHUB_TOKEN }}
  224. - name: Create Bootimgs Folder and Build Boot Images
  225. uses: ./.github/actions/build-boot-images
  226. - name: Upload Boot Image (boot.img)
  227. uses: actions/upload-artifact@v7
  228. with:
  229. path: ${{ github.workspace }}/boot-artifacts/${{ steps.extract.outputs.file_name }}-boot.img
  230. if-no-files-found: error
  231. archive: false
  232. - name: Upload Boot Image (boot-gz.img)
  233. uses: actions/upload-artifact@v7
  234. with:
  235. path: ${{ github.workspace }}/boot-artifacts/${{ steps.extract.outputs.file_name }}-boot-gz.img
  236. if-no-files-found: error
  237. archive: false
  238. - name: Upload Boot Image (boot-lz4.img)
  239. uses: actions/upload-artifact@v7
  240. with:
  241. path: ${{ github.workspace }}/boot-artifacts/${{ steps.extract.outputs.file_name }}-boot-lz4.img
  242. if-no-files-found: error
  243. archive: false
  244. - name: Prepare AnyKernel3 Zip
  245. uses: ./.github/actions/prepare-anykernel3
  246. - name: Upload Artifacts
  247. uses: actions/upload-artifact@v7
  248. with:
  249. name: ${{ steps.extract.outputs.file_name }}-AnyKernel3
  250. path: ${{ github.workspace }}/AnyKernel3/**
  251. if-no-files-found: ignore
  252. compression-level: 9