build.yml 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695
  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. build_bypass:
  66. required: false
  67. type: boolean
  68. default: true
  69. jobs:
  70. build-gki:
  71. name: "${{ inputs.kernel_version }}.${{ inputs.sublevel }}-${{ inputs.android_version }}-${{ inputs.os_patch_level }} (${{ inputs.variant }})"
  72. runs-on: ubuntu-latest
  73. timeout-minutes: 120
  74. steps:
  75. - name: Checkout Repository
  76. uses: actions/checkout@v7
  77. - name: 🧹 Emergency Disk Cleanup
  78. if: false
  79. uses: ./.github/actions/disk-cleanup
  80. - name: Free Disk Space
  81. if: true
  82. uses: endersonmenezes/free-disk-space@v3 # Use @main for latest, @v3 for stable
  83. with:
  84. remove_android: true
  85. remove_dotnet: true
  86. remove_haskell: true
  87. remove_tool_cache: true
  88. remove_packages: "azure-cli google-cloud-cli microsoft-edge-stable google-chrome-stable firefox postgresql* temurin-* *llvm* mysql* dotnet-sdk-*"
  89. remove_packages_one_command: true
  90. 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"
  91. rm_cmd: "rmz" # Use 'rmz' for faster deletion (default: 'rm')
  92. rmz_version: "3.1.1" # Required when rm_cmd is 'rmz'
  93. testing: false
  94. - name: Setup more Swap (for LTO)
  95. uses: thejerrybao/setup-swap-space@v1 # or pierotofy/set-swap-space
  96. with:
  97. swap-size-gb: 16 # 10-24 GB is common for heavy LTO
  98. # swap-space-path: /mnt/swapfile # optional
  99. - name: Setup Build Environment
  100. uses: ./.github/actions/setup-build-environment
  101. with:
  102. version: ${{ inputs.version }}
  103. sublevel: ${{ inputs.sublevel }}
  104. kernel_patches_commit: ${{ inputs.kernel_patches_commit }}
  105. anykernel3_commit: ${{ inputs.anykernel3_commit }}
  106. env:
  107. BOOT_SIGN_KEY: ${{ secrets.BOOT_SIGN_KEY }}
  108. - name: Download Kernel Repository
  109. uses: ./.github/actions/download-kernel
  110. with:
  111. version: ${{ inputs.version }}
  112. android_version: ${{ inputs.android_version }}
  113. kernel_version: ${{ inputs.kernel_version }}
  114. os_patch_level: ${{ inputs.os_patch_level }}
  115. - name: Set Build Timestamp from Kernel Commit
  116. shell: bash
  117. run: |
  118. set -x
  119. # Hardcode the build timestamp to the 5th day of the patch level
  120. # at 04:20 UTC, using the existing timestamp formats expected by the build.
  121. OS_PATCH_LEVEL_INPUT="${{ inputs.os_patch_level }}"
  122. if [[ "$OS_PATCH_LEVEL_INPUT" == lts* ]]; then
  123. if [[ "$OS_PATCH_LEVEL_INPUT" =~ ^lts-([0-9]{2})$ ]]; then
  124. OS_PATCH_LEVEL_YM="$(date -u +%Y)-${BASH_REMATCH[1]}"
  125. else
  126. OS_PATCH_LEVEL_YM="$(date -u +%Y-%m)"
  127. fi
  128. else
  129. OS_PATCH_LEVEL_YM="$OS_PATCH_LEVEL_INPUT"
  130. fi
  131. FIXED_BUILD_DATE="${OS_PATCH_LEVEL_YM}-05 04:20:00 UTC"
  132. SOURCE_DATE_EPOCH=$(date -u -d "$FIXED_BUILD_DATE" +%s)
  133. echo "SOURCE_DATE_EPOCH=$SOURCE_DATE_EPOCH" >> $GITHUB_ENV
  134. KBUILD_TS=$(date -u -d @${SOURCE_DATE_EPOCH} '+%a %b %d %H:%M:%S UTC %Y')
  135. echo "KBUILD_BUILD_TIMESTAMP=${KBUILD_TS}" >> $GITHUB_ENV
  136. # Keep git metadata aligned with the same fixed timestamp.
  137. GIT_DATE=$(date -u -d @${SOURCE_DATE_EPOCH} '+%Y-%m-%dT%H:%M:%SZ')
  138. echo "GIT_COMMITTER_DATE=${GIT_DATE}" >> $GITHUB_ENV
  139. echo "GIT_AUTHOR_DATE=${GIT_DATE}" >> $GITHUB_ENV
  140. echo "Build timestamp set to: $(date -u -d @${SOURCE_DATE_EPOCH} '+%Y-%m-%d %H:%M:%S UTC') (epoch: $SOURCE_DATE_EPOCH)"
  141. - name: Extract Sublevel and Set File Name
  142. id: extract
  143. uses: ./.github/actions/extract-sublevel-file-name
  144. with:
  145. android_version: ${{ inputs.android_version }}
  146. kernel_version: ${{ inputs.kernel_version }}
  147. sublevel: ${{ inputs.sublevel }}
  148. os_patch_level: ${{ inputs.os_patch_level }}
  149. variant: ${{ inputs.variant }}
  150. - name: Kernel Fixes
  151. uses: ./.github/actions/kernel-fixes
  152. with:
  153. version: ${{ inputs.version }}
  154. android_version: ${{ inputs.android_version }}
  155. kernel_version: ${{ inputs.kernel_version }}
  156. sublevel: ${{ steps.extract.outputs.sublevel }}
  157. os_patch_level: ${{ inputs.os_patch_level }}
  158. - name: Setup Selected Root Implementation
  159. if: ${{ inputs.root_flavor != '' }}
  160. uses: ./.github/actions/root-setup
  161. with:
  162. flavor: ${{ inputs.root_flavor }}
  163. commit: ${{ inputs.root_commit }}
  164. - name: Disable SUSFS for ReSukiSU without SUSFS feature
  165. if: ${{ inputs.root_flavor == 'resukisu' && !contains(inputs.feature_set, 'SUSFS') }}
  166. uses: ./.github/actions/set-kernel-config
  167. with:
  168. config_list: |
  169. CONFIG_KSU_SUSFS=n
  170. - name: Resolve SUSFS commit
  171. id: susfs-cm
  172. shell: bash
  173. run: |
  174. set -euo pipefail
  175. # KernelSU-Next (next) always uses the latest susfs4ksu gki branch tip so
  176. # SUSFS stays API-matched to the always-latest KernelSU-Next tree. All
  177. # other roots (kernelsu, resukisu) use the pinned verified SUSFS commit.
  178. if [ "${{ inputs.root_flavor }}" = "next" ]; then
  179. BRANCH="gki-${{ inputs.android_version }}-${{ inputs.kernel_version }}"
  180. SUSFS_COMMIT="$(git ls-remote https://gitlab.com/simonpunk/susfs4ksu.git "refs/heads/${BRANCH}" | cut -f1)"
  181. echo "KernelSU-Next: resolving SUSFS at latest on ${BRANCH} -> ${SUSFS_COMMIT}"
  182. else
  183. SUSFS_COMMIT="${{ inputs.susfs_commit }}"
  184. echo "Using pinned SUSFS commit: ${SUSFS_COMMIT}"
  185. fi
  186. echo "commit=${SUSFS_COMMIT}" >> "$GITHUB_OUTPUT"
  187. - name: SUSFS
  188. if: contains(inputs.feature_set, 'SUSFS') || inputs.feature_set == 'All'
  189. uses: ./.github/actions/susfs
  190. with:
  191. susfs_commit: ${{ steps.susfs-cm.outputs.commit }}
  192. version: ${{ inputs.version }}
  193. android_version: ${{ inputs.android_version }}
  194. kernel_version: ${{ inputs.kernel_version }}
  195. os_patch_level: ${{ inputs.os_patch_level }}
  196. sublevel: ${{ steps.extract.outputs.sublevel }}
  197. root_flavor: ${{ inputs.root_flavor }}
  198. nomount_enabled: ${{ contains(inputs.feature_set, 'NoMount') }}
  199. - name: Baseband Guard
  200. if: (contains(inputs.feature_set, 'BBG') || inputs.feature_set == 'All')
  201. uses: ./.github/actions/bbg
  202. - name: Setup Networking
  203. if: contains(inputs.feature_set, 'NET') || inputs.feature_set == 'All'
  204. uses: ./.github/actions/networking
  205. with:
  206. version: ${{ inputs.version }}
  207. kernel_version: ${{ inputs.kernel_version }}
  208. android_version: ${{ inputs.android_version }}
  209. sublevel: ${{ steps.extract.outputs.sublevel }}
  210. - name: DroidSpaces-OSS Patches
  211. if: contains(inputs.feature_set, 'DS') || inputs.feature_set == 'All'
  212. uses: ./.github/actions/droidspaces
  213. with:
  214. version: ${{ inputs.version }}
  215. kernel_version: ${{ inputs.kernel_version }}
  216. droidspaces_commit: ${{ inputs.droidspaces_commit }}
  217. - name: Apply NTSync Patches
  218. if: contains(inputs.feature_set, 'NTSync')
  219. uses: ./.github/actions/ntsync
  220. with:
  221. version: ${{ inputs.version }}
  222. kernel_version: ${{ inputs.kernel_version }}
  223. sublevel: ${{ steps.extract.outputs.sublevel }}
  224. - name: Apply Ptrace Patch
  225. if: contains(inputs.feature_set, 'Ptrace')
  226. uses: ./.github/actions/ptrace
  227. with:
  228. kernel_version: ${{ inputs.kernel_version }}
  229. - name: Apply Unicode Fix Patch
  230. if: contains(inputs.feature_set, 'Unicode')
  231. uses: ./.github/actions/unicode-fix
  232. with:
  233. kernel_version: ${{ inputs.kernel_version }}
  234. - name: Apply Performance Patches
  235. uses: ./.github/actions/performance
  236. if: contains(inputs.feature_set, 'Perf')
  237. with:
  238. kernel_version: ${{ inputs.kernel_version }}
  239. - name: Setup Misc Configs
  240. uses: ./.github/actions/misc
  241. - name: Enable BPF Stack (BTF + eBPF + FUSE-BPF)
  242. if: contains(inputs.feature_set, 'BPF')
  243. uses: ./.github/actions/btf
  244. with:
  245. version: ${{ inputs.version }}
  246. kernel_version: ${{ inputs.kernel_version }}
  247. sublevel: ${{ steps.extract.outputs.sublevel }}
  248. - name: Apply Device-Specific Patches
  249. uses: ./.github/actions/apply-device-patches
  250. with:
  251. version: ${{ inputs.version }}
  252. kernel_version: ${{ inputs.kernel_version }}
  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: Clean Kernel Flags
  288. uses: ./.github/actions/clean-kernel-flags
  289. - name: Scan and collect patch rejects
  290. id: scan
  291. if: ${{ always() }}
  292. uses: ./.github/actions/scan-patch-rejects
  293. - name: Upload Rejects
  294. if: ${{ always() }}
  295. uses: actions/upload-artifact@v7
  296. with:
  297. name: ${{ steps.extract.outputs.file_name }}-Rejects
  298. path: patch-rejects/
  299. if-no-files-found: ignore
  300. compression-level: 9
  301. - name: Get prebuilt ccache (downloaded once by prepare-ccache)
  302. if: false
  303. uses: actions/download-artifact@v8
  304. with:
  305. name: ccache-binary
  306. path: ccache-dl
  307. continue-on-error: true
  308. - name: 'Setup Cache and Build Environment'
  309. uses: ./.github/actions/cache-setup
  310. with:
  311. version: ${{ inputs.version }}
  312. android_version: ${{ inputs.android_version }}
  313. kernel_version: ${{ inputs.kernel_version }}
  314. sublevel: ${{ steps.extract.outputs.sublevel }}
  315. - name: Restore ccache
  316. id: restore-ccache
  317. continue-on-error: true
  318. if: false && (inputs.version == 'android12-5.10' || inputs.version == 'android13-5.10' || inputs.version == 'android13-5.15')
  319. uses: ./.github/actions/cache-restore
  320. with:
  321. cache_path: /home/runner/.ccache
  322. cache_key: ${{ inputs.android_version }}-${{ inputs.kernel_version }}.${{ steps.extract.outputs.sublevel }}-${{ inputs.os_patch_level }}
  323. cache_bucket: ccache-cache
  324. restore_keys: |
  325. ${{ inputs.android_version }}-${{ inputs.kernel_version }}.${{ steps.extract.outputs.sublevel }}-
  326. - name: Restore bazel-cache
  327. id: restore-bazel
  328. continue-on-error: true
  329. if: false && (inputs.version == 'android14-5.15' || inputs.version == 'android14-6.1' || inputs.version == 'android15-6.6' || inputs.version == 'android16-6.12')
  330. uses: ./.github/actions/cache-restore
  331. with:
  332. cache_path: /home/runner/.cache/bazel
  333. cache_key: ${{ inputs.android_version }}-${{ inputs.kernel_version }}.${{ steps.extract.outputs.sublevel }}-${{ inputs.os_patch_level }}
  334. cache_bucket: bazel-cache
  335. restore_keys: |
  336. ${{ inputs.android_version }}-${{ inputs.kernel_version }}.${{ steps.extract.outputs.sublevel }}-
  337. - name: Cache ccache (GitHub Native)
  338. if: false
  339. uses: actions/cache@v6
  340. with:
  341. path: /home/runner/.ccache
  342. key: ccache-${{ inputs.android_version }}-${{ inputs.kernel_version }}.${{ steps.extract.outputs.sublevel }}-${{ inputs.os_patch_level }}
  343. restore-keys: |
  344. ccache-${{ inputs.android_version }}-${{ inputs.kernel_version }}.${{ steps.extract.outputs.sublevel }}-
  345. ccache-${{ inputs.android_version }}-${{ inputs.kernel_version }}-
  346. ccache-
  347. - name: Cache bazel-cache (GitHub Native)
  348. if: false
  349. uses: actions/cache@v6
  350. with:
  351. path: /home/runner/.cache/bazel
  352. key: bazel-${{ inputs.android_version }}-${{ inputs.kernel_version }}.${{ steps.extract.outputs.sublevel }}-${{ inputs.os_patch_level }}
  353. restore-keys: |
  354. bazel-${{ inputs.android_version }}-${{ inputs.kernel_version }}.${{ steps.extract.outputs.sublevel }}-
  355. bazel-${{ inputs.android_version }}-${{ inputs.kernel_version }}-
  356. bazel-
  357. - name: Check cache hit
  358. run: |
  359. echo "Cache restore status:"
  360. CCACHE_HIT="${{ steps.restore-ccache.outputs.cache-hit || 'skipped' }}"
  361. BAZEL_HIT="${{ steps.restore-bazel.outputs.cache-hit || 'skipped' }}"
  362. echo " ccache: $CCACHE_HIT"
  363. echo " bazel: $BAZEL_HIT"
  364. - name: Get Cache Stats
  365. uses: ./.github/actions/cache-stats
  366. with:
  367. clear_stats: true
  368. - name: Initialize Config Fragment
  369. run: touch "${{ github.workspace }}/wild_gki.fragment"
  370. - name: Build Normal Kernel
  371. env:
  372. SOURCE_DATE_EPOCH: ${{ env.SOURCE_DATE_EPOCH }}
  373. KBUILD_BUILD_TIMESTAMP: ${{ env.KBUILD_BUILD_TIMESTAMP }}
  374. uses: ./.github/actions/build-kernel
  375. with:
  376. version: ${{ inputs.version }}
  377. bypass: false
  378. - name: Get Cache Stats
  379. uses: ./.github/actions/cache-stats
  380. with:
  381. clear_stats: false
  382. - name: Save ccache
  383. continue-on-error: true
  384. uses: ./.github/actions/cache-save
  385. if: false && (inputs.version == 'android12-5.10' || inputs.version == 'android13-5.10' || inputs.version == 'android13-5.15')
  386. with:
  387. cache_path: /home/runner/.ccache
  388. cache_key: ${{ inputs.android_version }}-${{ inputs.kernel_version }}.${{ steps.extract.outputs.sublevel }}-${{ inputs.os_patch_level }}
  389. cache_bucket: "ccache-cache"
  390. compression_level: 9
  391. github_token: ${{ secrets.MY_GITHUB_TOKEN }}
  392. - name: Save bazel-cache
  393. continue-on-error: true
  394. uses: ./.github/actions/cache-save
  395. if: false && (inputs.version == 'android14-5.15' || inputs.version == 'android14-6.1' || inputs.version == 'android15-6.6' || inputs.version == 'android16-6.12')
  396. with:
  397. cache_path: /home/runner/.cache/bazel
  398. cache_key: ${{ inputs.android_version }}-${{ inputs.kernel_version }}.${{ steps.extract.outputs.sublevel }}-${{ inputs.os_patch_level }}
  399. cache_bucket: "bazel-cache"
  400. compression_level: 9
  401. github_token: ${{ secrets.MY_GITHUB_TOKEN }}
  402. - name: Build Bypass Kernel
  403. if: ${{ inputs.build_bypass }}
  404. env:
  405. SOURCE_DATE_EPOCH: ${{ env.SOURCE_DATE_EPOCH }}
  406. KBUILD_BUILD_TIMESTAMP: ${{ env.KBUILD_BUILD_TIMESTAMP }}
  407. uses: ./.github/actions/build-kernel
  408. with:
  409. bypass: true
  410. version: ${{ inputs.version }}
  411. - name: 📋 Consolidated Build Summary
  412. if: ${{ always() }}
  413. shell: bash
  414. run: |
  415. SUMMARY_BASE="${{ steps.extract.outputs.file_name }}"
  416. if [ -z "${SUMMARY_BASE}" ]; then
  417. SUMMARY_BASE="${{ inputs.kernel_version }}.${{ inputs.sublevel }}-${{ inputs.android_version }}-${{ inputs.os_patch_level }}"
  418. VARIANT="${{ inputs.variant }}"
  419. if [ -n "${VARIANT}" ] && [ "${VARIANT}" != "Normal" ]; then
  420. SUMMARY_BASE="${SUMMARY_BASE}-${VARIANT}"
  421. fi
  422. fi
  423. SUMMARY_FILE="/tmp/build-summary-${SUMMARY_BASE}.md"
  424. echo "SUMMARY_BASE=${SUMMARY_BASE}" >> "$GITHUB_ENV"
  425. # Determine build status
  426. if [ "${{ job.status }}" = "success" ]; then
  427. STATUS="✅ Success"
  428. else
  429. STATUS="❌ Failed"
  430. fi
  431. # Get kernel version from Image if available
  432. KERNEL_VER_STR=""
  433. if [ -f "/home/runner/out/dist/Image" ]; then
  434. KERNEL_VER_STR=$(strings "/home/runner/out/dist/Image" | grep -m1 "^Linux version " | sed 's/Linux version //' || echo "")
  435. elif [ -f "/home/runner/out/Image" ]; then
  436. KERNEL_VER_STR=$(strings "/home/runner/out/Image" | grep -m1 "^Linux version " | sed 's/Linux version //' || echo "")
  437. fi
  438. # Get KSU version from env (set by kernelsu action)
  439. KSU_VER="${KSU_VERSION:-N/A}"
  440. KSU_TAG="${KSU_GIT_TAG:-N/A}"
  441. ROOT_IMPL="${ROOT_IMPLEMENTATION:-KernelSU-Next (legacy path)}"
  442. ROOT_MANAGER="${ROOT_MANAGER:-KernelSU-Next Manager}"
  443. ROOT_VERSION="${ROOT_VERSION:-${KSU_TAG}}"
  444. ROOT_SHA="${ROOT_COMMIT:-${KSU_COMMIT:-N/A}}"
  445. NOMOUNT_SHA="${NOMOUNT_COMMIT:-${{ inputs.nomount_commit }}}"
  446. SUSFS_SHA="${SUSFS_COMMIT:-${{ inputs.susfs_commit }}}"
  447. # Get SUSFS version from susfs.h if available
  448. SUSFS_VER="N/A"
  449. if [ -f "${{ github.workspace }}/kernel/common/include/linux/susfs.h" ]; then
  450. SUSFS_VER=$(grep '#define SUSFS_VERSION' "${{ github.workspace }}/kernel/common/include/linux/susfs.h" | awk -F'"' '{print $2}' || echo "N/A")
  451. fi
  452. # Get cache stats from env (set by cache-stats action)
  453. CCACHE_HIT="${CCACHE_HIT_RATE:-N/A}"
  454. # Get build time (approximate from step timing)
  455. BUILD_TIME="N/A"
  456. # Count warnings from build log if available
  457. WARNINGS="N/A"
  458. {
  459. echo "## ${{ inputs.android_version }} ${{ inputs.kernel_version }}.${{ inputs.sublevel }} (${{ inputs.variant }}) — ${STATUS}"
  460. echo
  461. echo "| Metric | Value |"
  462. echo "|--------|-------|"
  463. echo "| **Status** | ${STATUS} |"
  464. echo "| **Kernel** | ${{ inputs.kernel_version }}.${{ inputs.sublevel }}-${{ inputs.android_version }}-${{ inputs.os_patch_level }} |"
  465. if [ -n "$KERNEL_VER_STR" ]; then
  466. echo "| **Version String** | \`${KERNEL_VER_STR}\` |"
  467. fi
  468. echo "| **KSU Version** | ${KSU_VER} |"
  469. echo "| **KSU Tag** | ${KSU_TAG} |"
  470. echo "| **Root Implementation** | ${ROOT_IMPL} |"
  471. echo "| **Root Manager** | ${ROOT_MANAGER} |"
  472. echo "| **Root Version** | ${ROOT_VERSION} |"
  473. echo "| **Root Commit** | ${ROOT_SHA} |"
  474. echo "| **SUSFS Version** | ${SUSFS_VER} |"
  475. echo "| **SUSFS Commit** | ${SUSFS_SHA} |"
  476. echo "| **NoMount Commit** | ${NOMOUNT_SHA} |"
  477. echo "| **Feature Set** | ${{ inputs.feature_set }} |"
  478. echo "| **Variant** | ${{ inputs.variant }} |"
  479. echo
  480. # Kernel Fixes
  481. if [ -f /tmp/kernel-fixes-summary.md ]; then
  482. echo "### 🔧 Kernel Fixes"
  483. cat /tmp/kernel-fixes-summary.md
  484. echo
  485. fi
  486. } > "$SUMMARY_FILE"
  487. - name: Upload Artifacts
  488. id: kernel-artifact
  489. uses: actions/upload-artifact@v7
  490. with:
  491. name: ${{ steps.extract.outputs.file_name }}-AnyKernel3
  492. path: ${{ github.workspace }}/AnyKernel3/**
  493. if-no-files-found: ignore
  494. compression-level: 9
  495. - name: Write Build-verified only artifact metadata
  496. if: ${{ success() && inputs.root_flavor != '' && inputs.nomount_commit != '' }}
  497. shell: bash
  498. env:
  499. GH_TOKEN: ${{ github.token }}
  500. run: |
  501. set -euo pipefail
  502. metadata_file="/tmp/${SUMMARY_BASE}-metadata.json"
  503. summary_file="/tmp/build-summary-${SUMMARY_BASE}.md"
  504. artifacts_api="${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}/artifacts?per_page=100"
  505. resolve_artifact() {
  506. local artifact_name="$1"
  507. local page=1
  508. local match=""
  509. local page_file
  510. page_file="$(mktemp)"
  511. # Page through the artifacts API, checking each page for the exact
  512. # artifact name. Uses a temp file for jq input (not argv) so large
  513. # artifact lists can't exceed the OS argument-length limit.
  514. while :; do
  515. curl --fail --silent --show-error --location \
  516. --header "Authorization: Bearer ${GH_TOKEN}" \
  517. --header "X-GitHub-Api-Version: 2022-11-28" \
  518. "${artifacts_api}&page=${page}" -o "$page_file"
  519. match="$(jq -r --arg name "$artifact_name" \
  520. '[.artifacts[] | select(.name == $name and .expired == false)] | .[0]
  521. | if . == null then "" else (.archive_download_url + "\t" + .digest) end' \
  522. "$page_file")"
  523. items="$(jq '(.artifacts | length) // 0' "$page_file")"
  524. if [ "$items" -lt 100 ] || [ -n "$match" ]; then
  525. break
  526. fi
  527. page=$((page + 1))
  528. done
  529. rm -f "$page_file"
  530. if [ -z "$match" ]; then
  531. echo "Expected exactly one available artifact named ${artifact_name}." >&2
  532. exit 1
  533. fi
  534. printf '%s\n' "$match"
  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. # Merge the verified metadata into the combined summary markdown so both
  611. # live in a single artifact: human-readable table + machine JSON block.
  612. {
  613. echo
  614. echo "## Verified Metadata"
  615. echo
  616. echo '```json'
  617. cat "$metadata_file"
  618. echo '```'
  619. echo
  620. } >> "$summary_file"
  621. - name: Upload Build Summary + Metadata
  622. uses: actions/upload-artifact@v7
  623. with:
  624. name: ${{ steps.extract.outputs.file_name }}-BuildInfo
  625. path: /tmp/build-summary-${{ env.SUMMARY_BASE }}.md
  626. if-no-files-found: warn
  627. compression-level: 9