build.yml 26 KB

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