main.yml 28 KB

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