main.yml 31 KB

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