main.yml 35 KB

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