build.yml 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685
  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: Setup KernelSU-Next (legacy)
  174. if: ${{ inputs.root_flavor == '' }}
  175. uses: ./.github/actions/kernelsu
  176. with:
  177. ksu_branch: ${{ inputs.ksu_branch }}
  178. - name: Verify root ABI/KMI safeguards
  179. if: ${{ inputs.preserve_abi }}
  180. uses: ./.github/actions/abi-kmi-safeguards
  181. with:
  182. mode: verify
  183. - name: SUSFS
  184. if: contains(inputs.feature_set, 'SUSFS') || inputs.feature_set == 'All'
  185. uses: ./.github/actions/susfs
  186. with:
  187. susfs_commit: ${{ inputs.susfs_commit }}
  188. version: ${{ inputs.version }}
  189. android_version: ${{ inputs.android_version }}
  190. kernel_version: ${{ inputs.kernel_version }}
  191. os_patch_level: ${{ inputs.os_patch_level }}
  192. sublevel: ${{ steps.extract.outputs.sublevel }}
  193. root_flavor: ${{ inputs.root_flavor }}
  194. - name: Baseband Guard
  195. if: (contains(inputs.feature_set, 'BBG') || inputs.feature_set == 'All')
  196. uses: ./.github/actions/bbg
  197. - name: Setup Networking
  198. if: contains(inputs.feature_set, 'NET') || inputs.feature_set == 'All'
  199. uses: ./.github/actions/networking
  200. with:
  201. version: ${{ inputs.version }}
  202. kernel_version: ${{ inputs.kernel_version }}
  203. android_version: ${{ inputs.android_version }}
  204. sublevel: ${{ steps.extract.outputs.sublevel }}
  205. - name: DroidSpaces-OSS Patches
  206. if: contains(inputs.feature_set, 'DS') || inputs.feature_set == 'All'
  207. uses: ./.github/actions/droidspaces
  208. with:
  209. version: ${{ inputs.version }}
  210. kernel_version: ${{ inputs.kernel_version }}
  211. droidspaces_commit: ${{ inputs.droidspaces_commit }}
  212. - name: Apply NTSync Patches
  213. if: contains(inputs.feature_set, 'NTSync')
  214. uses: ./.github/actions/ntsync
  215. with:
  216. version: ${{ inputs.version }}
  217. kernel_version: ${{ inputs.kernel_version }}
  218. sublevel: ${{ steps.extract.outputs.sublevel }}
  219. - name: Apply Ptrace Patch
  220. if: contains(inputs.feature_set, 'Ptrace')
  221. uses: ./.github/actions/ptrace
  222. with:
  223. kernel_version: ${{ inputs.kernel_version }}
  224. - name: Apply Unicode Fix Patch
  225. if: contains(inputs.feature_set, 'Unicode')
  226. uses: ./.github/actions/unicode-fix
  227. with:
  228. kernel_version: ${{ inputs.kernel_version }}
  229. - name: Apply Performance Patches
  230. uses: ./.github/actions/performance
  231. if: contains(inputs.feature_set, 'Perf')
  232. with:
  233. kernel_version: ${{ inputs.kernel_version }}
  234. - name: Setup Misc Configs
  235. uses: ./.github/actions/misc
  236. - name: Enable BPF Stack (BTF + eBPF + FUSE-BPF)
  237. if: contains(inputs.feature_set, 'BPF')
  238. uses: ./.github/actions/btf
  239. with:
  240. version: ${{ inputs.version }}
  241. kernel_version: ${{ inputs.kernel_version }}
  242. sublevel: ${{ steps.extract.outputs.sublevel }}
  243. - name: Apply Device-Specific Patches
  244. uses: ./.github/actions/apply-device-patches
  245. with:
  246. version: ${{ inputs.version }}
  247. kernel_version: ${{ inputs.kernel_version }}
  248. - name: Capture approved feature ABI/KMI baseline
  249. if: ${{ inputs.preserve_abi }}
  250. uses: ./.github/actions/abi-kmi-safeguards
  251. with:
  252. mode: capture
  253. - name: Integrate NoMount
  254. if: ${{ inputs.nomount_commit != '' || contains(inputs.feature_set, 'NoMount') || inputs.feature_set == 'All' }}
  255. uses: ./.github/actions/nomount
  256. with:
  257. commit: ${{ inputs.nomount_commit }}
  258. kernel_version: ${{ inputs.kernel_version }}
  259. - name: Apply ABI Compare Bypass
  260. if: false
  261. working-directory: ${{ github.workspace }}/kernel
  262. run: |
  263. # ABI compare bypass per kernel/android version
  264. # Edit each block as needed per version
  265. if [[ "$ANDROID_VERSION" == "android12" && "$KERNEL_VERSION" == "5.10" ]]; then
  266. sed -i 's/^\s*exit 1$/ echo "Who Cares? Bypassing Now!"/' build/abi/compare_to_symbol_list
  267. elif [[ "$ANDROID_VERSION" == "android13" && "$KERNEL_VERSION" == "5.10" ]]; then
  268. sed -i 's/^\s*exit 1$/ echo "Who Cares? Bypassing Now!"/' build/kernel/abi/compare_to_symbol_list
  269. elif [[ "$ANDROID_VERSION" == "android13" && "$KERNEL_VERSION" == "5.15" ]]; then
  270. sed -i 's/^\s*exit 1$/ echo "Who Cares? Bypassing Now!"/' build/kernel/abi/compare_to_symbol_list
  271. elif [[ "$ANDROID_VERSION" == "android14" && "$KERNEL_VERSION" == "5.15" ]]; then
  272. 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
  273. elif [[ "$ANDROID_VERSION" == "android14" && "$KERNEL_VERSION" == "6.1" ]]; then
  274. 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
  275. elif [[ "$ANDROID_VERSION" == "android15" && "$KERNEL_VERSION" == "6.6" ]]; then
  276. 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
  277. fi
  278. - name: Apply Kernel Branding
  279. uses: ./.github/actions/apply-kernel-branding
  280. with:
  281. variant: ${{ inputs.variant }}
  282. kernel_version: ${{ inputs.kernel_version }}
  283. android_version: ${{ inputs.android_version }}
  284. version: ${{ inputs.version }}
  285. sublevel: ${{ steps.extract.outputs.sublevel }}
  286. brand_name: ${{ inputs.brand_name }}
  287. - name: Remove Protected Exports
  288. if: ${{ !inputs.preserve_abi }}
  289. uses: ./.github/actions/remove-protected-exports
  290. - name: Verify NoMount ABI/KMI safeguards
  291. if: ${{ inputs.preserve_abi }}
  292. uses: ./.github/actions/abi-kmi-safeguards
  293. with:
  294. mode: verify
  295. - name: Clean Kernel Flags
  296. uses: ./.github/actions/clean-kernel-flags
  297. - name: Scan and collect patch rejects
  298. id: scan
  299. if: ${{ always() }}
  300. uses: ./.github/actions/scan-patch-rejects
  301. - name: Upload Rejects
  302. if: ${{ always() }}
  303. uses: actions/upload-artifact@v7
  304. with:
  305. name: ${{ steps.extract.outputs.file_name }}-Rejects
  306. path: patch-rejects/
  307. if-no-files-found: ignore
  308. compression-level: 9
  309. - name: Get prebuilt ccache (downloaded once by prepare-ccache)
  310. if: false
  311. uses: actions/download-artifact@v8
  312. with:
  313. name: ccache-binary
  314. path: ccache-dl
  315. continue-on-error: true
  316. - name: 'Setup Cache and Build Environment'
  317. uses: ./.github/actions/cache-setup
  318. with:
  319. version: ${{ inputs.version }}
  320. android_version: ${{ inputs.android_version }}
  321. kernel_version: ${{ inputs.kernel_version }}
  322. sublevel: ${{ steps.extract.outputs.sublevel }}
  323. - name: Restore ccache
  324. id: restore-ccache
  325. continue-on-error: true
  326. if: false && (inputs.version == 'android12-5.10' || inputs.version == 'android13-5.10' || inputs.version == 'android13-5.15')
  327. uses: ./.github/actions/cache-restore
  328. with:
  329. cache_path: /home/runner/.ccache
  330. cache_key: ${{ inputs.android_version }}-${{ inputs.kernel_version }}.${{ steps.extract.outputs.sublevel }}-${{ inputs.os_patch_level }}
  331. cache_bucket: ccache-cache
  332. restore_keys: |
  333. ${{ inputs.android_version }}-${{ inputs.kernel_version }}.${{ steps.extract.outputs.sublevel }}-
  334. - name: Restore bazel-cache
  335. id: restore-bazel
  336. continue-on-error: true
  337. if: false && (inputs.version == 'android14-5.15' || inputs.version == 'android14-6.1' || inputs.version == 'android15-6.6' || inputs.version == 'android16-6.12')
  338. uses: ./.github/actions/cache-restore
  339. with:
  340. cache_path: /home/runner/.cache/bazel
  341. cache_key: ${{ inputs.android_version }}-${{ inputs.kernel_version }}.${{ steps.extract.outputs.sublevel }}-${{ inputs.os_patch_level }}
  342. cache_bucket: bazel-cache
  343. restore_keys: |
  344. ${{ inputs.android_version }}-${{ inputs.kernel_version }}.${{ steps.extract.outputs.sublevel }}-
  345. - name: Cache ccache (GitHub Native)
  346. if: false
  347. uses: actions/cache@v6
  348. with:
  349. path: /home/runner/.ccache
  350. key: ccache-${{ inputs.android_version }}-${{ inputs.kernel_version }}.${{ steps.extract.outputs.sublevel }}-${{ inputs.os_patch_level }}
  351. restore-keys: |
  352. ccache-${{ inputs.android_version }}-${{ inputs.kernel_version }}.${{ steps.extract.outputs.sublevel }}-
  353. ccache-${{ inputs.android_version }}-${{ inputs.kernel_version }}-
  354. ccache-
  355. - name: Cache bazel-cache (GitHub Native)
  356. if: false
  357. uses: actions/cache@v6
  358. with:
  359. path: /home/runner/.cache/bazel
  360. key: bazel-${{ inputs.android_version }}-${{ inputs.kernel_version }}.${{ steps.extract.outputs.sublevel }}-${{ inputs.os_patch_level }}
  361. restore-keys: |
  362. bazel-${{ inputs.android_version }}-${{ inputs.kernel_version }}.${{ steps.extract.outputs.sublevel }}-
  363. bazel-${{ inputs.android_version }}-${{ inputs.kernel_version }}-
  364. bazel-
  365. - name: Check cache hit
  366. run: |
  367. echo "Cache restore status:"
  368. CCACHE_HIT="${{ steps.restore-ccache.outputs.cache-hit || 'skipped' }}"
  369. BAZEL_HIT="${{ steps.restore-bazel.outputs.cache-hit || 'skipped' }}"
  370. echo " ccache: $CCACHE_HIT"
  371. echo " bazel: $BAZEL_HIT"
  372. - name: Get Cache Stats
  373. uses: ./.github/actions/cache-stats
  374. with:
  375. clear_stats: true
  376. - name: Initialize Config Fragment
  377. run: touch "${{ github.workspace }}/wild_gki.fragment"
  378. - name: Build Normal Kernel
  379. env:
  380. SOURCE_DATE_EPOCH: ${{ env.SOURCE_DATE_EPOCH }}
  381. KBUILD_BUILD_TIMESTAMP: ${{ env.KBUILD_BUILD_TIMESTAMP }}
  382. uses: ./.github/actions/build-kernel
  383. with:
  384. version: ${{ inputs.version }}
  385. bypass: false
  386. - name: Get Cache Stats
  387. uses: ./.github/actions/cache-stats
  388. with:
  389. clear_stats: false
  390. - name: Save ccache
  391. continue-on-error: true
  392. uses: ./.github/actions/cache-save
  393. if: false && (inputs.version == 'android12-5.10' || inputs.version == 'android13-5.10' || inputs.version == 'android13-5.15')
  394. with:
  395. cache_path: /home/runner/.ccache
  396. cache_key: ${{ inputs.android_version }}-${{ inputs.kernel_version }}.${{ steps.extract.outputs.sublevel }}-${{ inputs.os_patch_level }}
  397. cache_bucket: "ccache-cache"
  398. compression_level: 9
  399. github_token: ${{ secrets.MY_GITHUB_TOKEN }}
  400. - name: Save bazel-cache
  401. continue-on-error: true
  402. uses: ./.github/actions/cache-save
  403. if: false && (inputs.version == 'android14-5.15' || inputs.version == 'android14-6.1' || inputs.version == 'android15-6.6' || inputs.version == 'android16-6.12')
  404. with:
  405. cache_path: /home/runner/.cache/bazel
  406. cache_key: ${{ inputs.android_version }}-${{ inputs.kernel_version }}.${{ steps.extract.outputs.sublevel }}-${{ inputs.os_patch_level }}
  407. cache_bucket: "bazel-cache"
  408. compression_level: 9
  409. github_token: ${{ secrets.MY_GITHUB_TOKEN }}
  410. - name: Build Bypass Kernel
  411. if: ${{ inputs.build_bypass }}
  412. env:
  413. SOURCE_DATE_EPOCH: ${{ env.SOURCE_DATE_EPOCH }}
  414. KBUILD_BUILD_TIMESTAMP: ${{ env.KBUILD_BUILD_TIMESTAMP }}
  415. uses: ./.github/actions/build-kernel
  416. with:
  417. bypass: true
  418. version: ${{ inputs.version }}
  419. - name: 📋 Consolidated Build Summary
  420. if: ${{ always() }}
  421. shell: bash
  422. run: |
  423. SUMMARY_BASE="${{ steps.extract.outputs.file_name }}"
  424. if [ -z "${SUMMARY_BASE}" ]; then
  425. SUMMARY_BASE="${{ inputs.kernel_version }}.${{ inputs.sublevel }}-${{ inputs.android_version }}-${{ inputs.os_patch_level }}"
  426. VARIANT="${{ inputs.variant }}"
  427. if [ -n "${VARIANT}" ] && [ "${VARIANT}" != "Normal" ]; then
  428. SUMMARY_BASE="${SUMMARY_BASE}-${VARIANT}"
  429. fi
  430. fi
  431. SUMMARY_FILE="/tmp/build-summary-${SUMMARY_BASE}.md"
  432. echo "SUMMARY_BASE=${SUMMARY_BASE}" >> "$GITHUB_ENV"
  433. # Determine build status
  434. if [ "${{ job.status }}" = "success" ]; then
  435. STATUS="✅ Success"
  436. else
  437. STATUS="❌ Failed"
  438. fi
  439. # Get kernel version from Image if available
  440. KERNEL_VER_STR=""
  441. if [ -f "/home/runner/out/dist/Image" ]; then
  442. KERNEL_VER_STR=$(strings "/home/runner/out/dist/Image" | grep -m1 "^Linux version " | sed 's/Linux version //' || echo "")
  443. elif [ -f "/home/runner/out/Image" ]; then
  444. KERNEL_VER_STR=$(strings "/home/runner/out/Image" | grep -m1 "^Linux version " | sed 's/Linux version //' || echo "")
  445. fi
  446. # Get KSU version from env (set by kernelsu action)
  447. KSU_VER="${KSU_VERSION:-N/A}"
  448. KSU_TAG="${KSU_GIT_TAG:-N/A}"
  449. ROOT_IMPL="${ROOT_IMPLEMENTATION:-KernelSU-Next (legacy path)}"
  450. ROOT_MANAGER="${ROOT_MANAGER:-KernelSU-Next Manager}"
  451. ROOT_VERSION="${ROOT_VERSION:-${KSU_TAG}}"
  452. ROOT_SHA="${ROOT_COMMIT:-${KSU_COMMIT:-N/A}}"
  453. NOMOUNT_SHA="${NOMOUNT_COMMIT:-${{ inputs.nomount_commit }}}"
  454. SUSFS_SHA="${SUSFS_COMMIT:-${{ inputs.susfs_commit }}}"
  455. # Get SUSFS version from susfs.h if available
  456. SUSFS_VER="N/A"
  457. if [ -f "${{ github.workspace }}/kernel/common/include/linux/susfs.h" ]; then
  458. SUSFS_VER=$(grep '#define SUSFS_VERSION' "${{ github.workspace }}/kernel/common/include/linux/susfs.h" | awk -F'"' '{print $2}' || echo "N/A")
  459. fi
  460. # Get cache stats from env (set by cache-stats action)
  461. CCACHE_HIT="${CCACHE_HIT_RATE:-N/A}"
  462. # Get build time (approximate from step timing)
  463. BUILD_TIME="N/A"
  464. # Count warnings from build log if available
  465. WARNINGS="N/A"
  466. {
  467. echo "## ${{ inputs.android_version }} ${{ inputs.kernel_version }}.${{ inputs.sublevel }} (${{ inputs.variant }}) — ${STATUS}"
  468. echo
  469. echo "| Metric | Value |"
  470. echo "|--------|-------|"
  471. echo "| **Status** | ${STATUS} |"
  472. echo "| **Kernel** | ${{ inputs.kernel_version }}.${{ inputs.sublevel }}-${{ inputs.android_version }}-${{ inputs.os_patch_level }} |"
  473. if [ -n "$KERNEL_VER_STR" ]; then
  474. echo "| **Version String** | \`${KERNEL_VER_STR}\` |"
  475. fi
  476. echo "| **KSU Version** | ${KSU_VER} |"
  477. echo "| **KSU Tag** | ${KSU_TAG} |"
  478. echo "| **Root Implementation** | ${ROOT_IMPL} |"
  479. echo "| **Root Manager** | ${ROOT_MANAGER} |"
  480. echo "| **Root Version** | ${ROOT_VERSION} |"
  481. echo "| **Root Commit** | ${ROOT_SHA} |"
  482. echo "| **SUSFS Version** | ${SUSFS_VER} |"
  483. echo "| **SUSFS Commit** | ${SUSFS_SHA} |"
  484. echo "| **NoMount Commit** | ${NOMOUNT_SHA} |"
  485. echo "| **Feature Set** | ${{ inputs.feature_set }} |"
  486. echo "| **Variant** | ${{ inputs.variant }} |"
  487. echo
  488. # Kernel Fixes
  489. if [ -f /tmp/kernel-fixes-summary.md ]; then
  490. echo "### 🔧 Kernel Fixes"
  491. cat /tmp/kernel-fixes-summary.md
  492. echo
  493. fi
  494. } > "$SUMMARY_FILE"
  495. - name: Upload Build Summary Artifact
  496. if: ${{ always() }}
  497. uses: actions/upload-artifact@v7
  498. with:
  499. name: ${{ env.SUMMARY_BASE }}-Summary
  500. path: /tmp/build-summary-${{ env.SUMMARY_BASE }}.md
  501. if-no-files-found: ignore
  502. compression-level: 9
  503. - name: Upload Artifacts
  504. id: kernel-artifact
  505. uses: actions/upload-artifact@v7
  506. with:
  507. name: ${{ steps.extract.outputs.file_name }}-AnyKernel3
  508. path: ${{ github.workspace }}/AnyKernel3/**
  509. if-no-files-found: ignore
  510. compression-level: 9
  511. - name: Write Build-verified only artifact metadata
  512. if: ${{ success() && inputs.root_flavor != '' && inputs.nomount_commit != '' }}
  513. shell: bash
  514. env:
  515. GH_TOKEN: ${{ github.token }}
  516. run: |
  517. set -euo pipefail
  518. metadata_file="${{ github.workspace }}/${{ steps.extract.outputs.file_name }}-metadata.json"
  519. artifacts_api="${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}/artifacts?per_page=100"
  520. artifacts_json="$(curl --fail --silent --show-error \
  521. --header "Authorization: Bearer ${GH_TOKEN}" \
  522. --header "X-GitHub-Api-Version: 2022-11-28" \
  523. "$artifacts_api")"
  524. resolve_artifact() {
  525. local artifact_name="$1"
  526. local matches
  527. matches="$(jq --arg name "$artifact_name" \
  528. '[.artifacts[] | select(.name == $name and .expired == false)]' \
  529. <<<"$artifacts_json")"
  530. if [ "$(jq 'length' <<<"$matches")" -ne 1 ]; then
  531. echo "Expected exactly one available artifact named ${artifact_name}." >&2
  532. exit 1
  533. fi
  534. jq -r '.[0] | [.archive_download_url, .digest] | @tsv' <<<"$matches"
  535. }
  536. read -r kernel_artifact_url kernel_artifact_sha256 < <(
  537. resolve_artifact "${{ steps.extract.outputs.file_name }}-AnyKernel3"
  538. )
  539. read -r nomount_module_url nomount_module_sha256 < <(
  540. resolve_artifact "NoMount-Metamodule"
  541. )
  542. jq -n \
  543. --arg method "GKI source build with SHA-pinned root implementation, SUSFS, and NoMount" \
  544. --arg root_implementation "${ROOT_IMPLEMENTATION:-KernelSU-Next (legacy path)}" \
  545. --arg root_manager "${ROOT_MANAGER:-KernelSU-Next Manager}" \
  546. --arg root_version "${ROOT_VERSION:-${KSU_GIT_TAG:-N/A}}" \
  547. --arg root_commit "${ROOT_COMMIT:-${KSU_COMMIT:-N/A}}" \
  548. --arg susfs_commit "${SUSFS_COMMIT:-N/A}" \
  549. --arg nomount_commit "${NOMOUNT_COMMIT:-N/A}" \
  550. --arg android_branch "${{ inputs.android_version }}-${{ inputs.kernel_version }}-${{ inputs.os_patch_level }}" \
  551. --arg kmi "${{ inputs.android_version }}-${{ inputs.kernel_version }}" \
  552. --arg kernel_source_commit "${KERNEL_SOURCE_COMMIT:-N/A}" \
  553. --arg provenance_url "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" \
  554. --arg artifact_url "$kernel_artifact_url" \
  555. --arg sha256 "$kernel_artifact_sha256" \
  556. --arg nomount_module_commit "${{ inputs.nomount_commit }}" \
  557. --arg nomount_module_url "$nomount_module_url" \
  558. --arg nomount_module_sha256 "$nomount_module_sha256" \
  559. --arg status "Build-verified only" \
  560. --arg catalog_availability "eligible-with-provenance-and-checksums" \
  561. --arg device_compatibility "not-validated" \
  562. --arg flashability "not-guaranteed" \
  563. --arg boot "not-guaranteed" \
  564. '{
  565. method: $method,
  566. root: {
  567. implementation: $root_implementation,
  568. manager: $root_manager,
  569. version: $root_version,
  570. commit: $root_commit
  571. },
  572. susfs_revision: $susfs_commit,
  573. nomount_commit: $nomount_commit,
  574. android_branch: $android_branch,
  575. kmi: $kmi,
  576. kernel_source_commit: $kernel_source_commit,
  577. provenance_url: $provenance_url,
  578. artifact_url: $artifact_url,
  579. sha256: $sha256,
  580. nomount_metamodule: {
  581. commit: $nomount_module_commit,
  582. artifact_url: $nomount_module_url,
  583. sha256: $nomount_module_sha256
  584. },
  585. catalog: {
  586. availability: $catalog_availability,
  587. device_compatibility: $device_compatibility,
  588. flashability: $flashability,
  589. boot: $boot
  590. },
  591. status: $status
  592. }' > "$metadata_file"
  593. jq -e '
  594. .status == "Build-verified only" and
  595. (.root.manager | length > 0) and
  596. (.root.version | length > 0) and
  597. (.susfs_revision | test("^[0-9a-f]{40}$")) and
  598. (.nomount_commit | test("^[0-9a-f]{40}$")) and
  599. (.kernel_source_commit | test("^[0-9a-f]{40}$")) and
  600. (.artifact_url | startswith("https://")) and
  601. (.sha256 | test("^sha256:[0-9a-f]{64}$")) and
  602. (.nomount_metamodule.commit == .nomount_commit) and
  603. (.nomount_metamodule.artifact_url | startswith("https://")) and
  604. (.nomount_metamodule.sha256 | test("^sha256:[0-9a-f]{64}$")) and
  605. .catalog.availability == "eligible-with-provenance-and-checksums" and
  606. .catalog.device_compatibility == "not-validated" and
  607. .catalog.flashability == "not-guaranteed" and
  608. .catalog.boot == "not-guaranteed"
  609. ' "$metadata_file" > /dev/null
  610. - name: Upload Build-verified only artifact metadata
  611. if: ${{ success() && inputs.root_flavor != '' && inputs.nomount_commit != '' }}
  612. uses: actions/upload-artifact@v7
  613. with:
  614. name: ${{ steps.extract.outputs.file_name }}-Metadata
  615. path: ${{ github.workspace }}/${{ steps.extract.outputs.file_name }}-metadata.json
  616. if-no-files-found: error
  617. compression-level: 9