build.yml 27 KB

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