main.yml 39 KB

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