build.yml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302
  1. name: Kernel Build Process
  2. permissions:
  3. contents: write
  4. actions: write
  5. on:
  6. workflow_call:
  7. inputs:
  8. android_version:
  9. required: true
  10. type: string
  11. kernel_version:
  12. required: true
  13. type: string
  14. sublevel:
  15. required: true
  16. type: string
  17. os_patch_level:
  18. required: true
  19. type: string
  20. variant:
  21. required: false
  22. type: string
  23. config_variant:
  24. required: false
  25. type: string
  26. feature_set:
  27. required: true
  28. type: string
  29. use_repo:
  30. required: false
  31. type: boolean
  32. jobs:
  33. build-gki:
  34. name: "${{ inputs.android_version }}-${{ inputs.kernel_version }}.${{ inputs.sublevel }}-${{ inputs.os_patch_level }} (${{ inputs.variant }} / ${{ inputs.config_variant || 'base' }})"
  35. runs-on: ubuntu-latest
  36. timeout-minutes: 60
  37. steps:
  38. - name: Checkout Repository
  39. uses: actions/checkout@v5
  40. - name: Free Disk Space
  41. if: false
  42. uses: endersonmenezes/free-disk-space@v3 # Use @main for latest, @v3 for stable
  43. with:
  44. remove_android: true
  45. remove_dotnet: true
  46. remove_haskell: true
  47. remove_tool_cache: true
  48. #remove_packages: "azure-cli google-cloud-cli microsoft-edge-stable google-chrome-stable firefox postgresql* temurin-* *llvm* mysql* dotnet-sdk-*"
  49. #remove_packages_one_command: true
  50. 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"
  51. rm_cmd: "rmz" # Use 'rmz' for faster deletion (default: 'rm')
  52. rmz_version: "3.1.1" # Required when rm_cmd is 'rmz'
  53. testing: false
  54. - name: Setup more Swap (for LTO)
  55. uses: thejerrybao/setup-swap-space@v1 # or pierotofy/set-swap-space
  56. with:
  57. swap-size-gb: 10 # 10-24 GB is common for heavy LTO
  58. # swap-space-path: /mnt/swapfile # optional
  59. - name: Setup Build Environment
  60. uses: ./.github/actions/setup-build-environment
  61. env:
  62. BOOT_SIGN_KEY: ${{ secrets.BOOT_SIGN_KEY }}
  63. - name: Download Kernel Repository
  64. uses: ./.github/actions/download-kernel
  65. with:
  66. android_version: ${{ inputs.android_version }}
  67. kernel_version: ${{ inputs.kernel_version }}
  68. os_patch_level: ${{ inputs.os_patch_level }}
  69. use_repo: ${{ inputs.use_repo }}
  70. - name: Extract Sublevel and Set File Name
  71. id: extract
  72. uses: ./.github/actions/extract-sublevel-file-name
  73. with:
  74. android_version: ${{ inputs.android_version }}
  75. kernel_version: ${{ inputs.kernel_version }}
  76. sublevel: ${{ inputs.sublevel }}
  77. os_patch_level: ${{ inputs.os_patch_level }}
  78. variant: ${{ inputs.variant }}
  79. config_variant: ${{ inputs.config_variant }}
  80. - name: Kernel Fixes
  81. uses: ./.github/actions/kernel-fixes
  82. with:
  83. android_version: ${{ inputs.android_version }}
  84. kernel_version: ${{ inputs.kernel_version }}
  85. sublevel: ${{ steps.extract.outputs.sublevel }}
  86. os_patch_level: ${{ inputs.os_patch_level }}
  87. - name: Setup KernelSU-Next
  88. if: contains(inputs.feature_set, 'KSUN') || inputs.feature_set == 'FULL'
  89. uses: ./.github/actions/kernelsu
  90. - name: SUSFS
  91. if: contains(inputs.feature_set, 'SUSFS') || inputs.feature_set == 'FULL'
  92. uses: ./.github/actions/susfs
  93. with:
  94. android_version: ${{ inputs.android_version }}
  95. kernel_version: ${{ inputs.kernel_version }}
  96. os_patch_level: ${{ inputs.os_patch_level }}
  97. sublevel: ${{ steps.extract.outputs.sublevel }}
  98. - name: Baseband Guard
  99. if: (contains(inputs.feature_set, 'BBG') || inputs.feature_set == 'FULL') && false
  100. uses: ./.github/actions/bbg
  101. - name: Setup Networking
  102. if: contains(inputs.feature_set, 'NET') || inputs.feature_set == 'FULL'
  103. uses: ./.github/actions/networking
  104. with:
  105. kernel_version: ${{ inputs.kernel_version }}
  106. android_version: ${{ inputs.android_version }}
  107. - name: DroidSpaces-OSS Patches
  108. if: contains(inputs.feature_set, 'DS') || inputs.feature_set == 'FULL'
  109. uses: ./.github/actions/droidspaces
  110. with:
  111. kernel_version: ${{ inputs.kernel_version }}
  112. - name: Setup Misc Configs
  113. uses: ./.github/actions/misc
  114. with:
  115. kernel_version: ${{ inputs.kernel_version }}
  116. android_version: ${{ inputs.android_version }}
  117. sublevel: ${{ steps.extract.outputs.sublevel }}
  118. config_variant: ${{ inputs.config_variant }}
  119. - name: Apply Module Check Bypass
  120. if: ${{ inputs.variant == 'Bypass' }}
  121. uses: ./.github/actions/module-check-bypass
  122. with:
  123. kernel_version: ${{ inputs.kernel_version }}
  124. - name: Apply Device-Specific Patches
  125. uses: ./.github/actions/apply-device-patches
  126. with:
  127. kernel_version: ${{ inputs.kernel_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: ${{ inputs.variant }}
  151. kernel_version: ${{ inputs.kernel_version }}
  152. android_version: ${{ inputs.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() && inputs.variant == 'Normal' }}
  161. uses: ./.github/actions/scan-patch-rejects
  162. - name: Upload Rejects
  163. if: ${{ always() && inputs.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: 'Setup Cache and Build Environment'
  171. uses: ./.github/actions/cache-setup
  172. with:
  173. android_version: ${{ steps.parse.outputs.android_version }}
  174. kernel_version: ${{ steps.parse.outputs.kernel_version }}
  175. sublevel: ${{ steps.extract.outputs.sublevel }}
  176. - name: Restore build caches (ccache, bazel, bazel-disk, lto)
  177. id: restore-caches
  178. uses: ./.github/actions/cache-restore
  179. with:
  180. cache_paths: |
  181. /home/runner/.ccache
  182. /home/runner/.cache/bazel
  183. /home/runner/.ld_cache
  184. cache_keys: |
  185. buildcache-${{ inputs.kernel_version }}
  186. buildcache-${{ inputs.kernel_version }}
  187. buildcache-${{ inputs.kernel_version }}
  188. cache_buckets: |
  189. ccache-cache
  190. bazel-cache
  191. lto-cache
  192. compression_level: 9
  193. restore_keys: |
  194. buildcache-
  195. - name: Check cache hit
  196. run: |
  197. if [ "${{ steps.restore-caches.outputs.cache-hit }}" = "true" ]; then
  198. echo "✅ Cache HIT"
  199. IFS=',' read -ra KEYS <<< "${{ steps.restore-caches.outputs.cache-key }}"
  200. IFS=',' read -ra SIZES <<< "${{ steps.restore-caches.outputs.cache-size }}"
  201. for i in "${!KEYS[@]}"; do
  202. echo " [${i}] ${KEYS[$i]} (${SIZES[$i]})"
  203. done
  204. else
  205. echo "❌ No caches found - Fresh build"
  206. fi
  207. - name: Get Cache Stats
  208. uses: ./.github/actions/cache-stats
  209. with:
  210. clear_stats: true
  211. - name: Build Kernel
  212. env:
  213. SOURCE_DATE_EPOCH: ${{ env.SOURCE_DATE_EPOCH }}
  214. KBUILD_BUILD_TIMESTAMP: ${{ env.KBUILD_BUILD_TIMESTAMP }}
  215. uses: ./.github/actions/build-kernel
  216. - name: Get Cache Stats
  217. uses: ./.github/actions/cache-stats
  218. with:
  219. clear_stats: false
  220. - name: Save build caches (ccache, bazel, bazel-disk, lto)
  221. uses: ./.github/actions/cache-save
  222. with:
  223. cache_paths: |
  224. /home/runner/.ccache
  225. /home/runner/.cache/bazel
  226. /home/runner/.ld_cache
  227. cache_keys: |
  228. buildcache-${{ inputs.kernel_version }}
  229. buildcache-${{ inputs.kernel_version }}
  230. buildcache-${{ inputs.kernel_version }}
  231. cache_buckets: |
  232. ccache-cache
  233. bazel-cache
  234. lto-cache
  235. compression_level: 9
  236. github_token: ${{ secrets.GITHUB_TOKEN }}
  237. - name: Create Bootimgs Folder and Build Boot Images
  238. uses: ./.github/actions/build-boot-images
  239. - name: Upload Boot Image (boot.img)
  240. uses: actions/upload-artifact@v7
  241. with:
  242. path: ${{ github.workspace }}/boot-artifacts/${{ steps.extract.outputs.file_name }}-boot.img
  243. if-no-files-found: error
  244. archive: false
  245. - name: Upload Boot Image (boot-gz.img)
  246. uses: actions/upload-artifact@v7
  247. with:
  248. path: ${{ github.workspace }}/boot-artifacts/${{ steps.extract.outputs.file_name }}-boot-gz.img
  249. if-no-files-found: error
  250. archive: false
  251. - name: Upload Boot Image (boot-lz4.img)
  252. uses: actions/upload-artifact@v7
  253. with:
  254. path: ${{ github.workspace }}/boot-artifacts/${{ steps.extract.outputs.file_name }}-boot-lz4.img
  255. if-no-files-found: error
  256. archive: false
  257. - name: Prepare AnyKernel3 Zip
  258. uses: ./.github/actions/prepare-anykernel3
  259. - name: Upload Artifacts
  260. uses: actions/upload-artifact@v7
  261. with:
  262. name: ${{ steps.extract.outputs.file_name }}-AnyKernel3
  263. path: ${{ github.workspace }}/AnyKernel3/**
  264. if-no-files-found: ignore
  265. compression-level: 9