build.yml 27 KB

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