build.yml 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701
  1. name: Kernel Build Process
  2. permissions:
  3. contents: read
  4. actions: write
  5. on:
  6. workflow_call:
  7. inputs:
  8. version:
  9. required: true
  10. type: string
  11. android_version:
  12. required: true
  13. type: string
  14. kernel_version:
  15. required: true
  16. type: string
  17. sublevel:
  18. required: true
  19. type: string
  20. os_patch_level:
  21. required: true
  22. type: string
  23. variant:
  24. required: false
  25. type: string
  26. feature_set:
  27. required: true
  28. type: string
  29. ksu_branch:
  30. required: false
  31. type: string
  32. default: ""
  33. susfs_commit:
  34. required: false
  35. type: string
  36. default: ""
  37. root_flavor:
  38. required: false
  39. type: string
  40. default: ""
  41. root_commit:
  42. required: false
  43. type: string
  44. default: ""
  45. nomount_commit:
  46. required: false
  47. type: string
  48. default: ""
  49. kernel_patches_commit:
  50. required: false
  51. type: string
  52. default: ""
  53. anykernel3_commit:
  54. required: false
  55. type: string
  56. default: ""
  57. droidspaces_commit:
  58. required: false
  59. type: string
  60. default: ""
  61. brand_name:
  62. required: false
  63. type: string
  64. default: Wild
  65. preserve_abi:
  66. required: false
  67. type: boolean
  68. default: false
  69. build_bypass:
  70. required: false
  71. type: boolean
  72. default: true
  73. jobs:
  74. build-gki:
  75. name: "${{ inputs.kernel_version }}.${{ inputs.sublevel }}-${{ inputs.android_version }}-${{ inputs.os_patch_level }} (${{ inputs.variant }})"
  76. runs-on: ubuntu-latest
  77. timeout-minutes: 120
  78. steps:
  79. - name: Checkout Repository
  80. uses: actions/checkout@v7
  81. - name: 🧹 Emergency Disk Cleanup
  82. if: false
  83. uses: ./.github/actions/disk-cleanup
  84. - name: Free Disk Space
  85. if: true
  86. uses: endersonmenezes/free-disk-space@v3 # Use @main for latest, @v3 for stable
  87. with:
  88. remove_android: true
  89. remove_dotnet: true
  90. remove_haskell: true
  91. remove_tool_cache: true
  92. remove_packages: "azure-cli google-cloud-cli microsoft-edge-stable google-chrome-stable firefox postgresql* temurin-* *llvm* mysql* dotnet-sdk-*"
  93. remove_packages_one_command: true
  94. remove_folders: "/usr/share/swift /usr/share/miniconda /usr/share/az* /usr/local/lib/node_modules /usr/local/share/chromium /usr/local/share/powershell /usr/local/julia /usr/local/aws-cli /usr/local/aws-sam-cli /usr/share/gradle"
  95. rm_cmd: "rmz" # Use 'rmz' for faster deletion (default: 'rm')
  96. rmz_version: "3.1.1" # Required when rm_cmd is 'rmz'
  97. testing: false
  98. - name: Setup more Swap (for LTO)
  99. uses: thejerrybao/setup-swap-space@v1 # or pierotofy/set-swap-space
  100. with:
  101. swap-size-gb: 16 # 10-24 GB is common for heavy LTO
  102. # swap-space-path: /mnt/swapfile # optional
  103. - name: Setup Build Environment
  104. uses: ./.github/actions/setup-build-environment
  105. with:
  106. version: ${{ inputs.version }}
  107. sublevel: ${{ inputs.sublevel }}
  108. kernel_patches_commit: ${{ inputs.kernel_patches_commit }}
  109. anykernel3_commit: ${{ inputs.anykernel3_commit }}
  110. env:
  111. BOOT_SIGN_KEY: ${{ secrets.BOOT_SIGN_KEY }}
  112. - name: Download Kernel Repository
  113. uses: ./.github/actions/download-kernel
  114. with:
  115. version: ${{ inputs.version }}
  116. android_version: ${{ inputs.android_version }}
  117. kernel_version: ${{ inputs.kernel_version }}
  118. os_patch_level: ${{ inputs.os_patch_level }}
  119. - name: Set Build Timestamp from Kernel Commit
  120. shell: bash
  121. run: |
  122. set -x
  123. # Hardcode the build timestamp to the 5th day of the patch level
  124. # at 04:20 UTC, using the existing timestamp formats expected by the build.
  125. OS_PATCH_LEVEL_INPUT="${{ inputs.os_patch_level }}"
  126. if [[ "$OS_PATCH_LEVEL_INPUT" == lts* ]]; then
  127. if [[ "$OS_PATCH_LEVEL_INPUT" =~ ^lts-([0-9]{2})$ ]]; then
  128. OS_PATCH_LEVEL_YM="$(date -u +%Y)-${BASH_REMATCH[1]}"
  129. else
  130. OS_PATCH_LEVEL_YM="$(date -u +%Y-%m)"
  131. fi
  132. else
  133. OS_PATCH_LEVEL_YM="$OS_PATCH_LEVEL_INPUT"
  134. fi
  135. FIXED_BUILD_DATE="${OS_PATCH_LEVEL_YM}-05 04:20:00 UTC"
  136. SOURCE_DATE_EPOCH=$(date -u -d "$FIXED_BUILD_DATE" +%s)
  137. echo "SOURCE_DATE_EPOCH=$SOURCE_DATE_EPOCH" >> $GITHUB_ENV
  138. KBUILD_TS=$(date -u -d @${SOURCE_DATE_EPOCH} '+%a %b %d %H:%M:%S UTC %Y')
  139. echo "KBUILD_BUILD_TIMESTAMP=${KBUILD_TS}" >> $GITHUB_ENV
  140. # Keep git metadata aligned with the same fixed timestamp.
  141. GIT_DATE=$(date -u -d @${SOURCE_DATE_EPOCH} '+%Y-%m-%dT%H:%M:%SZ')
  142. echo "GIT_COMMITTER_DATE=${GIT_DATE}" >> $GITHUB_ENV
  143. echo "GIT_AUTHOR_DATE=${GIT_DATE}" >> $GITHUB_ENV
  144. echo "Build timestamp set to: $(date -u -d @${SOURCE_DATE_EPOCH} '+%Y-%m-%d %H:%M:%S UTC') (epoch: $SOURCE_DATE_EPOCH)"
  145. - name: Extract Sublevel and Set File Name
  146. id: extract
  147. uses: ./.github/actions/extract-sublevel-file-name
  148. with:
  149. android_version: ${{ inputs.android_version }}
  150. kernel_version: ${{ inputs.kernel_version }}
  151. sublevel: ${{ inputs.sublevel }}
  152. os_patch_level: ${{ inputs.os_patch_level }}
  153. variant: ${{ inputs.variant }}
  154. - name: Kernel Fixes
  155. uses: ./.github/actions/kernel-fixes
  156. with:
  157. version: ${{ inputs.version }}
  158. android_version: ${{ inputs.android_version }}
  159. kernel_version: ${{ inputs.kernel_version }}
  160. sublevel: ${{ steps.extract.outputs.sublevel }}
  161. os_patch_level: ${{ inputs.os_patch_level }}
  162. - name: Capture source ABI/KMI safeguards
  163. if: ${{ inputs.preserve_abi }}
  164. uses: ./.github/actions/abi-kmi-safeguards
  165. with:
  166. mode: capture
  167. - name: Setup Selected Root Implementation
  168. if: ${{ inputs.root_flavor != '' }}
  169. uses: ./.github/actions/root-setup
  170. with:
  171. flavor: ${{ inputs.root_flavor }}
  172. commit: ${{ inputs.root_commit }}
  173. - name: Disable SUSFS for ReSukiSU without SUSFS feature
  174. if: ${{ inputs.root_flavor == 'resukisu' && !contains(inputs.feature_set, 'SUSFS') }}
  175. uses: ./.github/actions/set-kernel-config
  176. with:
  177. config_list: |
  178. CONFIG_KSU_SUSFS=n
  179. - name: Verify root ABI/KMI safeguards
  180. if: ${{ inputs.preserve_abi }}
  181. uses: ./.github/actions/abi-kmi-safeguards
  182. with:
  183. mode: verify
  184. - name: SUSFS
  185. if: contains(inputs.feature_set, 'SUSFS') || inputs.feature_set == 'All'
  186. uses: ./.github/actions/susfs
  187. with:
  188. susfs_commit: ${{ inputs.susfs_commit }}
  189. version: ${{ inputs.version }}
  190. android_version: ${{ inputs.android_version }}
  191. kernel_version: ${{ inputs.kernel_version }}
  192. os_patch_level: ${{ inputs.os_patch_level }}
  193. sublevel: ${{ steps.extract.outputs.sublevel }}
  194. root_flavor: ${{ inputs.root_flavor }}
  195. nomount_enabled: ${{ contains(inputs.feature_set, 'NoMount') }}
  196. - name: Baseband Guard
  197. if: (contains(inputs.feature_set, 'BBG') || inputs.feature_set == 'All')
  198. uses: ./.github/actions/bbg
  199. - name: Setup Networking
  200. if: contains(inputs.feature_set, 'NET') || inputs.feature_set == 'All'
  201. uses: ./.github/actions/networking
  202. with:
  203. version: ${{ inputs.version }}
  204. kernel_version: ${{ inputs.kernel_version }}
  205. android_version: ${{ inputs.android_version }}
  206. sublevel: ${{ steps.extract.outputs.sublevel }}
  207. - name: DroidSpaces-OSS Patches
  208. if: contains(inputs.feature_set, 'DS') || inputs.feature_set == 'All'
  209. uses: ./.github/actions/droidspaces
  210. with:
  211. version: ${{ inputs.version }}
  212. kernel_version: ${{ inputs.kernel_version }}
  213. droidspaces_commit: ${{ inputs.droidspaces_commit }}
  214. - name: Apply NTSync Patches
  215. if: contains(inputs.feature_set, 'NTSync')
  216. uses: ./.github/actions/ntsync
  217. with:
  218. version: ${{ inputs.version }}
  219. kernel_version: ${{ inputs.kernel_version }}
  220. sublevel: ${{ steps.extract.outputs.sublevel }}
  221. - name: Apply Ptrace Patch
  222. if: contains(inputs.feature_set, 'Ptrace')
  223. uses: ./.github/actions/ptrace
  224. with:
  225. kernel_version: ${{ inputs.kernel_version }}
  226. - name: Apply Unicode Fix Patch
  227. if: contains(inputs.feature_set, 'Unicode')
  228. uses: ./.github/actions/unicode-fix
  229. with:
  230. kernel_version: ${{ inputs.kernel_version }}
  231. - name: Apply Performance Patches
  232. uses: ./.github/actions/performance
  233. if: contains(inputs.feature_set, 'Perf')
  234. with:
  235. kernel_version: ${{ inputs.kernel_version }}
  236. - name: Setup Misc Configs
  237. uses: ./.github/actions/misc
  238. - name: Enable BPF Stack (BTF + eBPF + FUSE-BPF)
  239. if: contains(inputs.feature_set, 'BPF')
  240. uses: ./.github/actions/btf
  241. with:
  242. version: ${{ inputs.version }}
  243. kernel_version: ${{ inputs.kernel_version }}
  244. sublevel: ${{ steps.extract.outputs.sublevel }}
  245. - name: Apply Device-Specific Patches
  246. uses: ./.github/actions/apply-device-patches
  247. with:
  248. version: ${{ inputs.version }}
  249. kernel_version: ${{ inputs.kernel_version }}
  250. - name: Capture approved feature ABI/KMI baseline
  251. if: ${{ inputs.preserve_abi }}
  252. uses: ./.github/actions/abi-kmi-safeguards
  253. with:
  254. mode: capture
  255. - name: Integrate NoMount
  256. if: ${{ inputs.nomount_commit != '' || contains(inputs.feature_set, 'NoMount') || inputs.feature_set == 'All' }}
  257. uses: ./.github/actions/nomount
  258. with:
  259. commit: ${{ inputs.nomount_commit }}
  260. kernel_version: ${{ inputs.kernel_version }}
  261. - name: Apply ABI Compare Bypass
  262. if: false
  263. working-directory: ${{ github.workspace }}/kernel
  264. run: |
  265. # ABI compare bypass per kernel/android version
  266. # Edit each block as needed per version
  267. if [[ "$ANDROID_VERSION" == "android12" && "$KERNEL_VERSION" == "5.10" ]]; then
  268. sed -i 's/^\s*exit 1$/ echo "Who Cares? Bypassing Now!"/' build/abi/compare_to_symbol_list
  269. elif [[ "$ANDROID_VERSION" == "android13" && "$KERNEL_VERSION" == "5.10" ]]; then
  270. sed -i 's/^\s*exit 1$/ echo "Who Cares? Bypassing Now!"/' build/kernel/abi/compare_to_symbol_list
  271. elif [[ "$ANDROID_VERSION" == "android13" && "$KERNEL_VERSION" == "5.15" ]]; then
  272. sed -i 's/^\s*exit 1$/ echo "Who Cares? Bypassing Now!"/' build/kernel/abi/compare_to_symbol_list
  273. elif [[ "$ANDROID_VERSION" == "android14" && "$KERNEL_VERSION" == "5.15" ]]; 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" == "android14" && "$KERNEL_VERSION" == "6.1" ]]; 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. elif [[ "$ANDROID_VERSION" == "android15" && "$KERNEL_VERSION" == "6.6" ]]; 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. fi
  280. - name: Apply Kernel Branding
  281. uses: ./.github/actions/apply-kernel-branding
  282. with:
  283. variant: ${{ inputs.variant }}
  284. kernel_version: ${{ inputs.kernel_version }}
  285. android_version: ${{ inputs.android_version }}
  286. version: ${{ inputs.version }}
  287. sublevel: ${{ steps.extract.outputs.sublevel }}
  288. brand_name: ${{ inputs.brand_name }}
  289. - name: Remove Protected Exports
  290. if: ${{ !inputs.preserve_abi }}
  291. uses: ./.github/actions/remove-protected-exports
  292. - name: Verify NoMount ABI/KMI safeguards
  293. if: ${{ inputs.preserve_abi }}
  294. uses: ./.github/actions/abi-kmi-safeguards
  295. with:
  296. mode: verify
  297. - name: Clean Kernel Flags
  298. uses: ./.github/actions/clean-kernel-flags
  299. - name: Scan and collect patch rejects
  300. id: scan
  301. if: ${{ always() }}
  302. uses: ./.github/actions/scan-patch-rejects
  303. - name: Upload Rejects
  304. if: ${{ always() }}
  305. uses: actions/upload-artifact@v7
  306. with:
  307. name: ${{ steps.extract.outputs.file_name }}-Rejects
  308. path: patch-rejects/
  309. if-no-files-found: ignore
  310. compression-level: 9
  311. - name: Get prebuilt ccache (downloaded once by prepare-ccache)
  312. if: false
  313. uses: actions/download-artifact@v8
  314. with:
  315. name: ccache-binary
  316. path: ccache-dl
  317. continue-on-error: true
  318. - name: 'Setup Cache and Build Environment'
  319. uses: ./.github/actions/cache-setup
  320. with:
  321. version: ${{ inputs.version }}
  322. android_version: ${{ inputs.android_version }}
  323. kernel_version: ${{ inputs.kernel_version }}
  324. sublevel: ${{ steps.extract.outputs.sublevel }}
  325. - name: Restore ccache
  326. id: restore-ccache
  327. continue-on-error: true
  328. if: false && (inputs.version == 'android12-5.10' || inputs.version == 'android13-5.10' || inputs.version == 'android13-5.15')
  329. uses: ./.github/actions/cache-restore
  330. with:
  331. cache_path: /home/runner/.ccache
  332. cache_key: ${{ inputs.android_version }}-${{ inputs.kernel_version }}.${{ steps.extract.outputs.sublevel }}-${{ inputs.os_patch_level }}
  333. cache_bucket: ccache-cache
  334. restore_keys: |
  335. ${{ inputs.android_version }}-${{ inputs.kernel_version }}.${{ steps.extract.outputs.sublevel }}-
  336. - name: Restore bazel-cache
  337. id: restore-bazel
  338. continue-on-error: true
  339. if: false && (inputs.version == 'android14-5.15' || inputs.version == 'android14-6.1' || inputs.version == 'android15-6.6' || inputs.version == 'android16-6.12')
  340. uses: ./.github/actions/cache-restore
  341. with:
  342. cache_path: /home/runner/.cache/bazel
  343. cache_key: ${{ inputs.android_version }}-${{ inputs.kernel_version }}.${{ steps.extract.outputs.sublevel }}-${{ inputs.os_patch_level }}
  344. cache_bucket: bazel-cache
  345. restore_keys: |
  346. ${{ inputs.android_version }}-${{ inputs.kernel_version }}.${{ steps.extract.outputs.sublevel }}-
  347. - name: Cache ccache (GitHub Native)
  348. if: false
  349. uses: actions/cache@v6
  350. with:
  351. path: /home/runner/.ccache
  352. key: ccache-${{ inputs.android_version }}-${{ inputs.kernel_version }}.${{ steps.extract.outputs.sublevel }}-${{ inputs.os_patch_level }}
  353. restore-keys: |
  354. ccache-${{ inputs.android_version }}-${{ inputs.kernel_version }}.${{ steps.extract.outputs.sublevel }}-
  355. ccache-${{ inputs.android_version }}-${{ inputs.kernel_version }}-
  356. ccache-
  357. - name: Cache bazel-cache (GitHub Native)
  358. if: false
  359. uses: actions/cache@v6
  360. with:
  361. path: /home/runner/.cache/bazel
  362. key: bazel-${{ inputs.android_version }}-${{ inputs.kernel_version }}.${{ steps.extract.outputs.sublevel }}-${{ inputs.os_patch_level }}
  363. restore-keys: |
  364. bazel-${{ inputs.android_version }}-${{ inputs.kernel_version }}.${{ steps.extract.outputs.sublevel }}-
  365. bazel-${{ inputs.android_version }}-${{ inputs.kernel_version }}-
  366. bazel-
  367. - name: Check cache hit
  368. run: |
  369. echo "Cache restore status:"
  370. CCACHE_HIT="${{ steps.restore-ccache.outputs.cache-hit || 'skipped' }}"
  371. BAZEL_HIT="${{ steps.restore-bazel.outputs.cache-hit || 'skipped' }}"
  372. echo " ccache: $CCACHE_HIT"
  373. echo " bazel: $BAZEL_HIT"
  374. - name: Get Cache Stats
  375. uses: ./.github/actions/cache-stats
  376. with:
  377. clear_stats: true
  378. - name: Initialize Config Fragment
  379. run: touch "${{ github.workspace }}/wild_gki.fragment"
  380. - name: Build Normal Kernel
  381. env:
  382. SOURCE_DATE_EPOCH: ${{ env.SOURCE_DATE_EPOCH }}
  383. KBUILD_BUILD_TIMESTAMP: ${{ env.KBUILD_BUILD_TIMESTAMP }}
  384. uses: ./.github/actions/build-kernel
  385. with:
  386. version: ${{ inputs.version }}
  387. bypass: false
  388. - name: Get Cache Stats
  389. uses: ./.github/actions/cache-stats
  390. with:
  391. clear_stats: false
  392. - name: Save ccache
  393. continue-on-error: true
  394. uses: ./.github/actions/cache-save
  395. if: false && (inputs.version == 'android12-5.10' || inputs.version == 'android13-5.10' || inputs.version == 'android13-5.15')
  396. with:
  397. cache_path: /home/runner/.ccache
  398. cache_key: ${{ inputs.android_version }}-${{ inputs.kernel_version }}.${{ steps.extract.outputs.sublevel }}-${{ inputs.os_patch_level }}
  399. cache_bucket: "ccache-cache"
  400. compression_level: 9
  401. github_token: ${{ secrets.MY_GITHUB_TOKEN }}
  402. - name: Save bazel-cache
  403. continue-on-error: true
  404. uses: ./.github/actions/cache-save
  405. if: false && (inputs.version == 'android14-5.15' || inputs.version == 'android14-6.1' || inputs.version == 'android15-6.6' || inputs.version == 'android16-6.12')
  406. with:
  407. cache_path: /home/runner/.cache/bazel
  408. cache_key: ${{ inputs.android_version }}-${{ inputs.kernel_version }}.${{ steps.extract.outputs.sublevel }}-${{ inputs.os_patch_level }}
  409. cache_bucket: "bazel-cache"
  410. compression_level: 9
  411. github_token: ${{ secrets.MY_GITHUB_TOKEN }}
  412. - name: Build Bypass Kernel
  413. if: ${{ inputs.build_bypass }}
  414. env:
  415. SOURCE_DATE_EPOCH: ${{ env.SOURCE_DATE_EPOCH }}
  416. KBUILD_BUILD_TIMESTAMP: ${{ env.KBUILD_BUILD_TIMESTAMP }}
  417. uses: ./.github/actions/build-kernel
  418. with:
  419. bypass: true
  420. version: ${{ inputs.version }}
  421. - name: 📋 Consolidated Build Summary
  422. if: ${{ always() }}
  423. shell: bash
  424. run: |
  425. SUMMARY_BASE="${{ steps.extract.outputs.file_name }}"
  426. if [ -z "${SUMMARY_BASE}" ]; then
  427. SUMMARY_BASE="${{ inputs.kernel_version }}.${{ inputs.sublevel }}-${{ inputs.android_version }}-${{ inputs.os_patch_level }}"
  428. VARIANT="${{ inputs.variant }}"
  429. if [ -n "${VARIANT}" ] && [ "${VARIANT}" != "Normal" ]; then
  430. SUMMARY_BASE="${SUMMARY_BASE}-${VARIANT}"
  431. fi
  432. fi
  433. SUMMARY_FILE="/tmp/build-summary-${SUMMARY_BASE}.md"
  434. echo "SUMMARY_BASE=${SUMMARY_BASE}" >> "$GITHUB_ENV"
  435. # Determine build status
  436. if [ "${{ job.status }}" = "success" ]; then
  437. STATUS="✅ Success"
  438. else
  439. STATUS="❌ Failed"
  440. fi
  441. # Get kernel version from Image if available
  442. KERNEL_VER_STR=""
  443. if [ -f "/home/runner/out/dist/Image" ]; then
  444. KERNEL_VER_STR=$(strings "/home/runner/out/dist/Image" | grep -m1 "^Linux version " | sed 's/Linux version //' || echo "")
  445. elif [ -f "/home/runner/out/Image" ]; then
  446. KERNEL_VER_STR=$(strings "/home/runner/out/Image" | grep -m1 "^Linux version " | sed 's/Linux version //' || echo "")
  447. fi
  448. # Get KSU version from env (set by kernelsu action)
  449. KSU_VER="${KSU_VERSION:-N/A}"
  450. KSU_TAG="${KSU_GIT_TAG:-N/A}"
  451. ROOT_IMPL="${ROOT_IMPLEMENTATION:-KernelSU-Next (legacy path)}"
  452. ROOT_MANAGER="${ROOT_MANAGER:-KernelSU-Next Manager}"
  453. ROOT_VERSION="${ROOT_VERSION:-${KSU_TAG}}"
  454. ROOT_SHA="${ROOT_COMMIT:-${KSU_COMMIT:-N/A}}"
  455. NOMOUNT_SHA="${NOMOUNT_COMMIT:-${{ inputs.nomount_commit }}}"
  456. SUSFS_SHA="${SUSFS_COMMIT:-${{ inputs.susfs_commit }}}"
  457. # Get SUSFS version from susfs.h if available
  458. SUSFS_VER="N/A"
  459. if [ -f "${{ github.workspace }}/kernel/common/include/linux/susfs.h" ]; then
  460. SUSFS_VER=$(grep '#define SUSFS_VERSION' "${{ github.workspace }}/kernel/common/include/linux/susfs.h" | awk -F'"' '{print $2}' || echo "N/A")
  461. fi
  462. # Get cache stats from env (set by cache-stats action)
  463. CCACHE_HIT="${CCACHE_HIT_RATE:-N/A}"
  464. # Get build time (approximate from step timing)
  465. BUILD_TIME="N/A"
  466. # Count warnings from build log if available
  467. WARNINGS="N/A"
  468. {
  469. echo "## ${{ inputs.android_version }} ${{ inputs.kernel_version }}.${{ inputs.sublevel }} (${{ inputs.variant }}) — ${STATUS}"
  470. echo
  471. echo "| Metric | Value |"
  472. echo "|--------|-------|"
  473. echo "| **Status** | ${STATUS} |"
  474. echo "| **Kernel** | ${{ inputs.kernel_version }}.${{ inputs.sublevel }}-${{ inputs.android_version }}-${{ inputs.os_patch_level }} |"
  475. if [ -n "$KERNEL_VER_STR" ]; then
  476. echo "| **Version String** | \`${KERNEL_VER_STR}\` |"
  477. fi
  478. echo "| **KSU Version** | ${KSU_VER} |"
  479. echo "| **KSU Tag** | ${KSU_TAG} |"
  480. echo "| **Root Implementation** | ${ROOT_IMPL} |"
  481. echo "| **Root Manager** | ${ROOT_MANAGER} |"
  482. echo "| **Root Version** | ${ROOT_VERSION} |"
  483. echo "| **Root Commit** | ${ROOT_SHA} |"
  484. echo "| **SUSFS Version** | ${SUSFS_VER} |"
  485. echo "| **SUSFS Commit** | ${SUSFS_SHA} |"
  486. echo "| **NoMount Commit** | ${NOMOUNT_SHA} |"
  487. echo "| **Feature Set** | ${{ inputs.feature_set }} |"
  488. echo "| **Variant** | ${{ inputs.variant }} |"
  489. echo
  490. # Kernel Fixes
  491. if [ -f /tmp/kernel-fixes-summary.md ]; then
  492. echo "### 🔧 Kernel Fixes"
  493. cat /tmp/kernel-fixes-summary.md
  494. echo
  495. fi
  496. } > "$SUMMARY_FILE"
  497. - name: Upload Build Summary Artifact
  498. if: ${{ always() }}
  499. uses: actions/upload-artifact@v7
  500. with:
  501. name: ${{ env.SUMMARY_BASE }}-Summary
  502. path: /tmp/build-summary-${{ env.SUMMARY_BASE }}.md
  503. if-no-files-found: ignore
  504. compression-level: 9
  505. - name: Upload Artifacts
  506. id: kernel-artifact
  507. uses: actions/upload-artifact@v7
  508. with:
  509. name: ${{ steps.extract.outputs.file_name }}-AnyKernel3
  510. path: ${{ github.workspace }}/AnyKernel3/**
  511. if-no-files-found: ignore
  512. compression-level: 9
  513. - name: Write Build-verified only artifact metadata
  514. if: ${{ success() && inputs.root_flavor != '' && inputs.nomount_commit != '' }}
  515. shell: bash
  516. env:
  517. GH_TOKEN: ${{ github.token }}
  518. run: |
  519. set -euo pipefail
  520. metadata_file="${{ github.workspace }}/${{ steps.extract.outputs.file_name }}-metadata.json"
  521. artifacts_api="${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}/artifacts?per_page=100"
  522. resolve_artifact() {
  523. local artifact_name="$1"
  524. local all_artifacts="[]"
  525. local page=1
  526. local has_more=true
  527. while [ "$has_more" = "true" ]; do
  528. page_content="$(curl --fail --silent --show-error --location \
  529. --header "Authorization: Bearer ${GH_TOKEN}" \
  530. --header "X-GitHub-Api-Version: 2022-11-28" \
  531. "${artifacts_api}&page=${page}")"
  532. all_artifacts="$(jq -cn --argjson acc "$all_artifacts" --argjson cur "$page_content" \
  533. '$acc + $cur.artifacts')"
  534. items="$(jq '(.artifacts | length) // 0' <<<"$page_content")"
  535. if [ "$items" -lt 100 ]; then
  536. has_more=false
  537. fi
  538. page=$((page + 1))
  539. done
  540. local matches
  541. matches="$(jq --arg name "$artifact_name" \
  542. '[.artifacts[] | select(.name == $name and .expired == false)]' \
  543. <<<"{\"artifacts\": $all_artifacts}")"
  544. if [ "$(jq 'length' <<<"$matches")" -ne 1 ]; then
  545. echo "Expected exactly one available artifact named ${artifact_name}." >&2
  546. exit 1
  547. fi
  548. jq -r '.[0] | [.archive_download_url, .digest] | @tsv' <<<"$matches"
  549. }
  550. read -r kernel_artifact_url kernel_artifact_sha256 < <(
  551. resolve_artifact "${{ steps.extract.outputs.file_name }}-AnyKernel3"
  552. )
  553. read -r nomount_module_url nomount_module_sha256 < <(
  554. resolve_artifact "NoMount-Metamodule"
  555. )
  556. jq -n \
  557. --arg method "GKI source build with SHA-pinned root implementation, SUSFS, and NoMount" \
  558. --arg root_implementation "${ROOT_IMPLEMENTATION:-KernelSU-Next (legacy path)}" \
  559. --arg root_manager "${ROOT_MANAGER:-KernelSU-Next Manager}" \
  560. --arg root_version "${ROOT_VERSION:-${KSU_GIT_TAG:-N/A}}" \
  561. --arg root_commit "${ROOT_COMMIT:-${KSU_COMMIT:-N/A}}" \
  562. --arg susfs_commit "${SUSFS_COMMIT:-N/A}" \
  563. --arg nomount_commit "${NOMOUNT_COMMIT:-N/A}" \
  564. --arg android_branch "${{ inputs.android_version }}-${{ inputs.kernel_version }}-${{ inputs.os_patch_level }}" \
  565. --arg kmi "${{ inputs.android_version }}-${{ inputs.kernel_version }}" \
  566. --arg kernel_source_commit "${KERNEL_SOURCE_COMMIT:-N/A}" \
  567. --arg provenance_url "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" \
  568. --arg artifact_url "$kernel_artifact_url" \
  569. --arg sha256 "$kernel_artifact_sha256" \
  570. --arg nomount_module_commit "${{ inputs.nomount_commit }}" \
  571. --arg nomount_module_url "$nomount_module_url" \
  572. --arg nomount_module_sha256 "$nomount_module_sha256" \
  573. --arg status "Build-verified only" \
  574. --arg catalog_availability "eligible-with-provenance-and-checksums" \
  575. --arg device_compatibility "not-validated" \
  576. --arg flashability "not-guaranteed" \
  577. --arg boot "not-guaranteed" \
  578. '{
  579. method: $method,
  580. root: {
  581. implementation: $root_implementation,
  582. manager: $root_manager,
  583. version: $root_version,
  584. commit: $root_commit
  585. },
  586. susfs_revision: $susfs_commit,
  587. nomount_commit: $nomount_commit,
  588. android_branch: $android_branch,
  589. kmi: $kmi,
  590. kernel_source_commit: $kernel_source_commit,
  591. provenance_url: $provenance_url,
  592. artifact_url: $artifact_url,
  593. sha256: $sha256,
  594. nomount_metamodule: {
  595. commit: $nomount_module_commit,
  596. artifact_url: $nomount_module_url,
  597. sha256: $nomount_module_sha256
  598. },
  599. catalog: {
  600. availability: $catalog_availability,
  601. device_compatibility: $device_compatibility,
  602. flashability: $flashability,
  603. boot: $boot
  604. },
  605. status: $status
  606. }' > "$metadata_file"
  607. jq -e '
  608. .status == "Build-verified only" and
  609. (.root.manager | length > 0) and
  610. (.root.version | length > 0) and
  611. (.susfs_revision | test("^[0-9a-f]{40}$")) and
  612. (.nomount_commit | test("^[0-9a-f]{40}$")) and
  613. (.kernel_source_commit | test("^[0-9a-f]{40}$")) and
  614. (.artifact_url | startswith("https://")) and
  615. (.sha256 | test("^sha256:[0-9a-f]{64}$")) and
  616. (.nomount_metamodule.commit == .nomount_commit) and
  617. (.nomount_metamodule.artifact_url | startswith("https://")) and
  618. (.nomount_metamodule.sha256 | test("^sha256:[0-9a-f]{64}$")) and
  619. .catalog.availability == "eligible-with-provenance-and-checksums" and
  620. .catalog.device_compatibility == "not-validated" and
  621. .catalog.flashability == "not-guaranteed" and
  622. .catalog.boot == "not-guaranteed"
  623. ' "$metadata_file" > /dev/null
  624. - name: Upload Build-verified only artifact metadata
  625. if: ${{ success() && inputs.root_flavor != '' && inputs.nomount_commit != '' }}
  626. uses: actions/upload-artifact@v7
  627. with:
  628. name: ${{ steps.extract.outputs.file_name }}-Metadata
  629. path: ${{ github.workspace }}/${{ steps.extract.outputs.file_name }}-metadata.json
  630. if-no-files-found: error
  631. compression-level: 9