main.yml 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929
  1. name: Build Kernels
  2. permissions:
  3. contents: write
  4. actions: write
  5. on:
  6. workflow_dispatch:
  7. inputs:
  8. release_type:
  9. description: "Release Type"
  10. type: choice
  11. options:
  12. - Action
  13. - Pre-Release
  14. - Release
  15. default: Action
  16. kernel_build_version:
  17. description: "Kernel Version"
  18. type: choice
  19. options:
  20. - All
  21. - android12-5.10
  22. - android13-5.10
  23. - android13-5.15
  24. - android14-5.15
  25. - android14-6.1
  26. - android15-6.6
  27. - android16-6.12
  28. default: All
  29. brand_name:
  30. description: "Kernel Branding"
  31. type: string
  32. default: Wild
  33. root_flavor:
  34. description: "Root Flavor"
  35. type: choice
  36. options:
  37. - none
  38. - KernelSU-Next
  39. - KernelSU
  40. - ReSukiSU
  41. default: KernelSU-Next
  42. use_susfs:
  43. description: "SUSFS"
  44. type: boolean
  45. default: true
  46. use_nomount:
  47. description: "NoMount"
  48. type: boolean
  49. default: true
  50. use_bbg:
  51. description: "Baseband Guard"
  52. type: boolean
  53. default: true
  54. use_net:
  55. description: "Networking"
  56. type: boolean
  57. default: true
  58. use_ds:
  59. description: "DroidSpaces"
  60. type: boolean
  61. default: true
  62. use_ntsync:
  63. description: "NTSync"
  64. type: boolean
  65. default: true
  66. use_ptrace:
  67. description: "Ptrace Patch"
  68. type: boolean
  69. default: true
  70. use_unicode:
  71. description: "Unicode Fix"
  72. type: boolean
  73. default: true
  74. use_bpf:
  75. description: "BPF Stack (BTF + eBPF + FUSE-BPF)"
  76. type: boolean
  77. default: true
  78. use_perf:
  79. description: "Performance"
  80. type: boolean
  81. default: false
  82. jobs:
  83. prepare-ccache:
  84. name: Prepare ccache binary (download once)
  85. runs-on: ubuntu-latest
  86. steps:
  87. - name: Download custom ccache once
  88. if: false
  89. run: |
  90. set -uo pipefail
  91. echo "::group::Download ccache"
  92. url="https://raw.githubusercontent.com/WildKernels/kernel_patches/refs/heads/main/ccache/ccache-x86-64"
  93. ok=0
  94. for attempt in 1 2 3 4 5 6; do
  95. if curl -LfsS --connect-timeout 30 --max-time 120 -H "User-Agent: Mozilla/5.0" "$url" -o ccache && [ -s ccache ]; then
  96. ok=1; break
  97. fi
  98. echo "attempt $attempt failed (GitHub raw 504/throttle); backing off..."
  99. sleep $(( attempt * 5 + RANDOM % 6 ))
  100. done
  101. if [ "$ok" = 1 ]; then
  102. echo "✅ downloaded ccache once for all matrix jobs"
  103. else
  104. echo "::warning::custom ccache download failed; matrix jobs will fall back to the apt ccache"
  105. rm -f ccache
  106. fi
  107. echo "::endgroup::"
  108. - name: Upload ccache artifact
  109. if: false
  110. uses: actions/upload-artifact@v7
  111. with:
  112. name: ccache-binary
  113. path: ccache
  114. retention-days: 1
  115. if-no-files-found: warn
  116. resolve-sources:
  117. runs-on: ubuntu-latest
  118. outputs:
  119. nomount_commit: ${{ steps.resolve.outputs.nomount_commit }}
  120. kernelsu_commit: ${{ steps.resolve.outputs.kernelsu_commit }}
  121. kernelsu_branch: ${{ steps.resolve.outputs.kernelsu_branch }}
  122. root_flavor: ${{ steps.resolve.outputs.root_flavor }}
  123. root_commit: ${{ steps.resolve.outputs.root_commit }}
  124. susfs_commit_android12_5_10: ${{ steps.resolve.outputs.susfs_commit_android12_5_10 }}
  125. susfs_commit_android13_5_10: ${{ steps.resolve.outputs.susfs_commit_android13_5_10 }}
  126. susfs_commit_android13_5_15: ${{ steps.resolve.outputs.susfs_commit_android13_5_15 }}
  127. susfs_commit_android14_5_15: ${{ steps.resolve.outputs.susfs_commit_android14_5_15 }}
  128. susfs_commit_android14_6_1: ${{ steps.resolve.outputs.susfs_commit_android14_6_1 }}
  129. susfs_commit_android15_6_6: ${{ steps.resolve.outputs.susfs_commit_android15_6_6 }}
  130. susfs_commit_android16_6_12: ${{ steps.resolve.outputs.susfs_commit_android16_6_12 }}
  131. kernel_patches_commit: ${{ steps.resolve.outputs.kernel_patches_commit }}
  132. anykernel3_commit: ${{ steps.resolve.outputs.anykernel3_commit }}
  133. droidspaces_commit: ${{ steps.resolve.outputs.droidspaces_commit }}
  134. feature_set: ${{ steps.features.outputs.feature_set }}
  135. steps:
  136. - name: Resolve latest component commits
  137. id: resolve
  138. shell: bash
  139. run: |
  140. set -euo pipefail
  141. retry() {
  142. local n=0
  143. until [ "$n" -ge 5 ]; do
  144. "$@" && return 0
  145. n=$((n+1))
  146. echo "retry $n/5 failed for: $*" >&2
  147. sleep 5
  148. done
  149. return 1
  150. }
  151. resolve_sha() { # repo ref
  152. retry git ls-remote "$1" "$2" | awk '{print $1; exit}'
  153. }
  154. emit() { # key value
  155. if [ -z "$2" ] || ! [[ "$2" =~ ^[0-9a-f]{40}$ ]]; then
  156. echo "Failed to resolve $1 (got: ${2:-empty})" >&2
  157. exit 1
  158. fi
  159. echo "$1=$2" >> "$GITHUB_OUTPUT"
  160. }
  161. # NoMount (dev tip)
  162. emit nomount_commit "$(resolve_sha https://github.com/maxsteeel/nomount.git refs/heads/dev)"
  163. # KernelSU-Next manager — always built from the official repo's dev branch.
  164. # pershoot's fork is used only for the kernel SUSFS integration (root_commit below),
  165. # never for the manager.
  166. emit kernelsu_commit "$(resolve_sha https://github.com/KernelSU-Next/KernelSU-Next.git refs/heads/dev)"
  167. echo "kernelsu_branch=dev" >> "$GITHUB_OUTPUT"
  168. # Selected root implementation at its branch tip. Maps the human-facing
  169. # choice (KernelSU-Next / KernelSU / ReSukiSU) to the internal root-setup
  170. # flavor (next / classic / resukisu). 'none' leaves both empty so build.yml
  171. # falls back to its legacy KernelSU-Next path.
  172. case "${{ inputs.root_flavor }}" in
  173. KernelSU)
  174. emit root_flavor "classic"
  175. emit root_commit "$(resolve_sha https://github.com/tiann/KernelSU.git refs/heads/main)"
  176. ;;
  177. KernelSU-Next)
  178. emit root_flavor "next"
  179. if [ "${{ inputs.use_susfs }}" = "true" ]; then
  180. # SUSFS on: kernel source from pershoot's dev-susfs fork
  181. emit root_commit "$(resolve_sha https://github.com/pershoot/KernelSU-Next.git refs/heads/dev-susfs)"
  182. else
  183. # SUSFS off: plain KernelSU-Next official dev
  184. emit root_commit "$(resolve_sha https://github.com/KernelSU-Next/KernelSU-Next.git refs/heads/dev)"
  185. fi
  186. ;;
  187. ReSukiSU)
  188. emit root_flavor "resukisu"
  189. emit root_commit "$(resolve_sha https://github.com/ReSukiSU/ReSukiSU.git refs/heads/main)"
  190. ;;
  191. *)
  192. echo "root_flavor=" >> "$GITHUB_OUTPUT"
  193. echo "root_commit=" >> "$GITHUB_OUTPUT"
  194. ;;
  195. esac
  196. # SUSFS per supported Android/kernel branch (gitlab simonpunk/susfs4ksu)
  197. declare -A SUSFS_BRANCHES=(
  198. [susfs_commit_android12_5_10]="gki-android12-5.10"
  199. [susfs_commit_android13_5_10]="gki-android13-5.10"
  200. [susfs_commit_android13_5_15]="gki-android13-5.15"
  201. [susfs_commit_android14_5_15]="gki-android14-5.15"
  202. [susfs_commit_android14_6_1]="gki-android14-6.1"
  203. [susfs_commit_android15_6_6]="gki-android15-6.6"
  204. [susfs_commit_android16_6_12]="gki-android16-6.12"
  205. )
  206. for key in "${!SUSFS_BRANCHES[@]}"; do
  207. emit "$key" "$(resolve_sha https://gitlab.com/simonpunk/susfs4ksu.git refs/heads/${SUSFS_BRANCHES[$key]})"
  208. done
  209. # Tracked build helpers (resolved automatically, before the run)
  210. emit kernel_patches_commit "$(resolve_sha https://github.com/WildKernels/kernel_patches.git refs/heads/main)"
  211. emit anykernel3_commit "$(resolve_sha https://github.com/WildKernels/AnyKernel3.git refs/heads/gki-2.0)"
  212. emit droidspaces_commit "$(resolve_sha https://github.com/ravindu644/Droidspaces-OSS.git refs/heads/main)"
  213. echo "Resolved:"
  214. env | grep -E '^(nomount_commit|kernelsu_commit|kernelsu_branch|root_commit|susfs_commit_|kernel_patches_commit|anykernel3_commit|droidspaces_commit)' | sort
  215. - name: Compose requested feature set
  216. id: features
  217. shell: bash
  218. run: |
  219. set -euo pipefail
  220. # SUSFS needs a root implementation (KernelSU / KernelSU-Next / ReSukiSU)
  221. # to hook into. Without one the kernel wouldn't actually exercise the
  222. # SUSFS root-hiding patches, so fail fast instead of building a useless kernel.
  223. if [ "${{ inputs.use_susfs }}" = "true" ] && [ "${{ inputs.root_flavor }}" = "none" ]; then
  224. echo "ERROR: SUSFS requires a root implementation, but root_flavor is 'none'." >&2
  225. echo "Pick KernelSU-Next, KernelSU, or ReSukiSU in the Root Implementation box" >&2
  226. echo "(SUSFS patches SUSFS's root-hiding on top of the root solution)." >&2
  227. exit 1
  228. fi
  229. # A Release/Pre-Release always links the KernelSU-Next manager built on the
  230. # official repo (build-manager-ci). If a different root was selected, the
  231. # release notes would reference a manager link that doesn't match the
  232. # kernel's actual root implementation.
  233. if { [ "${{ inputs.release_type }}" = "Release" ] || [ "${{ inputs.release_type }}" = "Pre-Release" ]; } && [ "${{ inputs.root_flavor }}" != "KernelSU-Next" ]; then
  234. echo "ERROR: Release/Pre-Release requires Root Implementation 'KernelSU-Next'." >&2
  235. echo "Releases link the official KernelSU-Next manager; select KernelSU-Next" >&2
  236. echo "(or use Release Type 'Action' for other root flavors)." >&2
  237. exit 1
  238. fi
  239. FEATURES=""
  240. [ "${{ inputs.use_susfs }}" = "true" ] && FEATURES="${FEATURES}SUSFS+"
  241. [ "${{ inputs.use_nomount }}" = "true" ] && FEATURES="${FEATURES}NoMount+"
  242. [ "${{ inputs.use_bbg }}" = "true" ] && FEATURES="${FEATURES}BBG+"
  243. [ "${{ inputs.use_net }}" = "true" ] && FEATURES="${FEATURES}NET+"
  244. [ "${{ inputs.use_ds }}" = "true" ] && FEATURES="${FEATURES}DS+"
  245. [ "${{ inputs.use_ntsync }}" = "true" ] && FEATURES="${FEATURES}NTSync+"
  246. [ "${{ inputs.use_ptrace }}" = "true" ] && FEATURES="${FEATURES}Ptrace+"
  247. [ "${{ inputs.use_unicode }}" = "true" ] && FEATURES="${FEATURES}Unicode+"
  248. [ "${{ inputs.use_bpf }}" = "true" ] && FEATURES="${FEATURES}BPF+"
  249. [ "${{ inputs.use_perf }}" = "true" ] && FEATURES="${FEATURES}Perf+"
  250. echo "feature_set=${FEATURES%+}" >> "$GITHUB_OUTPUT"
  251. - name: Clone shared source repos once
  252. if: ${{ inputs.use_nomount }}
  253. shell: bash
  254. run: |
  255. set -euo pipefail
  256. mkdir -p sources
  257. # NoMount kernel sources at the resolved dev tip
  258. git clone --depth=1 --branch dev https://github.com/maxsteeel/nomount.git sources/nomount
  259. [ "$(git -C sources/nomount rev-parse HEAD)" = "${{ steps.resolve.outputs.nomount_commit }}" ] || \
  260. { echo "NoMount clone HEAD mismatch" >&2; exit 1; }
  261. echo "sources_dir=$PWD/sources" >> "$GITHUB_ENV"
  262. - name: Upload sources artifact
  263. if: ${{ inputs.use_nomount }}
  264. uses: actions/upload-artifact@v7
  265. with:
  266. name: sources
  267. path: sources
  268. retention-days: 1
  269. if-no-files-found: error
  270. compression-level: 9
  271. build-nomount-module:
  272. needs: resolve-sources
  273. runs-on: ubuntu-latest
  274. steps:
  275. - uses: actions/checkout@v7
  276. if: ${{ inputs.use_nomount }}
  277. - name: Build NoMount metamodule
  278. id: nomount-metamodule
  279. if: ${{ inputs.use_nomount }}
  280. uses: ./.github/actions/nomount-metamodule
  281. with:
  282. commit: ${{ needs.resolve-sources.outputs.nomount_commit }}
  283. - name: Upload NoMount metamodule
  284. if: ${{ inputs.use_nomount }}
  285. uses: actions/upload-artifact@v7
  286. with:
  287. name: NoMount-Metamodule
  288. path: ${{ steps.nomount-metamodule.outputs.module_path }}
  289. if-no-files-found: error
  290. compression-level: 0
  291. build-fuse-bpf:
  292. needs: resolve-sources
  293. runs-on: ubuntu-latest
  294. steps:
  295. - uses: actions/checkout@v7
  296. if: ${{ inputs.use_bpf }}
  297. - name: Sparse-checkout FUSE-BPF source from kernel/common (android16-6.12-lts)
  298. if: ${{ inputs.use_bpf }}
  299. shell: bash
  300. run: |
  301. set -euo pipefail
  302. # Only the daemon source + the headers it compiles against are needed,
  303. # NOT the full ~16GB kernel tree (which includes ~12GB of prebuilts).
  304. git clone --depth 1 --filter=blob:none --sparse \
  305. --branch android16-6.12-lts \
  306. https://android.googlesource.com/kernel/common \
  307. "${{ github.workspace }}/kernel/common"
  308. cd "${{ github.workspace }}/kernel/common"
  309. git sparse-checkout set \
  310. tools/testing/selftests/filesystems/fuse \
  311. include \
  312. arch/arm64/include \
  313. tools/testing/selftests
  314. - name: Build FUSE-BPF Userspace Daemon (Issue #211)
  315. if: ${{ inputs.use_bpf }}
  316. uses: ./.github/actions/fuse-bpf
  317. with:
  318. version: android16-6.12
  319. kernel_version: 6.12
  320. android_version: android16
  321. build-android12-5-10:
  322. needs:
  323. - prepare-ccache
  324. - resolve-sources
  325. if: ${{ !inputs.test_release_notes && (inputs.kernel_build_version == 'All' || inputs.kernel_build_version == 'android12-5.10') }}
  326. uses: ./.github/workflows/prepare.yml
  327. with:
  328. config_file: .github/config/android12-5.10.json
  329. feature_set: ${{ needs.resolve-sources.outputs.feature_set }}
  330. susfs_commit: ${{ needs.resolve-sources.outputs.susfs_commit_android12_5_10 }}
  331. nomount_commit: ${{ needs.resolve-sources.outputs.nomount_commit }}
  332. kernel_patches_commit: ${{ needs.resolve-sources.outputs.kernel_patches_commit }}
  333. root_flavor: ${{ needs.resolve-sources.outputs.root_flavor }}
  334. root_commit: ${{ needs.resolve-sources.outputs.root_commit }}
  335. ksu_branch: ${{ needs.resolve-sources.outputs.kernelsu_commit }}
  336. anykernel3_commit: ${{ needs.resolve-sources.outputs.anykernel3_commit }}
  337. droidspaces_commit: ${{ needs.resolve-sources.outputs.droidspaces_commit }}
  338. brand_name: ${{ inputs.brand_name }}
  339. secrets: inherit
  340. build-android13-5-10:
  341. needs:
  342. - prepare-ccache
  343. - resolve-sources
  344. if: ${{ !inputs.test_release_notes && (inputs.kernel_build_version == 'All' || inputs.kernel_build_version == 'android13-5.10') }}
  345. uses: ./.github/workflows/prepare.yml
  346. with:
  347. config_file: .github/config/android13-5.10.json
  348. feature_set: ${{ needs.resolve-sources.outputs.feature_set }}
  349. susfs_commit: ${{ needs.resolve-sources.outputs.susfs_commit_android13_5_10 }}
  350. nomount_commit: ${{ needs.resolve-sources.outputs.nomount_commit }}
  351. kernel_patches_commit: ${{ needs.resolve-sources.outputs.kernel_patches_commit }}
  352. root_flavor: ${{ needs.resolve-sources.outputs.root_flavor }}
  353. root_commit: ${{ needs.resolve-sources.outputs.root_commit }}
  354. ksu_branch: ${{ needs.resolve-sources.outputs.kernelsu_commit }}
  355. anykernel3_commit: ${{ needs.resolve-sources.outputs.anykernel3_commit }}
  356. droidspaces_commit: ${{ needs.resolve-sources.outputs.droidspaces_commit }}
  357. brand_name: ${{ inputs.brand_name }}
  358. secrets: inherit
  359. build-android13-5-15:
  360. needs:
  361. - prepare-ccache
  362. - resolve-sources
  363. if: ${{ !inputs.test_release_notes && (inputs.kernel_build_version == 'All' || inputs.kernel_build_version == 'android13-5.15') }}
  364. uses: ./.github/workflows/prepare.yml
  365. with:
  366. config_file: .github/config/android13-5.15.json
  367. feature_set: ${{ needs.resolve-sources.outputs.feature_set }}
  368. susfs_commit: ${{ needs.resolve-sources.outputs.susfs_commit_android13_5_15 }}
  369. nomount_commit: ${{ needs.resolve-sources.outputs.nomount_commit }}
  370. kernel_patches_commit: ${{ needs.resolve-sources.outputs.kernel_patches_commit }}
  371. root_flavor: ${{ needs.resolve-sources.outputs.root_flavor }}
  372. root_commit: ${{ needs.resolve-sources.outputs.root_commit }}
  373. ksu_branch: ${{ needs.resolve-sources.outputs.kernelsu_commit }}
  374. anykernel3_commit: ${{ needs.resolve-sources.outputs.anykernel3_commit }}
  375. droidspaces_commit: ${{ needs.resolve-sources.outputs.droidspaces_commit }}
  376. brand_name: ${{ inputs.brand_name }}
  377. secrets: inherit
  378. build-android14-5-15:
  379. needs:
  380. - prepare-ccache
  381. - resolve-sources
  382. if: ${{ !inputs.test_release_notes && (inputs.kernel_build_version == 'All' || inputs.kernel_build_version == 'android14-5.15') }}
  383. uses: ./.github/workflows/prepare.yml
  384. with:
  385. config_file: .github/config/android14-5.15.json
  386. feature_set: ${{ needs.resolve-sources.outputs.feature_set }}
  387. susfs_commit: ${{ needs.resolve-sources.outputs.susfs_commit_android14_5_15 }}
  388. nomount_commit: ${{ needs.resolve-sources.outputs.nomount_commit }}
  389. kernel_patches_commit: ${{ needs.resolve-sources.outputs.kernel_patches_commit }}
  390. root_flavor: ${{ needs.resolve-sources.outputs.root_flavor }}
  391. root_commit: ${{ needs.resolve-sources.outputs.root_commit }}
  392. ksu_branch: ${{ needs.resolve-sources.outputs.kernelsu_commit }}
  393. anykernel3_commit: ${{ needs.resolve-sources.outputs.anykernel3_commit }}
  394. droidspaces_commit: ${{ needs.resolve-sources.outputs.droidspaces_commit }}
  395. brand_name: ${{ inputs.brand_name }}
  396. secrets: inherit
  397. build-android14-6-1:
  398. needs:
  399. - prepare-ccache
  400. - resolve-sources
  401. if: ${{ !inputs.test_release_notes && (inputs.kernel_build_version == 'All' || inputs.kernel_build_version == 'android14-6.1') }}
  402. uses: ./.github/workflows/prepare.yml
  403. with:
  404. config_file: .github/config/android14-6.1.json
  405. feature_set: ${{ needs.resolve-sources.outputs.feature_set }}
  406. susfs_commit: ${{ needs.resolve-sources.outputs.susfs_commit_android14_6_1 }}
  407. nomount_commit: ${{ needs.resolve-sources.outputs.nomount_commit }}
  408. kernel_patches_commit: ${{ needs.resolve-sources.outputs.kernel_patches_commit }}
  409. root_flavor: ${{ needs.resolve-sources.outputs.root_flavor }}
  410. root_commit: ${{ needs.resolve-sources.outputs.root_commit }}
  411. ksu_branch: ${{ needs.resolve-sources.outputs.kernelsu_commit }}
  412. anykernel3_commit: ${{ needs.resolve-sources.outputs.anykernel3_commit }}
  413. droidspaces_commit: ${{ needs.resolve-sources.outputs.droidspaces_commit }}
  414. brand_name: ${{ inputs.brand_name }}
  415. secrets: inherit
  416. build-android15-6-6:
  417. needs:
  418. - prepare-ccache
  419. - resolve-sources
  420. if: ${{ !inputs.test_release_notes && (inputs.kernel_build_version == 'All' || inputs.kernel_build_version == 'android15-6.6') }}
  421. uses: ./.github/workflows/prepare.yml
  422. with:
  423. config_file: .github/config/android15-6.6.json
  424. feature_set: ${{ needs.resolve-sources.outputs.feature_set }}
  425. susfs_commit: ${{ needs.resolve-sources.outputs.susfs_commit_android15_6_6 }}
  426. nomount_commit: ${{ needs.resolve-sources.outputs.nomount_commit }}
  427. kernel_patches_commit: ${{ needs.resolve-sources.outputs.kernel_patches_commit }}
  428. root_flavor: ${{ needs.resolve-sources.outputs.root_flavor }}
  429. root_commit: ${{ needs.resolve-sources.outputs.root_commit }}
  430. ksu_branch: ${{ needs.resolve-sources.outputs.kernelsu_commit }}
  431. anykernel3_commit: ${{ needs.resolve-sources.outputs.anykernel3_commit }}
  432. droidspaces_commit: ${{ needs.resolve-sources.outputs.droidspaces_commit }}
  433. brand_name: ${{ inputs.brand_name }}
  434. secrets: inherit
  435. build-android16-6-12:
  436. needs:
  437. - prepare-ccache
  438. - resolve-sources
  439. if: ${{ !inputs.test_release_notes && (inputs.kernel_build_version == 'All' || inputs.kernel_build_version == 'android16-6.12') }}
  440. uses: ./.github/workflows/prepare.yml
  441. with:
  442. config_file: .github/config/android16-6.12.json
  443. feature_set: ${{ needs.resolve-sources.outputs.feature_set }}
  444. susfs_commit: ${{ needs.resolve-sources.outputs.susfs_commit_android16_6_12 }}
  445. nomount_commit: ${{ needs.resolve-sources.outputs.nomount_commit }}
  446. kernel_patches_commit: ${{ needs.resolve-sources.outputs.kernel_patches_commit }}
  447. root_flavor: ${{ needs.resolve-sources.outputs.root_flavor }}
  448. root_commit: ${{ needs.resolve-sources.outputs.root_commit }}
  449. ksu_branch: ${{ needs.resolve-sources.outputs.kernelsu_commit }}
  450. anykernel3_commit: ${{ needs.resolve-sources.outputs.anykernel3_commit }}
  451. droidspaces_commit: ${{ needs.resolve-sources.outputs.droidspaces_commit }}
  452. brand_name: ${{ inputs.brand_name }}
  453. secrets: inherit
  454. rej:
  455. if: ${{ !inputs.test_release_notes && always() }}
  456. runs-on: ubuntu-latest
  457. permissions:
  458. actions: read
  459. contents: read
  460. needs:
  461. - build-android12-5-10
  462. - build-android13-5-10
  463. - build-android13-5-15
  464. - build-android14-5-15
  465. - build-android14-6-1
  466. - build-android15-6-6
  467. - build-android16-6-12
  468. steps:
  469. - name: Download Misc Artifacts
  470. uses: actions/download-artifact@v7
  471. with:
  472. path: ./downloaded-artifacts
  473. pattern: '*-Rejects'
  474. merge-multiple: false
  475. - name: Process Reject Artifacts
  476. run: |
  477. mkdir -p aio-rejects
  478. # Iterate over Rejects artifacts in downloaded-artifacts
  479. for dir in ./downloaded-artifacts/*-Rejects; do
  480. [ -d "$dir" ] || continue
  481. dirname=$(basename "$dir")
  482. original_name=${dirname%-Rejects}
  483. source_dir="$dir"
  484. if [ -d "$dir/patch-rejects" ]; then
  485. source_dir="$dir/patch-rejects"
  486. fi
  487. mapfile -t rej_files < <(find "$source_dir" -type f -name '*.rej' | sort)
  488. filtered_rej_files=()
  489. for rej_file in "${rej_files[@]}"; do
  490. rel_rej="${rej_file#${source_dir}/}"
  491. rel_name="$(basename "$rel_rej")"
  492. if [ "$rel_rej" = "common/mm/rmap.c.rej" ] || [ "$rel_name" = "i2c-nomadik.c.rej" ]; then
  493. echo "Skipping $rel_rej because it is an ignored reject file"
  494. continue
  495. fi
  496. filtered_rej_files+=("$rej_file")
  497. done
  498. if [ "${#filtered_rej_files[@]}" -eq 0 ]; then
  499. echo "Skipping $dirname because it only contains ignored reject files"
  500. continue
  501. fi
  502. mkdir -p "aio-rejects/$original_name"
  503. if [ -d "$dir/patch-rejects" ]; then
  504. cp -r "$dir/patch-rejects/." "aio-rejects/$original_name/"
  505. else
  506. cp -r "$dir/." "aio-rejects/$original_name/"
  507. fi
  508. find "aio-rejects/$original_name" -type f -name 'i2c-nomadik.c.rej' -delete
  509. done
  510. if [ "$(ls -A aio-rejects)" ]; then
  511. cd aio-rejects
  512. zip -r -q -9 ../AIO-REJ.zip .
  513. cd ..
  514. else
  515. echo "No rejects found to upload."
  516. fi
  517. - name: Rejects Summary
  518. run: |
  519. echo "Reject artifacts were collected locally only and are not uploaded." >> "$GITHUB_STEP_SUMMARY"
  520. - name: Upload AIO-REJ Artifact
  521. uses: actions/upload-artifact@v7
  522. with:
  523. name: AIO-REJ
  524. path: AIO-REJ.zip
  525. if-no-files-found: ignore
  526. summary:
  527. if: ${{ !inputs.test_release_notes && always() }}
  528. runs-on: ubuntu-latest
  529. permissions:
  530. actions: write
  531. contents: read
  532. needs:
  533. - resolve-sources
  534. - build-android12-5-10
  535. - build-android13-5-10
  536. - build-android13-5-15
  537. - build-android14-5-15
  538. - build-android14-6-1
  539. - build-android15-6-6
  540. - build-android16-6-12
  541. steps:
  542. - name: Download All Build Summaries
  543. uses: actions/download-artifact@v7
  544. with:
  545. path: ./summaries
  546. pattern: '*-Summary'
  547. merge-multiple: true
  548. - name: 📋 Workflow Build Summary
  549. run: |
  550. {
  551. echo "# 📋 Build Summary — $(date -u '+%Y-%m-%d %H:%M UTC')"
  552. echo
  553. echo "**Feature Set:** ${{ needs.resolve-sources.outputs.feature_set }}"
  554. echo "**Root Flavor:** ${{ inputs.root_flavor || 'none' }}"
  555. echo "**Brand:** ${{ inputs.brand_name || 'Wild' }}"
  556. echo
  557. # Count successes and failures
  558. SUCCESS_COUNT=0
  559. FAIL_COUNT=0
  560. # Sort summaries so they appear in a consistent order
  561. for f in ./summaries/*.md; do
  562. [ -f "$f" ] || continue
  563. if grep -q "✅ Success" "$f"; then
  564. SUCCESS_COUNT=$((SUCCESS_COUNT + 1))
  565. else
  566. FAIL_COUNT=$((FAIL_COUNT + 1))
  567. fi
  568. done
  569. TOTAL=$((SUCCESS_COUNT + FAIL_COUNT))
  570. echo "**Results:** ${SUCCESS_COUNT}/${TOTAL} succeeded"
  571. if [ "$FAIL_COUNT" -gt 0 ]; then
  572. echo " - ❌ ${FAIL_COUNT} failed"
  573. fi
  574. echo
  575. echo "---"
  576. echo
  577. # Output each summary
  578. for f in ./summaries/*.md; do
  579. [ -f "$f" ] || continue
  580. cat "$f"
  581. echo
  582. echo "---"
  583. echo
  584. done
  585. echo
  586. echo "> **SUSFS Commits:**"
  587. echo "> - android12-5.10: ${{ needs.resolve-sources.outputs.susfs_commit_android12_5_10 }}"
  588. echo "> - android13-5.10: ${{ needs.resolve-sources.outputs.susfs_commit_android13_5_10 }}"
  589. echo "> - android13-5.15: ${{ needs.resolve-sources.outputs.susfs_commit_android13_5_15 }}"
  590. echo "> - android14-5.15: ${{ needs.resolve-sources.outputs.susfs_commit_android14_5_15 }}"
  591. echo "> - android14-6.1: ${{ needs.resolve-sources.outputs.susfs_commit_android14_6_1 }}"
  592. echo "> - android15-6.6: ${{ needs.resolve-sources.outputs.susfs_commit_android15_6_6 }}"
  593. echo "> - android16-6.12: ${{ needs.resolve-sources.outputs.susfs_commit_android16_6_12 }}"
  594. } >> "$GITHUB_STEP_SUMMARY"
  595. - name: 🧹 Cleanup Summary Files
  596. if: ${{ always() }}
  597. run: rm -rf ./summaries
  598. - name: 🧹 Delete Summary Artifacts
  599. if: ${{ always() }}
  600. env:
  601. GH_TOKEN: ${{ github.token }}
  602. run: |
  603. # Delete all *-Summary artifacts from this run since they're now consolidated
  604. RUN_ID="${{ github.run_id }}"
  605. ARTIFACTS=$(gh api "repos/${{ github.repository }}/actions/runs/${RUN_ID}/artifacts" --jq '.artifacts[] | select(.name | endswith("-Summary")) | .id')
  606. for id in $ARTIFACTS; do
  607. echo "Deleting summary artifact id=$id"
  608. gh api -X DELETE "repos/${{ github.repository }}/actions/artifacts/${id}" || true
  609. done
  610. release:
  611. runs-on: ubuntu-latest
  612. if: ${{ github.event_name == 'workflow_dispatch' && !inputs.test_release_notes && (inputs.release_type == 'Pre-Release' || inputs.release_type == 'Release') }}
  613. permissions:
  614. contents: write
  615. needs:
  616. - build-android12-5-10
  617. - build-android13-5-10
  618. - build-android13-5-15
  619. - build-android14-5-15
  620. - build-android14-6-1
  621. - build-android15-6-6
  622. - build-android16-6-12
  623. - build-nomount-module
  624. env:
  625. GH_TOKEN: ${{ github.token }}
  626. RELEASE_NOTES: .github/config/RELEASE_NOTES.md
  627. outputs:
  628. new_tag: ${{ steps.tag.outputs.new_tag }}
  629. steps:
  630. - name: Validate Selected Builds
  631. run: |
  632. set -euo pipefail
  633. failed=0
  634. current_type="${{ inputs.kernel_build_version }}"
  635. check_selected() {
  636. local target="$1"
  637. local job_name="$2"
  638. local result="$3"
  639. if [[ "$current_type" == "all" || "$current_type" == "$target" ]]; then
  640. if [[ "$result" != "success" ]]; then
  641. echo "Required job $job_name did not succeed (result: $result)"
  642. failed=1
  643. fi
  644. fi
  645. }
  646. check_selected "android12-5.10" "build-android12-5-10" "${{ needs.build-android12-5-10.result }}"
  647. check_selected "android13-5.10" "build-android13-5-10" "${{ needs.build-android13-5-10.result }}"
  648. check_selected "android13-5.15" "build-android13-5-15" "${{ needs.build-android13-5-15.result }}"
  649. check_selected "android14-5.15" "build-android14-5-15" "${{ needs.build-android14-5-15.result }}"
  650. check_selected "android14-6.1" "build-android14-6-1" "${{ needs.build-android14-6-1.result }}"
  651. check_selected "android15-6.6" "build-android15-6-6" "${{ needs.build-android15-6-6.result }}"
  652. check_selected "android16-6.12" "build-android16-6-12" "${{ needs.build-android16-6-12.result }}"
  653. if [[ "$failed" -ne 0 ]]; then
  654. exit 1
  655. fi
  656. - name: Free Disk Space
  657. if: true
  658. uses: endersonmenezes/free-disk-space@v3 # Use @main for latest, @v3 for stable
  659. with:
  660. remove_android: true
  661. remove_dotnet: true
  662. remove_haskell: true
  663. remove_tool_cache: true
  664. remove_swap: true
  665. remove_packages: "azure-cli google-cloud-cli microsoft-edge-stable google-chrome-stable firefox postgresql* temurin-* *llvm* mysql* dotnet-sdk-*"
  666. remove_packages_one_command: true
  667. 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"
  668. rm_cmd: "rmz" # Use 'rmz' for faster deletion (default: 'rm')
  669. rmz_version: "3.1.1" # Required when rm_cmd is 'rmz'
  670. testing: false
  671. - name: Checkout code
  672. uses: actions/checkout@v7
  673. - name: Generate New Tag
  674. id: tag
  675. if: inputs.release_type != 'Action'
  676. run: |
  677. mapfile -t RELEASE_TAGS < <(gh api --paginate "repos/${{ github.repository }}/tags?per_page=100" --jq '.[].name' 2>/dev/null | grep -E '^r[0-9]+$' || true)
  678. LATEST_REV=0
  679. for TAG in "${RELEASE_TAGS[@]}"; do
  680. REV="${TAG#r}"
  681. if [[ "$REV" =~ ^[0-9]+$ && "$REV" -gt "$LATEST_REV" ]]; then
  682. LATEST_REV="$REV"
  683. fi
  684. done
  685. if [[ "$LATEST_REV" -gt 0 ]]; then
  686. NEW_TAG="r$((LATEST_REV + 1))"
  687. else
  688. NEW_TAG="r1"
  689. fi
  690. if [[ ${#RELEASE_TAGS[@]} -gt 0 ]]; then
  691. echo "Latest r-tag: r${LATEST_REV}"
  692. else
  693. echo "No existing r-tags found; starting at r1"
  694. fi
  695. echo "New tag: $NEW_TAG"
  696. echo "NEW_TAG=${NEW_TAG}" >> $GITHUB_ENV
  697. echo "new_tag=$NEW_TAG" >> $GITHUB_OUTPUT
  698. - name: Set Release Title
  699. id: release_meta
  700. run: |
  701. set -euo pipefail
  702. # Format release title: convert rN -> Release N
  703. if [[ "${NEW_TAG}" =~ ^r([0-9]+)$ ]]; then
  704. REV_NUM="${BASH_REMATCH[1]}"
  705. release_title="Release ${REV_NUM}"
  706. else
  707. release_title="Release ${NEW_TAG}"
  708. fi
  709. echo "release_title=$release_title" >> "$GITHUB_OUTPUT"
  710. - name: Extract KernelSU Version Info
  711. id: ksu_version
  712. run: |
  713. set -euo pipefail
  714. KSU_REPO="https://github.com/pershoot/KernelSU-Next.git"
  715. KSU_INPUT="dev-susfs"
  716. # Try as branch first, fall back to commit
  717. if git ls-remote --heads "$KSU_REPO" "$KSU_INPUT" | grep -q .; then
  718. echo "Cloning KernelSU-Next from branch: $KSU_INPUT"
  719. git clone --branch "$KSU_INPUT" "$KSU_REPO" /tmp/kernelsu-next
  720. cd /tmp/kernelsu-next
  721. KSUN_COMMIT=$(git rev-parse HEAD)
  722. else
  723. echo "Cloning KernelSU-Next from dev-susfs branch, then checking out commit: $KSU_INPUT"
  724. git clone --branch dev-susfs "$KSU_REPO" /tmp/kernelsu-next
  725. cd /tmp/kernelsu-next
  726. git fetch --depth=50 origin "$KSU_INPUT"
  727. git checkout "$KSU_INPUT"
  728. KSUN_COMMIT="$KSU_INPUT"
  729. fi
  730. # The manager is built on the OFFICIAL KernelSU-Next repo
  731. # (pershoot's workflows are all disabled). Find the official dev
  732. # commit this fork's branch is synced with (merge-base of our
  733. # branch vs official dev), then link the manager build run for
  734. # that commit. pershoot's own dev branch is intentionally ignored.
  735. retry() {
  736. local n=0
  737. until [ "$n" -ge 5 ]; do
  738. "$@" && return 0
  739. n=$((n+1))
  740. echo "retry $n/5 failed for: $*" >&2
  741. sleep 5
  742. done
  743. return 1
  744. }
  745. OFFICIAL_KSU_REPO="https://github.com/KernelSU-Next/KernelSU-Next.git"
  746. retry git fetch "$OFFICIAL_KSU_REPO" dev
  747. STOCK_COMMIT=$(git merge-base HEAD FETCH_HEAD)
  748. echo "KSU Stock Commit (official sync point): $STOCK_COMMIT"
  749. # Extract version info — anchored to the official sync point
  750. # (STOCK_COMMIT), i.e. the commit the linked manager is built from.
  751. # Mirrors pershoot c0a2c5fd: count the merge-base with origin, not
  752. # the fork's extra commits, so the version shown in the release
  753. # notes matches what the kernel reports and the manager displays.
  754. COMMITS_COUNT=$(git rev-list --count "$STOCK_COMMIT")
  755. BASE_VERSION=30000
  756. KSU_VERSION=$(expr $COMMITS_COUNT "+" $BASE_VERSION)
  757. # Extract git tag at the sync point
  758. KSU_GIT_TAG=$(git describe --tags --abbrev=0 "$STOCK_COMMIT" 2>/dev/null || echo "no-tag")
  759. MANAGER_RUN_ID=$(curl -fsSL --retry 5 --retry-delay 5 --retry-all-errors "https://api.github.com/repos/KernelSU-Next/KernelSU-Next/actions/workflows/build-manager-ci.yml/runs?head_sha=${STOCK_COMMIT}" | jq -r '.workflow_runs[0].id // empty')
  760. if [[ -n "${MANAGER_RUN_ID:-}" ]]; then
  761. KSU_MANAGER="https://github.com/KernelSU-Next/KernelSU-Next/actions/runs/${MANAGER_RUN_ID}"
  762. KSU_MANAGER_NOTE="exact build for initialized commit ${STOCK_COMMIT:0:12}"
  763. else
  764. # No run indexed for the stock commit (e.g. official dev was force-pushed/rebase).
  765. # Fall back to the build-manager run for the CURRENT official dev tip so the
  766. # release still gets a real manager build to link to.
  767. echo "No manager run found for stock commit ${STOCK_COMMIT}; falling back to latest dev tip." >&2
  768. MANAGER_RUN_ID=$(curl -fsSL --retry 5 --retry-delay 5 --retry-all-errors "https://api.github.com/repos/KernelSU-Next/KernelSU-Next/actions/workflows/build-manager-ci.yml/runs?branch=dev" | jq -r '.workflow_runs[0].id // empty')
  769. if [[ -n "${MANAGER_RUN_ID:-}" ]]; then
  770. KSU_MANAGER="https://github.com/KernelSU-Next/KernelSU-Next/actions/runs/${MANAGER_RUN_ID}"
  771. KSU_MANAGER_NOTE="latest official dev branch build-manager run (fallback)"
  772. else
  773. KSU_MANAGER="https://github.com/KernelSU-Next/KernelSU-Next/actions/workflows/build-manager-ci.yml"
  774. KSU_MANAGER_NOTE="no manager run found"
  775. fi
  776. fi
  777. echo "Commits count: $COMMITS_COUNT"
  778. echo "KSU Version: $KSU_VERSION"
  779. echo "KSU Git Tag: $KSU_GIT_TAG"
  780. echo "KSU Manager: $KSU_MANAGER"
  781. # Export as environment for next step
  782. echo "KSUN_BRANCH=$KSU_INPUT" >> $GITHUB_ENV
  783. echo "KSUN_COMMIT=$KSUN_COMMIT" >> $GITHUB_ENV
  784. echo "KSU_COMMITS_COUNT=$COMMITS_COUNT" >> $GITHUB_ENV
  785. echo "KSU_VERSION=$KSU_VERSION" >> $GITHUB_ENV
  786. echo "KSU_GIT_TAG=$KSU_GIT_TAG" >> $GITHUB_ENV
  787. echo "KSU_MANAGER=$KSU_MANAGER" >> $GITHUB_ENV
  788. echo "KSU_MANAGER_NOTE=${KSU_MANAGER_NOTE:-}" >> $GITHUB_ENV
  789. - name: Set release body
  790. run: |
  791. set -e
  792. RELEASE_NOTES_PATH="$RELEASE_NOTES"
  793. : > release_body.md
  794. python3 .github/scripts/render_release_body.py "$RELEASE_NOTES_PATH" > release_body.md
  795. - name: Publish release notes preview
  796. run: |
  797. {
  798. echo "## Release Notes Preview"
  799. echo
  800. cat release_body.md
  801. } >> "$GITHUB_STEP_SUMMARY"
  802. - name: Download AnyKernel3 Artifacts
  803. uses: actions/download-artifact@v7
  804. with:
  805. path: release-assets
  806. pattern: '*-AnyKernel3'
  807. merge-multiple: false
  808. - name: Download NoMount metamodule
  809. uses: actions/download-artifact@v7
  810. with:
  811. path: release-assets
  812. pattern: '*NoMount-Metamodule'
  813. merge-multiple: false
  814. if-no-files-found: ignore
  815. - name: Zip AnyKernel3 for Release
  816. run: |
  817. set -e
  818. shopt -s nullglob
  819. for dir in release-assets/*-AnyKernel3; do
  820. zip_name="${dir}.zip"
  821. rm -f "$zip_name"
  822. cd "$dir"
  823. zip -r -q -9 "../$(basename "$zip_name")" .
  824. cd - >/dev/null
  825. done
  826. - name: Create Release
  827. uses: softprops/action-gh-release@v1
  828. with:
  829. tag_name: ${{ steps.tag.outputs.new_tag }}
  830. name: ${{ steps.release_meta.outputs.release_title }}
  831. body_path: release_body.md
  832. draft: false
  833. prerelease: ${{ inputs.release_type == 'Pre-Release' }}
  834. files: |
  835. release-assets/**/*.zip
  836. release-assets/**/*-boot*.img