build.yml 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727
  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. preserve_abi:
  66. required: false
  67. type: boolean
  68. default: false
  69. build_bypass:
  70. required: false
  71. type: boolean
  72. default: true
  73. jobs:
  74. build-gki:
  75. name: "${{ inputs.kernel_version }}.${{ inputs.sublevel }}-${{ inputs.android_version }}-${{ inputs.os_patch_level }} (${{ inputs.variant }})"
  76. runs-on: ubuntu-latest
  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@v3 # 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_packages: "azure-cli google-cloud-cli microsoft-edge-stable google-chrome-stable firefox postgresql* temurin-* *llvm* mysql* dotnet-sdk-*"
  93. remove_packages_one_command: true
  94. 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"
  95. rm_cmd: "rmz" # Use 'rmz' for faster deletion (default: 'rm')
  96. rmz_version: "3.1.1" # Required when rm_cmd is 'rmz'
  97. testing: false
  98. - name: Setup more Swap (for LTO)
  99. uses: thejerrybao/setup-swap-space@v1 # or pierotofy/set-swap-space
  100. with:
  101. swap-size-gb: 16 # 10-24 GB is common for heavy LTO
  102. # swap-space-path: /mnt/swapfile # optional
  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: Capture source ABI/KMI safeguards
  163. if: ${{ inputs.preserve_abi }}
  164. uses: ./.github/actions/abi-kmi-safeguards
  165. with:
  166. mode: capture
  167. - name: Setup Selected Root Implementation
  168. if: ${{ inputs.root_flavor != '' }}
  169. uses: ./.github/actions/root-setup
  170. with:
  171. flavor: ${{ inputs.root_flavor }}
  172. commit: ${{ inputs.root_commit }}
  173. - name: Disable SUSFS for ReSukiSU without SUSFS feature
  174. if: ${{ inputs.root_flavor == 'resukisu' && !contains(inputs.feature_set, 'SUSFS') }}
  175. uses: ./.github/actions/set-kernel-config
  176. with:
  177. config_list: |
  178. CONFIG_KSU_SUSFS=n
  179. - name: Verify root ABI/KMI safeguards
  180. if: ${{ inputs.preserve_abi }}
  181. uses: ./.github/actions/abi-kmi-safeguards
  182. with:
  183. mode: verify
  184. - name: Resolve SUSFS commit
  185. id: susfs-cm
  186. shell: bash
  187. run: |
  188. set -euo pipefail
  189. # KernelSU-Next (next) always uses the latest susfs4ksu gki branch tip so
  190. # SUSFS stays API-matched to the always-latest KernelSU-Next tree. All
  191. # other roots (kernelsu, resukisu) use the pinned 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. nomount_enabled: ${{ contains(inputs.feature_set, 'NoMount') }}
  213. - name: Baseband Guard
  214. if: (contains(inputs.feature_set, 'BBG') || inputs.feature_set == 'All')
  215. uses: ./.github/actions/bbg
  216. - name: Setup Networking
  217. if: contains(inputs.feature_set, 'NET') || inputs.feature_set == 'All'
  218. uses: ./.github/actions/networking
  219. with:
  220. version: ${{ inputs.version }}
  221. kernel_version: ${{ inputs.kernel_version }}
  222. android_version: ${{ inputs.android_version }}
  223. sublevel: ${{ steps.extract.outputs.sublevel }}
  224. - name: DroidSpaces-OSS Patches
  225. if: contains(inputs.feature_set, 'DS') || inputs.feature_set == 'All'
  226. uses: ./.github/actions/droidspaces
  227. with:
  228. version: ${{ inputs.version }}
  229. kernel_version: ${{ inputs.kernel_version }}
  230. droidspaces_commit: ${{ inputs.droidspaces_commit }}
  231. - name: Apply NTSync Patches
  232. if: contains(inputs.feature_set, 'NTSync')
  233. uses: ./.github/actions/ntsync
  234. with:
  235. version: ${{ inputs.version }}
  236. kernel_version: ${{ inputs.kernel_version }}
  237. sublevel: ${{ steps.extract.outputs.sublevel }}
  238. - name: Apply Ptrace Patch
  239. if: contains(inputs.feature_set, 'Ptrace')
  240. uses: ./.github/actions/ptrace
  241. with:
  242. kernel_version: ${{ inputs.kernel_version }}
  243. - name: Apply Unicode Fix Patch
  244. if: contains(inputs.feature_set, 'Unicode')
  245. uses: ./.github/actions/unicode-fix
  246. with:
  247. kernel_version: ${{ inputs.kernel_version }}
  248. - name: Apply Performance Patches
  249. uses: ./.github/actions/performance
  250. if: contains(inputs.feature_set, 'Perf')
  251. with:
  252. kernel_version: ${{ inputs.kernel_version }}
  253. - name: Setup Misc Configs
  254. uses: ./.github/actions/misc
  255. - name: Enable BPF Stack (BTF + eBPF + FUSE-BPF)
  256. if: contains(inputs.feature_set, 'BPF')
  257. uses: ./.github/actions/btf
  258. with:
  259. version: ${{ inputs.version }}
  260. kernel_version: ${{ inputs.kernel_version }}
  261. sublevel: ${{ steps.extract.outputs.sublevel }}
  262. - name: Apply Device-Specific Patches
  263. uses: ./.github/actions/apply-device-patches
  264. with:
  265. version: ${{ inputs.version }}
  266. kernel_version: ${{ inputs.kernel_version }}
  267. - name: Capture approved feature ABI/KMI baseline
  268. if: ${{ inputs.preserve_abi }}
  269. uses: ./.github/actions/abi-kmi-safeguards
  270. with:
  271. mode: capture
  272. - name: Integrate NoMount
  273. if: ${{ inputs.nomount_commit != '' || contains(inputs.feature_set, 'NoMount') || inputs.feature_set == 'All' }}
  274. uses: ./.github/actions/nomount
  275. with:
  276. commit: ${{ inputs.nomount_commit }}
  277. kernel_version: ${{ inputs.kernel_version }}
  278. - name: Apply ABI Compare Bypass
  279. if: false
  280. working-directory: ${{ github.workspace }}/kernel
  281. run: |
  282. # ABI compare bypass per kernel/android version
  283. # Edit each block as needed per version
  284. if [[ "$ANDROID_VERSION" == "android12" && "$KERNEL_VERSION" == "5.10" ]]; then
  285. sed -i 's/^\s*exit 1$/ echo "Who Cares? Bypassing Now!"/' build/abi/compare_to_symbol_list
  286. elif [[ "$ANDROID_VERSION" == "android13" && "$KERNEL_VERSION" == "5.10" ]]; then
  287. sed -i 's/^\s*exit 1$/ echo "Who Cares? Bypassing Now!"/' build/kernel/abi/compare_to_symbol_list
  288. elif [[ "$ANDROID_VERSION" == "android13" && "$KERNEL_VERSION" == "5.15" ]]; then
  289. sed -i 's/^\s*exit 1$/ echo "Who Cares? Bypassing Now!"/' build/kernel/abi/compare_to_symbol_list
  290. elif [[ "$ANDROID_VERSION" == "android14" && "$KERNEL_VERSION" == "5.15" ]]; then
  291. 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
  292. elif [[ "$ANDROID_VERSION" == "android14" && "$KERNEL_VERSION" == "6.1" ]]; then
  293. 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
  294. elif [[ "$ANDROID_VERSION" == "android15" && "$KERNEL_VERSION" == "6.6" ]]; then
  295. 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
  296. fi
  297. - name: Apply Kernel Branding
  298. uses: ./.github/actions/apply-kernel-branding
  299. with:
  300. variant: ${{ inputs.variant }}
  301. kernel_version: ${{ inputs.kernel_version }}
  302. android_version: ${{ inputs.android_version }}
  303. version: ${{ inputs.version }}
  304. sublevel: ${{ steps.extract.outputs.sublevel }}
  305. brand_name: ${{ inputs.brand_name }}
  306. - name: Remove Protected Exports
  307. if: ${{ !inputs.preserve_abi }}
  308. uses: ./.github/actions/remove-protected-exports
  309. - name: Verify NoMount ABI/KMI safeguards
  310. if: ${{ inputs.preserve_abi }}
  311. uses: ./.github/actions/abi-kmi-safeguards
  312. with:
  313. mode: verify
  314. - name: Clean Kernel Flags
  315. uses: ./.github/actions/clean-kernel-flags
  316. - name: Scan and collect patch rejects
  317. id: scan
  318. if: ${{ always() }}
  319. uses: ./.github/actions/scan-patch-rejects
  320. - name: Upload Rejects
  321. if: ${{ always() }}
  322. uses: actions/upload-artifact@v7
  323. with:
  324. name: ${{ steps.extract.outputs.file_name }}-Rejects
  325. path: patch-rejects/
  326. if-no-files-found: ignore
  327. compression-level: 9
  328. - name: Get prebuilt ccache (downloaded once by prepare-ccache)
  329. if: false
  330. uses: actions/download-artifact@v8
  331. with:
  332. name: ccache-binary
  333. path: ccache-dl
  334. continue-on-error: true
  335. - name: 'Setup Cache and Build Environment'
  336. uses: ./.github/actions/cache-setup
  337. with:
  338. version: ${{ inputs.version }}
  339. android_version: ${{ inputs.android_version }}
  340. kernel_version: ${{ inputs.kernel_version }}
  341. sublevel: ${{ steps.extract.outputs.sublevel }}
  342. - name: Restore ccache
  343. id: restore-ccache
  344. continue-on-error: true
  345. if: false && (inputs.version == 'android12-5.10' || inputs.version == 'android13-5.10' || inputs.version == 'android13-5.15')
  346. uses: ./.github/actions/cache-restore
  347. with:
  348. cache_path: /home/runner/.ccache
  349. cache_key: ${{ inputs.android_version }}-${{ inputs.kernel_version }}.${{ steps.extract.outputs.sublevel }}-${{ inputs.os_patch_level }}
  350. cache_bucket: ccache-cache
  351. restore_keys: |
  352. ${{ inputs.android_version }}-${{ inputs.kernel_version }}.${{ steps.extract.outputs.sublevel }}-
  353. - name: Restore bazel-cache
  354. id: restore-bazel
  355. continue-on-error: true
  356. if: false && (inputs.version == 'android14-5.15' || inputs.version == 'android14-6.1' || inputs.version == 'android15-6.6' || inputs.version == 'android16-6.12')
  357. uses: ./.github/actions/cache-restore
  358. with:
  359. cache_path: /home/runner/.cache/bazel
  360. cache_key: ${{ inputs.android_version }}-${{ inputs.kernel_version }}.${{ steps.extract.outputs.sublevel }}-${{ inputs.os_patch_level }}
  361. cache_bucket: bazel-cache
  362. restore_keys: |
  363. ${{ inputs.android_version }}-${{ inputs.kernel_version }}.${{ steps.extract.outputs.sublevel }}-
  364. - name: Cache ccache (GitHub Native)
  365. if: false
  366. uses: actions/cache@v6
  367. with:
  368. path: /home/runner/.ccache
  369. key: ccache-${{ inputs.android_version }}-${{ inputs.kernel_version }}.${{ steps.extract.outputs.sublevel }}-${{ inputs.os_patch_level }}
  370. restore-keys: |
  371. ccache-${{ inputs.android_version }}-${{ inputs.kernel_version }}.${{ steps.extract.outputs.sublevel }}-
  372. ccache-${{ inputs.android_version }}-${{ inputs.kernel_version }}-
  373. ccache-
  374. - name: Cache bazel-cache (GitHub Native)
  375. if: false
  376. uses: actions/cache@v6
  377. with:
  378. path: /home/runner/.cache/bazel
  379. key: bazel-${{ inputs.android_version }}-${{ inputs.kernel_version }}.${{ steps.extract.outputs.sublevel }}-${{ inputs.os_patch_level }}
  380. restore-keys: |
  381. bazel-${{ inputs.android_version }}-${{ inputs.kernel_version }}.${{ steps.extract.outputs.sublevel }}-
  382. bazel-${{ inputs.android_version }}-${{ inputs.kernel_version }}-
  383. bazel-
  384. - name: Check cache hit
  385. run: |
  386. echo "Cache restore status:"
  387. CCACHE_HIT="${{ steps.restore-ccache.outputs.cache-hit || 'skipped' }}"
  388. BAZEL_HIT="${{ steps.restore-bazel.outputs.cache-hit || 'skipped' }}"
  389. echo " ccache: $CCACHE_HIT"
  390. echo " bazel: $BAZEL_HIT"
  391. - name: Get Cache Stats
  392. uses: ./.github/actions/cache-stats
  393. with:
  394. clear_stats: true
  395. - name: Initialize Config Fragment
  396. run: touch "${{ github.workspace }}/wild_gki.fragment"
  397. - name: Build Normal Kernel
  398. env:
  399. SOURCE_DATE_EPOCH: ${{ env.SOURCE_DATE_EPOCH }}
  400. KBUILD_BUILD_TIMESTAMP: ${{ env.KBUILD_BUILD_TIMESTAMP }}
  401. uses: ./.github/actions/build-kernel
  402. with:
  403. version: ${{ inputs.version }}
  404. bypass: false
  405. - name: Get Cache Stats
  406. uses: ./.github/actions/cache-stats
  407. with:
  408. clear_stats: false
  409. - name: Save ccache
  410. continue-on-error: true
  411. uses: ./.github/actions/cache-save
  412. if: false && (inputs.version == 'android12-5.10' || inputs.version == 'android13-5.10' || inputs.version == 'android13-5.15')
  413. with:
  414. cache_path: /home/runner/.ccache
  415. cache_key: ${{ inputs.android_version }}-${{ inputs.kernel_version }}.${{ steps.extract.outputs.sublevel }}-${{ inputs.os_patch_level }}
  416. cache_bucket: "ccache-cache"
  417. compression_level: 9
  418. github_token: ${{ secrets.MY_GITHUB_TOKEN }}
  419. - name: Save bazel-cache
  420. continue-on-error: true
  421. uses: ./.github/actions/cache-save
  422. if: false && (inputs.version == 'android14-5.15' || inputs.version == 'android14-6.1' || inputs.version == 'android15-6.6' || inputs.version == 'android16-6.12')
  423. with:
  424. cache_path: /home/runner/.cache/bazel
  425. cache_key: ${{ inputs.android_version }}-${{ inputs.kernel_version }}.${{ steps.extract.outputs.sublevel }}-${{ inputs.os_patch_level }}
  426. cache_bucket: "bazel-cache"
  427. compression_level: 9
  428. github_token: ${{ secrets.MY_GITHUB_TOKEN }}
  429. - name: Build Bypass Kernel
  430. if: ${{ inputs.build_bypass }}
  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. bypass: true
  437. version: ${{ inputs.version }}
  438. - name: 📋 Consolidated Build Summary
  439. if: ${{ always() }}
  440. shell: bash
  441. run: |
  442. SUMMARY_BASE="${{ steps.extract.outputs.file_name }}"
  443. if [ -z "${SUMMARY_BASE}" ]; then
  444. SUMMARY_BASE="${{ inputs.kernel_version }}.${{ inputs.sublevel }}-${{ inputs.android_version }}-${{ inputs.os_patch_level }}"
  445. VARIANT="${{ inputs.variant }}"
  446. if [ -n "${VARIANT}" ] && [ "${VARIANT}" != "Normal" ]; then
  447. SUMMARY_BASE="${SUMMARY_BASE}-${VARIANT}"
  448. fi
  449. fi
  450. SUMMARY_FILE="/tmp/build-summary-${SUMMARY_BASE}.md"
  451. echo "SUMMARY_BASE=${SUMMARY_BASE}" >> "$GITHUB_ENV"
  452. # Determine build status
  453. if [ "${{ job.status }}" = "success" ]; then
  454. STATUS="✅ Success"
  455. else
  456. STATUS="❌ Failed"
  457. fi
  458. # Get kernel version from Image if available
  459. KERNEL_VER_STR=""
  460. if [ -f "/home/runner/out/dist/Image" ]; then
  461. KERNEL_VER_STR=$(strings "/home/runner/out/dist/Image" | grep -m1 "^Linux version " | sed 's/Linux version //' || echo "")
  462. elif [ -f "/home/runner/out/Image" ]; then
  463. KERNEL_VER_STR=$(strings "/home/runner/out/Image" | grep -m1 "^Linux version " | sed 's/Linux version //' || echo "")
  464. fi
  465. # Get KSU version from env (set by kernelsu action)
  466. KSU_VER="${KSU_VERSION:-N/A}"
  467. KSU_TAG="${KSU_GIT_TAG:-N/A}"
  468. ROOT_IMPL="${ROOT_IMPLEMENTATION:-KernelSU-Next (legacy path)}"
  469. ROOT_MANAGER="${ROOT_MANAGER:-KernelSU-Next Manager}"
  470. ROOT_VERSION="${ROOT_VERSION:-${KSU_TAG}}"
  471. ROOT_SHA="${ROOT_COMMIT:-${KSU_COMMIT:-N/A}}"
  472. NOMOUNT_SHA="${NOMOUNT_COMMIT:-${{ inputs.nomount_commit }}}"
  473. SUSFS_SHA="${SUSFS_COMMIT:-${{ inputs.susfs_commit }}}"
  474. # Get SUSFS version from susfs.h if available
  475. SUSFS_VER="N/A"
  476. if [ -f "${{ github.workspace }}/kernel/common/include/linux/susfs.h" ]; then
  477. SUSFS_VER=$(grep '#define SUSFS_VERSION' "${{ github.workspace }}/kernel/common/include/linux/susfs.h" | awk -F'"' '{print $2}' || echo "N/A")
  478. fi
  479. # Get cache stats from env (set by cache-stats action)
  480. CCACHE_HIT="${CCACHE_HIT_RATE:-N/A}"
  481. # Get build time (approximate from step timing)
  482. BUILD_TIME="N/A"
  483. # Count warnings from build log if available
  484. WARNINGS="N/A"
  485. {
  486. echo "## ${{ inputs.android_version }} ${{ inputs.kernel_version }}.${{ inputs.sublevel }} (${{ inputs.variant }}) — ${STATUS}"
  487. echo
  488. echo "| Metric | Value |"
  489. echo "|--------|-------|"
  490. echo "| **Status** | ${STATUS} |"
  491. echo "| **Kernel** | ${{ inputs.kernel_version }}.${{ inputs.sublevel }}-${{ inputs.android_version }}-${{ inputs.os_patch_level }} |"
  492. if [ -n "$KERNEL_VER_STR" ]; then
  493. echo "| **Version String** | \`${KERNEL_VER_STR}\` |"
  494. fi
  495. echo "| **KSU Version** | ${KSU_VER} |"
  496. echo "| **KSU Tag** | ${KSU_TAG} |"
  497. echo "| **Root Implementation** | ${ROOT_IMPL} |"
  498. echo "| **Root Manager** | ${ROOT_MANAGER} |"
  499. echo "| **Root Version** | ${ROOT_VERSION} |"
  500. echo "| **Root Commit** | ${ROOT_SHA} |"
  501. echo "| **SUSFS Version** | ${SUSFS_VER} |"
  502. echo "| **SUSFS Commit** | ${SUSFS_SHA} |"
  503. echo "| **NoMount Commit** | ${NOMOUNT_SHA} |"
  504. echo "| **Feature Set** | ${{ inputs.feature_set }} |"
  505. echo "| **Variant** | ${{ inputs.variant }} |"
  506. echo
  507. # Kernel Fixes
  508. if [ -f /tmp/kernel-fixes-summary.md ]; then
  509. echo "### 🔧 Kernel Fixes"
  510. cat /tmp/kernel-fixes-summary.md
  511. echo
  512. fi
  513. } > "$SUMMARY_FILE"
  514. - name: Upload Artifacts
  515. id: kernel-artifact
  516. uses: actions/upload-artifact@v7
  517. with:
  518. name: ${{ steps.extract.outputs.file_name }}-AnyKernel3
  519. path: ${{ github.workspace }}/AnyKernel3/**
  520. if-no-files-found: ignore
  521. compression-level: 9
  522. - name: Write Build-verified only artifact metadata
  523. if: ${{ success() && inputs.root_flavor != '' && inputs.nomount_commit != '' }}
  524. shell: bash
  525. env:
  526. GH_TOKEN: ${{ github.token }}
  527. run: |
  528. set -euo pipefail
  529. metadata_file="/tmp/${SUMMARY_BASE}-metadata.json"
  530. summary_file="/tmp/build-summary-${SUMMARY_BASE}.md"
  531. artifacts_api="${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}/artifacts?per_page=100"
  532. resolve_artifact() {
  533. local artifact_name="$1"
  534. local page=1
  535. local match=""
  536. local page_file
  537. page_file="$(mktemp)"
  538. # Page through the artifacts API, checking each page for the exact
  539. # artifact name. Uses a temp file for jq input (not argv) so large
  540. # artifact lists can't exceed the OS argument-length limit.
  541. while :; do
  542. curl --fail --silent --show-error --location \
  543. --header "Authorization: Bearer ${GH_TOKEN}" \
  544. --header "X-GitHub-Api-Version: 2022-11-28" \
  545. "${artifacts_api}&page=${page}" -o "$page_file"
  546. match="$(jq -r --arg name "$artifact_name" \
  547. '[.artifacts[] | select(.name == $name and .expired == false)] | .[0]
  548. | if . == null then "" else (.archive_download_url + "\t" + .digest) end' \
  549. "$page_file")"
  550. items="$(jq '(.artifacts | length) // 0' "$page_file")"
  551. if [ "$items" -lt 100 ] || [ -n "$match" ]; then
  552. break
  553. fi
  554. page=$((page + 1))
  555. done
  556. rm -f "$page_file"
  557. if [ -z "$match" ]; then
  558. echo "Expected exactly one available artifact named ${artifact_name}." >&2
  559. exit 1
  560. fi
  561. printf '%s\n' "$match"
  562. }
  563. read -r kernel_artifact_url kernel_artifact_sha256 < <(
  564. resolve_artifact "${{ steps.extract.outputs.file_name }}-AnyKernel3"
  565. )
  566. read -r nomount_module_url nomount_module_sha256 < <(
  567. resolve_artifact "NoMount-Metamodule"
  568. )
  569. jq -n \
  570. --arg method "GKI source build with SHA-pinned root implementation, SUSFS, and NoMount" \
  571. --arg root_implementation "${ROOT_IMPLEMENTATION:-KernelSU-Next (legacy path)}" \
  572. --arg root_manager "${ROOT_MANAGER:-KernelSU-Next Manager}" \
  573. --arg root_version "${ROOT_VERSION:-${KSU_GIT_TAG:-N/A}}" \
  574. --arg root_commit "${ROOT_COMMIT:-${KSU_COMMIT:-N/A}}" \
  575. --arg susfs_commit "${SUSFS_COMMIT:-N/A}" \
  576. --arg nomount_commit "${NOMOUNT_COMMIT:-N/A}" \
  577. --arg android_branch "${{ inputs.android_version }}-${{ inputs.kernel_version }}-${{ inputs.os_patch_level }}" \
  578. --arg kmi "${{ inputs.android_version }}-${{ inputs.kernel_version }}" \
  579. --arg kernel_source_commit "${KERNEL_SOURCE_COMMIT:-N/A}" \
  580. --arg provenance_url "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" \
  581. --arg artifact_url "$kernel_artifact_url" \
  582. --arg sha256 "$kernel_artifact_sha256" \
  583. --arg nomount_module_commit "${{ inputs.nomount_commit }}" \
  584. --arg nomount_module_url "$nomount_module_url" \
  585. --arg nomount_module_sha256 "$nomount_module_sha256" \
  586. --arg status "Build-verified only" \
  587. --arg catalog_availability "eligible-with-provenance-and-checksums" \
  588. --arg device_compatibility "not-validated" \
  589. --arg flashability "not-guaranteed" \
  590. --arg boot "not-guaranteed" \
  591. '{
  592. method: $method,
  593. root: {
  594. implementation: $root_implementation,
  595. manager: $root_manager,
  596. version: $root_version,
  597. commit: $root_commit
  598. },
  599. susfs_revision: $susfs_commit,
  600. nomount_commit: $nomount_commit,
  601. android_branch: $android_branch,
  602. kmi: $kmi,
  603. kernel_source_commit: $kernel_source_commit,
  604. provenance_url: $provenance_url,
  605. artifact_url: $artifact_url,
  606. sha256: $sha256,
  607. nomount_metamodule: {
  608. commit: $nomount_module_commit,
  609. artifact_url: $nomount_module_url,
  610. sha256: $nomount_module_sha256
  611. },
  612. catalog: {
  613. availability: $catalog_availability,
  614. device_compatibility: $device_compatibility,
  615. flashability: $flashability,
  616. boot: $boot
  617. },
  618. status: $status
  619. }' > "$metadata_file"
  620. jq -e '
  621. .status == "Build-verified only" and
  622. (.root.manager | length > 0) and
  623. (.root.version | length > 0) and
  624. (.susfs_revision | test("^[0-9a-f]{40}$")) and
  625. (.nomount_commit | test("^[0-9a-f]{40}$")) and
  626. (.kernel_source_commit | test("^[0-9a-f]{40}$")) and
  627. (.artifact_url | startswith("https://")) and
  628. (.sha256 | test("^sha256:[0-9a-f]{64}$")) and
  629. (.nomount_metamodule.commit == .nomount_commit) and
  630. (.nomount_metamodule.artifact_url | startswith("https://")) and
  631. (.nomount_metamodule.sha256 | test("^sha256:[0-9a-f]{64}$")) and
  632. .catalog.availability == "eligible-with-provenance-and-checksums" and
  633. .catalog.device_compatibility == "not-validated" and
  634. .catalog.flashability == "not-guaranteed" and
  635. .catalog.boot == "not-guaranteed"
  636. ' "$metadata_file" > /dev/null
  637. # Merge the verified metadata into the combined summary markdown so both
  638. # live in a single artifact: human-readable table + machine JSON block.
  639. {
  640. echo
  641. echo "## Verified Metadata"
  642. echo
  643. echo '```json'
  644. cat "$metadata_file"
  645. echo '```'
  646. echo
  647. } >> "$summary_file"
  648. - name: Upload Build Summary + Metadata
  649. uses: actions/upload-artifact@v7
  650. with:
  651. name: ${{ steps.extract.outputs.file_name }}-BuildInfo
  652. path: /tmp/build-summary-${{ env.SUMMARY_BASE }}.md
  653. if-no-files-found: warn
  654. compression-level: 9