build.yml 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755
  1. name: Kernel Build Process
  2. permissions:
  3. contents: read
  4. actions: write
  5. on:
  6. workflow_call:
  7. inputs:
  8. version:
  9. required: true
  10. type: string
  11. android_version:
  12. required: true
  13. type: string
  14. kernel_version:
  15. required: true
  16. type: string
  17. sublevel:
  18. required: true
  19. type: string
  20. os_patch_level:
  21. required: true
  22. type: string
  23. variant:
  24. required: false
  25. type: string
  26. feature_set:
  27. required: true
  28. type: string
  29. ksu_branch:
  30. required: false
  31. type: string
  32. default: ""
  33. susfs_commit:
  34. required: false
  35. type: string
  36. default: ""
  37. root_flavor:
  38. required: false
  39. type: string
  40. default: ""
  41. root_commit:
  42. required: false
  43. type: string
  44. default: ""
  45. nomount_commit:
  46. required: false
  47. type: string
  48. default: ""
  49. kernel_patches_commit:
  50. required: false
  51. type: string
  52. default: ""
  53. anykernel3_commit:
  54. required: false
  55. type: string
  56. default: ""
  57. droidspaces_commit:
  58. required: false
  59. type: string
  60. default: ""
  61. brand_name:
  62. required: false
  63. type: string
  64. default: Wild
  65. build_bypass:
  66. required: false
  67. type: boolean
  68. default: true
  69. bypass:
  70. required: false
  71. type: boolean
  72. default: false
  73. jobs:
  74. build-gki:
  75. name: "${{ inputs.kernel_version }}.${{ inputs.sublevel }}-${{ inputs.android_version }}-${{ inputs.os_patch_level }} (${{ inputs.variant }})"
  76. runs-on: blacksmith-2vcpu-ubuntu-2404
  77. timeout-minutes: 120
  78. steps:
  79. - name: Checkout Repository
  80. uses: actions/checkout@v7
  81. - name: 🧹 Emergency Disk Cleanup
  82. if: false
  83. uses: ./.github/actions/disk-cleanup
  84. - name: Free Disk Space
  85. if: true
  86. uses: endersonmenezes/free-disk-space@v4 # Use @main for latest, @v3 for stable
  87. with:
  88. remove_android: true
  89. remove_dotnet: true
  90. remove_haskell: true
  91. remove_tool_cache: true
  92. remove_swap: true
  93. remove_packages: "azure-cli google-cloud-cli microsoft-edge-stable google-chrome-stable firefox postgresql* temurin-* *llvm* mysql* dotnet-sdk-*"
  94. remove_packages_one_command: true
  95. 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"
  96. rm_cmd: "rmz" # Use 'rmz' for faster deletion (default: 'rm')
  97. rmz_version: "3.2.0" # Required when rm_cmd is 'rmz'
  98. testing: false
  99. - name: Setup more Swap (for LTO)
  100. uses: pierotofy/set-swap-space@master
  101. with:
  102. swap-size-gb: 16
  103. - name: Setup Build Environment
  104. uses: ./.github/actions/setup-build-environment
  105. with:
  106. version: ${{ inputs.version }}
  107. sublevel: ${{ inputs.sublevel }}
  108. kernel_patches_commit: ${{ inputs.kernel_patches_commit }}
  109. anykernel3_commit: ${{ inputs.anykernel3_commit }}
  110. env:
  111. BOOT_SIGN_KEY: ${{ secrets.BOOT_SIGN_KEY }}
  112. - name: Download Kernel Repository
  113. uses: ./.github/actions/download-kernel
  114. with:
  115. version: ${{ inputs.version }}
  116. android_version: ${{ inputs.android_version }}
  117. kernel_version: ${{ inputs.kernel_version }}
  118. os_patch_level: ${{ inputs.os_patch_level }}
  119. - name: Set Build Timestamp from Kernel Commit
  120. shell: bash
  121. run: |
  122. set -x
  123. # Hardcode the build timestamp to the 5th day of the patch level
  124. # at 04:20 UTC, using the existing timestamp formats expected by the build.
  125. OS_PATCH_LEVEL_INPUT="${{ inputs.os_patch_level }}"
  126. if [[ "$OS_PATCH_LEVEL_INPUT" == lts* ]]; then
  127. if [[ "$OS_PATCH_LEVEL_INPUT" =~ ^lts-([0-9]{2})$ ]]; then
  128. OS_PATCH_LEVEL_YM="$(date -u +%Y)-${BASH_REMATCH[1]}"
  129. else
  130. OS_PATCH_LEVEL_YM="$(date -u +%Y-%m)"
  131. fi
  132. else
  133. OS_PATCH_LEVEL_YM="$OS_PATCH_LEVEL_INPUT"
  134. fi
  135. FIXED_BUILD_DATE="${OS_PATCH_LEVEL_YM}-05 04:20:00 UTC"
  136. SOURCE_DATE_EPOCH=$(date -u -d "$FIXED_BUILD_DATE" +%s)
  137. echo "SOURCE_DATE_EPOCH=$SOURCE_DATE_EPOCH" >> $GITHUB_ENV
  138. KBUILD_TS=$(date -u -d @${SOURCE_DATE_EPOCH} '+%a %b %d %H:%M:%S UTC %Y')
  139. echo "KBUILD_BUILD_TIMESTAMP=${KBUILD_TS}" >> $GITHUB_ENV
  140. # Keep git metadata aligned with the same fixed timestamp.
  141. GIT_DATE=$(date -u -d @${SOURCE_DATE_EPOCH} '+%Y-%m-%dT%H:%M:%SZ')
  142. echo "GIT_COMMITTER_DATE=${GIT_DATE}" >> $GITHUB_ENV
  143. echo "GIT_AUTHOR_DATE=${GIT_DATE}" >> $GITHUB_ENV
  144. echo "Build timestamp set to: $(date -u -d @${SOURCE_DATE_EPOCH} '+%Y-%m-%d %H:%M:%S UTC') (epoch: $SOURCE_DATE_EPOCH)"
  145. - name: Extract Sublevel and Set File Name
  146. id: extract
  147. uses: ./.github/actions/extract-sublevel-file-name
  148. with:
  149. android_version: ${{ inputs.android_version }}
  150. kernel_version: ${{ inputs.kernel_version }}
  151. sublevel: ${{ inputs.sublevel }}
  152. os_patch_level: ${{ inputs.os_patch_level }}
  153. variant: ${{ inputs.variant }}
  154. - name: Kernel Fixes
  155. uses: ./.github/actions/kernel-fixes
  156. with:
  157. version: ${{ inputs.version }}
  158. android_version: ${{ inputs.android_version }}
  159. kernel_version: ${{ inputs.kernel_version }}
  160. sublevel: ${{ steps.extract.outputs.sublevel }}
  161. os_patch_level: ${{ inputs.os_patch_level }}
  162. - name: Setup Selected Root Implementation
  163. if: ${{ inputs.root_flavor != '' }}
  164. uses: ./.github/actions/root-setup
  165. with:
  166. flavor: ${{ inputs.root_flavor }}
  167. commit: ${{ inputs.root_commit }}
  168. - name: Disable SUSFS for ReSukiSU without SUSFS feature
  169. if: ${{ inputs.root_flavor == 'resukisu' && !contains(inputs.feature_set, 'SUSFS') }}
  170. uses: ./.github/actions/set-kernel-config
  171. with:
  172. config_list: |
  173. CONFIG_KSU_SUSFS=n
  174. - name: Resolve SUSFS commit
  175. id: susfs-cm
  176. shell: bash
  177. run: |
  178. set -euo pipefail
  179. # KernelSU-Next (next) always uses the latest susfs4ksu gki branch tip so
  180. # SUSFS stays API-matched to the always-latest KernelSU-Next tree. All
  181. # other roots (kernelsu, resukisu) use the pinned verified SUSFS commit.
  182. if [ "${{ inputs.root_flavor }}" = "next" ]; then
  183. BRANCH="gki-${{ inputs.android_version }}-${{ inputs.kernel_version }}"
  184. SUSFS_COMMIT="$(git ls-remote https://gitlab.com/simonpunk/susfs4ksu.git "refs/heads/${BRANCH}" | cut -f1)"
  185. echo "KernelSU-Next: resolving SUSFS at latest on ${BRANCH} -> ${SUSFS_COMMIT}"
  186. else
  187. SUSFS_COMMIT="${{ inputs.susfs_commit }}"
  188. echo "Using pinned SUSFS commit: ${SUSFS_COMMIT}"
  189. fi
  190. echo "commit=${SUSFS_COMMIT}" >> "$GITHUB_OUTPUT"
  191. - name: SUSFS
  192. if: contains(inputs.feature_set, 'SUSFS') || inputs.feature_set == 'All'
  193. uses: ./.github/actions/susfs
  194. with:
  195. susfs_commit: ${{ steps.susfs-cm.outputs.commit }}
  196. version: ${{ inputs.version }}
  197. android_version: ${{ inputs.android_version }}
  198. kernel_version: ${{ inputs.kernel_version }}
  199. os_patch_level: ${{ inputs.os_patch_level }}
  200. sublevel: ${{ steps.extract.outputs.sublevel }}
  201. root_flavor: ${{ inputs.root_flavor }}
  202. nomount_enabled: ${{ contains(inputs.feature_set, 'NoMount') }}
  203. - name: Fix selinux_hide pointer-bool-conversion on 6.6+ (ALL branches)
  204. shell: bash
  205. run: |
  206. set -euo pipefail
  207. KVER="${{ inputs.kernel_version }}"
  208. if [ "$(printf '%s\n' "6.6" "$KVER" | sort -V | head -n1)" = "6.6" ]; then
  209. echo "[INFO] KVER $KVER >= 6.6, patching selinux_hide.c (all flavors/branches)"
  210. for f in $(find "${{ github.workspace }}" -name selinux_hide.c 2>/dev/null); do
  211. # After SUSFS 10_enable (kernelsu only) the declaration becomes
  212. # extern void security_dump_masked_av_fn(...) (a function)
  213. # if (func) / if (func != NULL) both trigger -Werror:
  214. # -Wpointer-bool-conversion vs -Wtautological-pointer-compare
  215. # For the function form, &func != NULL silences both (clang note).
  216. # For the pointer form (resukisu/next, no 10_enable) we want ptr != NULL.
  217. if grep -q "extern void security_dump_masked_av_fn" "$f"; then
  218. echo "[INFO] $f is extern-function form (10_enable applied), patching with &"
  219. sed -i 's/if (security_dump_masked_av_fn)/if (\&security_dump_masked_av_fn)/g' "$f"
  220. sed -i 's/if (security_dump_masked_av_fn != NULL)/if (\&security_dump_masked_av_fn != NULL)/g' "$f"
  221. sed -i 's/if (context_struct_compute_av_fn)/if (\&context_struct_compute_av_fn)/g' "$f"
  222. sed -i 's/if (context_struct_compute_av_fn != NULL)/if (\&context_struct_compute_av_fn != NULL)/g' "$f"
  223. echo "[OK] Patched $f (function form)"
  224. elif grep -q "if (security_dump_masked_av_fn" "$f"; then
  225. echo "[INFO] $f is pointer form, patching with != NULL"
  226. sed -i 's/if (security_dump_masked_av_fn)/if (security_dump_masked_av_fn != NULL)/g' "$f"
  227. sed -i 's/if (context_struct_compute_av_fn)/if (context_struct_compute_av_fn != NULL)/g' "$f"
  228. echo "[OK] Patched $f (pointer form)"
  229. else
  230. echo "[INFO] $f already patched"
  231. fi
  232. # Next (and tiann without 10_enable fallback) declares the 3 helpers as
  233. # static on 6.6, but kernel hooks.c/selinuxfs.c reference them as extern
  234. # after SUSFS (ReSukiSU uses __maybe_static -> global). Strip static so
  235. # the linker can resolve security_context_to_sid_with_policy etc.
  236. if grep -q "^static int security_context_to_sid_with_policy" "$f"; then
  237. echo "[INFO] Stripping static from $f helpers (Next 6.6)"
  238. sed -i 's/^static int security_context_to_sid_with_policy/int security_context_to_sid_with_policy/g' "$f"
  239. sed -i 's/^static int security_sid_to_context_with_policy/int security_sid_to_context_with_policy/g' "$f"
  240. sed -i 's/^static void security_compute_av_user_with_policy/void security_compute_av_user_with_policy/g' "$f"
  241. # also forward decls (same prefix, same sed covers them)
  242. echo "[OK] Stripped static from $f"
  243. fi
  244. done
  245. else
  246. echo "[SKIP] KVER $KVER < 6.6"
  247. fi
  248. - name: Baseband Guard
  249. if: (contains(inputs.feature_set, 'BBG') || inputs.feature_set == 'All')
  250. uses: ./.github/actions/bbg
  251. - name: Setup Networking
  252. if: contains(inputs.feature_set, 'NET') || inputs.feature_set == 'All'
  253. uses: ./.github/actions/networking
  254. with:
  255. version: ${{ inputs.version }}
  256. kernel_version: ${{ inputs.kernel_version }}
  257. android_version: ${{ inputs.android_version }}
  258. sublevel: ${{ steps.extract.outputs.sublevel }}
  259. - name: DroidSpaces-OSS Patches
  260. if: contains(inputs.feature_set, 'DS') || inputs.feature_set == 'All'
  261. uses: ./.github/actions/droidspaces
  262. with:
  263. version: ${{ inputs.version }}
  264. kernel_version: ${{ inputs.kernel_version }}
  265. droidspaces_commit: ${{ inputs.droidspaces_commit }}
  266. - name: Apply NTSync Patches
  267. if: contains(inputs.feature_set, 'NTSync')
  268. uses: ./.github/actions/ntsync
  269. with:
  270. version: ${{ inputs.version }}
  271. kernel_version: ${{ inputs.kernel_version }}
  272. sublevel: ${{ steps.extract.outputs.sublevel }}
  273. - name: Apply Ptrace Patch
  274. if: contains(inputs.feature_set, 'Ptrace')
  275. uses: ./.github/actions/ptrace
  276. with:
  277. kernel_version: ${{ inputs.kernel_version }}
  278. - name: Apply Unicode Fix Patch
  279. if: contains(inputs.feature_set, 'Unicode')
  280. uses: ./.github/actions/unicode-fix
  281. with:
  282. kernel_version: ${{ inputs.kernel_version }}
  283. - name: Apply Performance Patches
  284. uses: ./.github/actions/performance
  285. if: contains(inputs.feature_set, 'Perf')
  286. with:
  287. kernel_version: ${{ inputs.kernel_version }}
  288. - name: Setup Misc Configs
  289. uses: ./.github/actions/misc
  290. - name: Enable BPF Stack (BTF + eBPF + FUSE-BPF)
  291. if: contains(inputs.feature_set, 'BPF')
  292. uses: ./.github/actions/btf
  293. with:
  294. version: ${{ inputs.version }}
  295. kernel_version: ${{ inputs.kernel_version }}
  296. sublevel: ${{ steps.extract.outputs.sublevel }}
  297. - name: Apply Device-Specific Patches
  298. uses: ./.github/actions/apply-device-patches
  299. with:
  300. version: ${{ inputs.version }}
  301. kernel_version: ${{ inputs.kernel_version }}
  302. - name: Integrate NoMount
  303. if: ${{ inputs.nomount_commit != '' || contains(inputs.feature_set, 'NoMount') || inputs.feature_set == 'All' }}
  304. uses: ./.github/actions/nomount
  305. with:
  306. commit: ${{ inputs.nomount_commit }}
  307. kernel_version: ${{ inputs.kernel_version }}
  308. - name: Apply ABI Compare Bypass
  309. if: false
  310. working-directory: ${{ github.workspace }}/kernel
  311. run: |
  312. # ABI compare bypass per kernel/android version
  313. # Edit each block as needed per version
  314. if [[ "$ANDROID_VERSION" == "android12" && "$KERNEL_VERSION" == "5.10" ]]; then
  315. sed -i 's/^\s*exit 1$/ echo "Who Cares? Bypassing Now!"/' build/abi/compare_to_symbol_list
  316. elif [[ "$ANDROID_VERSION" == "android13" && "$KERNEL_VERSION" == "5.10" ]]; then
  317. sed -i 's/^\s*exit 1$/ echo "Who Cares? Bypassing Now!"/' build/kernel/abi/compare_to_symbol_list
  318. elif [[ "$ANDROID_VERSION" == "android13" && "$KERNEL_VERSION" == "5.15" ]]; then
  319. sed -i 's/^\s*exit 1$/ echo "Who Cares? Bypassing Now!"/' build/kernel/abi/compare_to_symbol_list
  320. elif [[ "$ANDROID_VERSION" == "android14" && "$KERNEL_VERSION" == "5.15" ]]; then
  321. 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
  322. elif [[ "$ANDROID_VERSION" == "android14" && "$KERNEL_VERSION" == "6.1" ]]; then
  323. 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
  324. elif [[ "$ANDROID_VERSION" == "android15" && "$KERNEL_VERSION" == "6.6" ]]; then
  325. 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
  326. fi
  327. - name: Apply Kernel Branding
  328. uses: ./.github/actions/apply-kernel-branding
  329. with:
  330. variant: ${{ inputs.variant }}
  331. kernel_version: ${{ inputs.kernel_version }}
  332. android_version: ${{ inputs.android_version }}
  333. version: ${{ inputs.version }}
  334. sublevel: ${{ steps.extract.outputs.sublevel }}
  335. brand_name: ${{ inputs.brand_name }}
  336. - name: Remove Protected Exports
  337. uses: ./.github/actions/remove-protected-exports
  338. - name: Clean Kernel Flags
  339. uses: ./.github/actions/clean-kernel-flags
  340. - name: Scan and collect patch rejects
  341. id: scan
  342. if: ${{ always() }}
  343. uses: ./.github/actions/scan-patch-rejects
  344. - name: Upload Rejects
  345. if: ${{ always() }}
  346. uses: actions/upload-artifact@v7
  347. with:
  348. name: ${{ steps.extract.outputs.file_name }}-Rejects
  349. path: patch-rejects/
  350. if-no-files-found: ignore
  351. compression-level: 9
  352. - name: Get prebuilt ccache (downloaded once by prepare-ccache)
  353. if: false
  354. uses: actions/download-artifact@v8
  355. with:
  356. name: ccache-binary
  357. path: ccache-dl
  358. continue-on-error: true
  359. - name: 'Setup Cache and Build Environment'
  360. uses: ./.github/actions/cache-setup
  361. with:
  362. version: ${{ inputs.version }}
  363. android_version: ${{ inputs.android_version }}
  364. kernel_version: ${{ inputs.kernel_version }}
  365. sublevel: ${{ steps.extract.outputs.sublevel }}
  366. - name: Restore ccache
  367. id: restore-ccache
  368. continue-on-error: true
  369. if: false && (inputs.version == 'android12-5.10' || inputs.version == 'android13-5.10' || inputs.version == 'android13-5.15')
  370. uses: ./.github/actions/cache-restore
  371. with:
  372. cache_path: /home/runner/.ccache
  373. cache_key: ${{ inputs.android_version }}-${{ inputs.kernel_version }}.${{ steps.extract.outputs.sublevel }}-${{ inputs.os_patch_level }}
  374. cache_bucket: ccache-cache
  375. restore_keys: |
  376. ${{ inputs.android_version }}-${{ inputs.kernel_version }}.${{ steps.extract.outputs.sublevel }}-
  377. - name: Restore bazel-cache
  378. id: restore-bazel
  379. continue-on-error: true
  380. if: false && (inputs.version == 'android14-5.15' || inputs.version == 'android14-6.1' || inputs.version == 'android15-6.6' || inputs.version == 'android16-6.12')
  381. uses: ./.github/actions/cache-restore
  382. with:
  383. cache_path: /home/runner/.cache/bazel
  384. cache_key: ${{ inputs.android_version }}-${{ inputs.kernel_version }}.${{ steps.extract.outputs.sublevel }}-${{ inputs.os_patch_level }}
  385. cache_bucket: bazel-cache
  386. restore_keys: |
  387. ${{ inputs.android_version }}-${{ inputs.kernel_version }}.${{ steps.extract.outputs.sublevel }}-
  388. - name: Cache ccache (GitHub Native)
  389. if: false
  390. uses: actions/cache@v6
  391. with:
  392. path: /home/runner/.ccache
  393. key: ccache-${{ inputs.android_version }}-${{ inputs.kernel_version }}.${{ steps.extract.outputs.sublevel }}-${{ inputs.os_patch_level }}
  394. restore-keys: |
  395. ccache-${{ inputs.android_version }}-${{ inputs.kernel_version }}.${{ steps.extract.outputs.sublevel }}-
  396. ccache-${{ inputs.android_version }}-${{ inputs.kernel_version }}-
  397. ccache-
  398. - name: Cache bazel-cache (GitHub Native)
  399. if: false
  400. uses: actions/cache@v6
  401. with:
  402. path: /home/runner/.cache/bazel
  403. key: bazel-${{ inputs.android_version }}-${{ inputs.kernel_version }}.${{ steps.extract.outputs.sublevel }}-${{ inputs.os_patch_level }}
  404. restore-keys: |
  405. bazel-${{ inputs.android_version }}-${{ inputs.kernel_version }}.${{ steps.extract.outputs.sublevel }}-
  406. bazel-${{ inputs.android_version }}-${{ inputs.kernel_version }}-
  407. bazel-
  408. - name: Check cache hit
  409. run: |
  410. echo "Cache restore status:"
  411. CCACHE_HIT="${{ steps.restore-ccache.outputs.cache-hit || 'skipped' }}"
  412. BAZEL_HIT="${{ steps.restore-bazel.outputs.cache-hit || 'skipped' }}"
  413. echo " ccache: $CCACHE_HIT"
  414. echo " bazel: $BAZEL_HIT"
  415. - name: Get Cache Stats
  416. uses: ./.github/actions/cache-stats
  417. with:
  418. clear_stats: true
  419. - name: Initialize Config Fragment
  420. run: touch "${{ github.workspace }}/wild_gki.fragment"
  421. - name: Apply Kernel Bypass Hack
  422. if: ${{ inputs.bypass == 'true' }}
  423. uses: ./.github/actions/bypass-kernel
  424. with:
  425. version: ${{ inputs.version }}
  426. bypass: true
  427. - name: Build Normal Kernel
  428. env:
  429. SOURCE_DATE_EPOCH: ${{ env.SOURCE_DATE_EPOCH }}
  430. KBUILD_BUILD_TIMESTAMP: ${{ env.KBUILD_BUILD_TIMESTAMP }}
  431. uses: ./.github/actions/build-kernel
  432. with:
  433. version: ${{ inputs.version }}
  434. bypass: false
  435. - name: Get Cache Stats
  436. uses: ./.github/actions/cache-stats
  437. with:
  438. clear_stats: false
  439. - name: Save ccache
  440. continue-on-error: true
  441. uses: ./.github/actions/cache-save
  442. if: false && (inputs.version == 'android12-5.10' || inputs.version == 'android13-5.10' || inputs.version == 'android13-5.15')
  443. with:
  444. cache_path: /home/runner/.ccache
  445. cache_key: ${{ inputs.android_version }}-${{ inputs.kernel_version }}.${{ steps.extract.outputs.sublevel }}-${{ inputs.os_patch_level }}
  446. cache_bucket: "ccache-cache"
  447. compression_level: 9
  448. github_token: ${{ secrets.MY_GITHUB_TOKEN }}
  449. - name: Save bazel-cache
  450. continue-on-error: true
  451. uses: ./.github/actions/cache-save
  452. if: false && (inputs.version == 'android14-5.15' || inputs.version == 'android14-6.1' || inputs.version == 'android15-6.6' || inputs.version == 'android16-6.12')
  453. with:
  454. cache_path: /home/runner/.cache/bazel
  455. cache_key: ${{ inputs.android_version }}-${{ inputs.kernel_version }}.${{ steps.extract.outputs.sublevel }}-${{ inputs.os_patch_level }}
  456. cache_bucket: "bazel-cache"
  457. compression_level: 9
  458. github_token: ${{ secrets.MY_GITHUB_TOKEN }}
  459. - name: Build Bypass Kernel
  460. if: false
  461. env:
  462. SOURCE_DATE_EPOCH: ${{ env.SOURCE_DATE_EPOCH }}
  463. KBUILD_BUILD_TIMESTAMP: ${{ env.KBUILD_BUILD_TIMESTAMP }}
  464. uses: ./.github/actions/build-kernel
  465. with:
  466. bypass: true
  467. version: ${{ inputs.version }}
  468. - name: 📋 Consolidated Build Summary
  469. if: ${{ always() }}
  470. shell: bash
  471. run: |
  472. SUMMARY_BASE="${{ steps.extract.outputs.file_name }}"
  473. if [ -z "${SUMMARY_BASE}" ]; then
  474. SUMMARY_BASE="${{ inputs.kernel_version }}.${{ inputs.sublevel }}-${{ inputs.android_version }}-${{ inputs.os_patch_level }}"
  475. VARIANT="${{ inputs.variant }}"
  476. if [ -n "${VARIANT}" ] && [ "${VARIANT}" != "Normal" ]; then
  477. SUMMARY_BASE="${SUMMARY_BASE}-${VARIANT}"
  478. fi
  479. fi
  480. SUMMARY_FILE="/tmp/build-summary-${SUMMARY_BASE}.md"
  481. echo "SUMMARY_BASE=${SUMMARY_BASE}" >> "$GITHUB_ENV"
  482. # Determine build status
  483. if [ "${{ job.status }}" = "success" ]; then
  484. STATUS="✅ Success"
  485. else
  486. STATUS="❌ Failed"
  487. fi
  488. # Get kernel version from Image if available
  489. KERNEL_VER_STR=""
  490. if [ -f "/home/runner/out/dist/Image" ]; then
  491. KERNEL_VER_STR=$(strings "/home/runner/out/dist/Image" | grep -m1 "^Linux version " | sed 's/Linux version //' || echo "")
  492. elif [ -f "/home/runner/out/Image" ]; then
  493. KERNEL_VER_STR=$(strings "/home/runner/out/Image" | grep -m1 "^Linux version " | sed 's/Linux version //' || echo "")
  494. fi
  495. # Get KSU version from env (set by kernelsu action)
  496. KSU_VER="${KSU_VERSION:-N/A}"
  497. KSU_TAG="${KSU_GIT_TAG:-N/A}"
  498. ROOT_IMPL="${ROOT_IMPLEMENTATION:-KernelSU-Next (legacy path)}"
  499. ROOT_MANAGER="${ROOT_MANAGER:-KernelSU-Next Manager}"
  500. ROOT_VERSION="${ROOT_VERSION:-${KSU_TAG}}"
  501. ROOT_SHA="${ROOT_COMMIT:-${KSU_COMMIT:-N/A}}"
  502. NOMOUNT_SHA="${NOMOUNT_COMMIT:-${{ inputs.nomount_commit }}}"
  503. SUSFS_SHA="${SUSFS_COMMIT:-${{ inputs.susfs_commit }}}"
  504. # Get SUSFS version from susfs.h if available
  505. SUSFS_VER="N/A"
  506. if [ -f "${{ github.workspace }}/kernel/common/include/linux/susfs.h" ]; then
  507. SUSFS_VER=$(grep '#define SUSFS_VERSION' "${{ github.workspace }}/kernel/common/include/linux/susfs.h" | awk -F'"' '{print $2}' || echo "N/A")
  508. fi
  509. # Get cache stats from env (set by cache-stats action)
  510. CCACHE_HIT="${CCACHE_HIT_RATE:-N/A}"
  511. # Get build time (approximate from step timing)
  512. BUILD_TIME="N/A"
  513. # Count warnings from build log if available
  514. WARNINGS="N/A"
  515. {
  516. echo "## ${{ inputs.android_version }} ${{ inputs.kernel_version }}.${{ inputs.sublevel }} (${{ inputs.variant }}) — ${STATUS}"
  517. echo
  518. echo "| Metric | Value |"
  519. echo "|--------|-------|"
  520. echo "| **Status** | ${STATUS} |"
  521. echo "| **Kernel** | ${{ inputs.kernel_version }}.${{ inputs.sublevel }}-${{ inputs.android_version }}-${{ inputs.os_patch_level }} |"
  522. if [ -n "$KERNEL_VER_STR" ]; then
  523. echo "| **Version String** | \`${KERNEL_VER_STR}\` |"
  524. fi
  525. echo "| **KSU Version** | ${KSU_VER} |"
  526. echo "| **KSU Tag** | ${KSU_TAG} |"
  527. echo "| **Root Implementation** | ${ROOT_IMPL} |"
  528. echo "| **Root Manager** | ${ROOT_MANAGER} |"
  529. echo "| **Root Version** | ${ROOT_VERSION} |"
  530. echo "| **Root Commit** | ${ROOT_SHA} |"
  531. echo "| **SUSFS Version** | ${SUSFS_VER} |"
  532. echo "| **SUSFS Commit** | ${SUSFS_SHA} |"
  533. echo "| **NoMount Commit** | ${NOMOUNT_SHA} |"
  534. echo "| **Feature Set** | ${{ inputs.feature_set }} |"
  535. echo "| **Variant** | ${{ inputs.variant }} |"
  536. echo
  537. # Kernel Fixes
  538. if [ -f /tmp/kernel-fixes-summary.md ]; then
  539. echo "### 🔧 Kernel Fixes"
  540. cat /tmp/kernel-fixes-summary.md
  541. echo
  542. fi
  543. } > "$SUMMARY_FILE"
  544. - name: Upload Artifacts
  545. id: kernel-artifact
  546. uses: actions/upload-artifact@v7
  547. with:
  548. name: ${{ steps.extract.outputs.file_name }}-AnyKernel3
  549. path: ${{ github.workspace }}/AnyKernel3/**
  550. if-no-files-found: ignore
  551. compression-level: 9
  552. - name: Write Build-verified only artifact metadata
  553. if: ${{ success() && inputs.root_flavor != '' && inputs.nomount_commit != '' }}
  554. shell: bash
  555. env:
  556. GH_TOKEN: ${{ github.token }}
  557. run: |
  558. set -euo pipefail
  559. metadata_file="/tmp/${SUMMARY_BASE}-metadata.json"
  560. summary_file="/tmp/build-summary-${SUMMARY_BASE}.md"
  561. artifacts_api="${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}/artifacts?per_page=100"
  562. resolve_artifact() {
  563. local artifact_name="$1"
  564. local page=1
  565. local match=""
  566. local page_file
  567. page_file="$(mktemp)"
  568. # Page through the artifacts API, checking each page for the exact
  569. # artifact name. Uses a temp file for jq input (not argv) so large
  570. # artifact lists can't exceed the OS argument-length limit.
  571. while :; do
  572. curl --fail --silent --show-error --location \
  573. --header "Authorization: Bearer ${GH_TOKEN}" \
  574. --header "X-GitHub-Api-Version: 2022-11-28" \
  575. "${artifacts_api}&page=${page}" -o "$page_file"
  576. match="$(jq -r --arg name "$artifact_name" \
  577. '[.artifacts[] | select(.name == $name and .expired == false)] | .[0]
  578. | if . == null then "" else (.archive_download_url + "\t" + .digest) end' \
  579. "$page_file")"
  580. items="$(jq '(.artifacts | length) // 0' "$page_file")"
  581. if [ "$items" -lt 100 ] || [ -n "$match" ]; then
  582. break
  583. fi
  584. page=$((page + 1))
  585. done
  586. rm -f "$page_file"
  587. if [ -z "$match" ]; then
  588. echo "Expected exactly one available artifact named ${artifact_name}." >&2
  589. exit 1
  590. fi
  591. printf '%s\n' "$match"
  592. }
  593. read -r kernel_artifact_url kernel_artifact_sha256 < <(
  594. resolve_artifact "${{ steps.extract.outputs.file_name }}-AnyKernel3"
  595. )
  596. read -r nomount_module_url nomount_module_sha256 < <(
  597. resolve_artifact "NoMount-Metamodule"
  598. )
  599. jq -n \
  600. --arg method "GKI source build with SHA-pinned root implementation, SUSFS, and NoMount" \
  601. --arg root_implementation "${ROOT_IMPLEMENTATION:-KernelSU-Next (legacy path)}" \
  602. --arg root_manager "${ROOT_MANAGER:-KernelSU-Next Manager}" \
  603. --arg root_version "${ROOT_VERSION:-${KSU_GIT_TAG:-N/A}}" \
  604. --arg root_commit "${ROOT_COMMIT:-${KSU_COMMIT:-N/A}}" \
  605. --arg susfs_commit "${SUSFS_COMMIT:-N/A}" \
  606. --arg nomount_commit "${NOMOUNT_COMMIT:-N/A}" \
  607. --arg android_branch "${{ inputs.android_version }}-${{ inputs.kernel_version }}-${{ inputs.os_patch_level }}" \
  608. --arg kmi "${{ inputs.android_version }}-${{ inputs.kernel_version }}" \
  609. --arg kernel_source_commit "${KERNEL_SOURCE_COMMIT:-N/A}" \
  610. --arg provenance_url "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" \
  611. --arg artifact_url "$kernel_artifact_url" \
  612. --arg sha256 "$kernel_artifact_sha256" \
  613. --arg nomount_module_commit "${{ inputs.nomount_commit }}" \
  614. --arg nomount_module_url "$nomount_module_url" \
  615. --arg nomount_module_sha256 "$nomount_module_sha256" \
  616. --arg status "Build-verified only" \
  617. --arg catalog_availability "eligible-with-provenance-and-checksums" \
  618. --arg device_compatibility "not-validated" \
  619. --arg flashability "not-guaranteed" \
  620. --arg boot "not-guaranteed" \
  621. '{
  622. method: $method,
  623. root: {
  624. implementation: $root_implementation,
  625. manager: $root_manager,
  626. version: $root_version,
  627. commit: $root_commit
  628. },
  629. susfs_revision: $susfs_commit,
  630. nomount_commit: $nomount_commit,
  631. android_branch: $android_branch,
  632. kmi: $kmi,
  633. kernel_source_commit: $kernel_source_commit,
  634. provenance_url: $provenance_url,
  635. artifact_url: $artifact_url,
  636. sha256: $sha256,
  637. nomount_metamodule: {
  638. commit: $nomount_module_commit,
  639. artifact_url: $nomount_module_url,
  640. sha256: $nomount_module_sha256
  641. },
  642. catalog: {
  643. availability: $catalog_availability,
  644. device_compatibility: $device_compatibility,
  645. flashability: $flashability,
  646. boot: $boot
  647. },
  648. status: $status
  649. }' > "$metadata_file"
  650. jq -e '
  651. .status == "Build-verified only" and
  652. (.root.manager | length > 0) and
  653. (.root.version | length > 0) and
  654. (.susfs_revision | test("^[0-9a-f]{40}$")) and
  655. (.nomount_commit | test("^[0-9a-f]{40}$")) and
  656. (.kernel_source_commit | test("^[0-9a-f]{40}$")) and
  657. (.artifact_url | startswith("https://")) and
  658. (.sha256 | test("^sha256:[0-9a-f]{64}$")) and
  659. (.nomount_metamodule.commit == .nomount_commit) and
  660. (.nomount_metamodule.artifact_url | startswith("https://")) and
  661. (.nomount_metamodule.sha256 | test("^sha256:[0-9a-f]{64}$")) and
  662. .catalog.availability == "eligible-with-provenance-and-checksums" and
  663. .catalog.device_compatibility == "not-validated" and
  664. .catalog.flashability == "not-guaranteed" and
  665. .catalog.boot == "not-guaranteed"
  666. ' "$metadata_file" > /dev/null
  667. # Merge the verified metadata into the combined summary markdown so both
  668. # live in a single artifact: human-readable table + machine JSON block.
  669. {
  670. echo
  671. echo "## Verified Metadata"
  672. echo
  673. echo '```json'
  674. cat "$metadata_file"
  675. echo '```'
  676. echo
  677. } >> "$summary_file"
  678. - name: Upload Build Summary + Metadata
  679. uses: actions/upload-artifact@v7
  680. with:
  681. name: ${{ steps.extract.outputs.file_name }}-BuildInfo
  682. path: /tmp/build-summary-${{ env.SUMMARY_BASE }}.md
  683. if-no-files-found: warn
  684. compression-level: 9