build.yml 33 KB

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