build.yml 27 KB

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