main.yml 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519
  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: Actions
  16. kernel_build_version:
  17. description: "Kernel Version"
  18. type: choice
  19. options:
  20. - All
  21. - a12-5-10
  22. - a13-5-10
  23. - a13-5-15
  24. - a14-5-15
  25. - a14-6-1
  26. - a15-6-6
  27. - a16-6-12
  28. default: All
  29. feature_set:
  30. description: "Feature Set"
  31. type: choice
  32. options:
  33. - KSUN+SUSFS+BBG+NET+DS
  34. - KSUN+SUSFS+BBG
  35. - KSUN+SUSFS+NET
  36. - KSUN+SUSFS+DS
  37. - KSUN+SUSFS
  38. - KSUN+BBG
  39. - KSUN+NET
  40. - KSUN+DS
  41. - KSUN
  42. - BBG
  43. - NET
  44. - DS
  45. - NONE
  46. - FULL
  47. default: FULL
  48. ksu_commit:
  49. description: "KSU Commit (optional)"
  50. type: string
  51. default: ""
  52. required: false
  53. variant:
  54. description: "Build Variant"
  55. type: choice
  56. options:
  57. - All
  58. - Normal
  59. - Bypass
  60. - Wild
  61. default: Normal
  62. use_repo:
  63. description: "Use repo for downloading kernel source"
  64. type: boolean
  65. default: false
  66. jobs:
  67. fetch-commits:
  68. runs-on: ubuntu-latest
  69. outputs:
  70. ksu_commit: ${{ steps.fetch.outputs.ksu_commit }}
  71. anykernel_commit: ${{ steps.fetch.outputs.anykernel_commit }}
  72. patches_commit: ${{ steps.fetch.outputs.patches_commit }}
  73. susfs_commit: ${{ steps.fetch.outputs.susfs_commit }}
  74. steps:
  75. - name: Checkout Repository
  76. uses: actions/checkout@v5
  77. - name: Fetch Commits
  78. id: fetch
  79. uses: ./.github/actions/fetch-commits
  80. with:
  81. ksu_commit: ${{ inputs.ksu_commit }}
  82. build-a12-5-10:
  83. if: ${{ inputs.kernel_build_version == 'All' || inputs.kernel_build_version == 'a12-5-10' }}
  84. needs: fetch-commits
  85. uses: ./.github/workflows/prepare.yml
  86. with:
  87. config_file: .github/kernel-config/a12-5.10.json
  88. ksu_commit: ${{ inputs.ksu_commit || needs.fetch-commits.outputs.ksu_commit }}
  89. anykernel_commit: ${{ needs.fetch-commits.outputs.anykernel_commit }}
  90. patches_commit: ${{ needs.fetch-commits.outputs.patches_commit }}
  91. susfs_commit: ${{ needs.fetch-commits.outputs.susfs_commit }}
  92. feature_set: ${{ inputs.feature_set || 'FULL' }}
  93. variant: ${{ inputs.variant || 'Normal' }}
  94. use_repo: ${{ inputs.use_repo }}
  95. secrets: inherit
  96. build-a13-5-10:
  97. if: ${{ inputs.kernel_build_version == 'All' || inputs.kernel_build_version == 'a13-5-10' }}
  98. needs: fetch-commits
  99. uses: ./.github/workflows/prepare.yml
  100. with:
  101. config_file: .github/kernel-config/a13-5.10.json
  102. ksu_commit: ${{ inputs.ksu_commit || needs.fetch-commits.outputs.ksu_commit }}
  103. anykernel_commit: ${{ needs.fetch-commits.outputs.anykernel_commit }}
  104. patches_commit: ${{ needs.fetch-commits.outputs.patches_commit }}
  105. susfs_commit: ${{ needs.fetch-commits.outputs.susfs_commit }}
  106. feature_set: ${{ inputs.feature_set || 'FULL' }}
  107. variant: ${{ inputs.variant || 'Normal' }}
  108. use_repo: ${{ inputs.use_repo }}
  109. secrets: inherit
  110. build-a13-5-15:
  111. if: ${{ inputs.kernel_build_version == 'All' || inputs.kernel_build_version == 'a13-5-15' }}
  112. needs: fetch-commits
  113. uses: ./.github/workflows/prepare.yml
  114. with:
  115. config_file: .github/kernel-config/a13-5.15.json
  116. ksu_commit: ${{ inputs.ksu_commit || needs.fetch-commits.outputs.ksu_commit }}
  117. anykernel_commit: ${{ needs.fetch-commits.outputs.anykernel_commit }}
  118. patches_commit: ${{ needs.fetch-commits.outputs.patches_commit }}
  119. susfs_commit: ${{ needs.fetch-commits.outputs.susfs_commit }}
  120. feature_set: ${{ inputs.feature_set || 'FULL' }}
  121. variant: ${{ inputs.variant || 'Normal' }}
  122. use_repo: ${{ inputs.use_repo }}
  123. secrets: inherit
  124. build-a14-5-15:
  125. if: ${{ inputs.kernel_build_version == 'All' || inputs.kernel_build_version == 'a14-5-15' }}
  126. needs: fetch-commits
  127. uses: ./.github/workflows/prepare.yml
  128. with:
  129. config_file: .github/kernel-config/a14-5.15.json
  130. ksu_commit: ${{ inputs.ksu_commit || needs.fetch-commits.outputs.ksu_commit }}
  131. anykernel_commit: ${{ needs.fetch-commits.outputs.anykernel_commit }}
  132. patches_commit: ${{ needs.fetch-commits.outputs.patches_commit }}
  133. susfs_commit: ${{ needs.fetch-commits.outputs.susfs_commit }}
  134. feature_set: ${{ inputs.feature_set || 'FULL' }}
  135. variant: ${{ inputs.variant || 'Normal' }}
  136. use_repo: ${{ inputs.use_repo }}
  137. secrets: inherit
  138. build-a14-6-1:
  139. if: ${{ inputs.kernel_build_version == 'All' || inputs.kernel_build_version == 'a14-6-1' }}
  140. needs: fetch-commits
  141. uses: ./.github/workflows/prepare.yml
  142. with:
  143. config_file: .github/kernel-config/a14-6.1.json
  144. ksu_commit: ${{ inputs.ksu_commit || needs.fetch-commits.outputs.ksu_commit }}
  145. anykernel_commit: ${{ needs.fetch-commits.outputs.anykernel_commit }}
  146. patches_commit: ${{ needs.fetch-commits.outputs.patches_commit }}
  147. susfs_commit: ${{ needs.fetch-commits.outputs.susfs_commit }}
  148. feature_set: ${{ inputs.feature_set || 'FULL' }}
  149. variant: ${{ inputs.variant || 'Normal' }}
  150. use_repo: ${{ inputs.use_repo }}
  151. secrets: inherit
  152. build-a15-6-6:
  153. if: ${{ inputs.kernel_build_version == 'All' || inputs.kernel_build_version == 'a15-6-6' }}
  154. needs: fetch-commits
  155. uses: ./.github/workflows/prepare.yml
  156. with:
  157. config_file: .github/kernel-config/a15-6.6.json
  158. ksu_commit: ${{ inputs.ksu_commit || needs.fetch-commits.outputs.ksu_commit }}
  159. anykernel_commit: ${{ needs.fetch-commits.outputs.anykernel_commit }}
  160. patches_commit: ${{ needs.fetch-commits.outputs.patches_commit }}
  161. susfs_commit: ${{ needs.fetch-commits.outputs.susfs_commit }}
  162. feature_set: ${{ inputs.feature_set || 'FULL' }}
  163. variant: ${{ inputs.variant || 'Normal' }}
  164. use_repo: ${{ inputs.use_repo }}
  165. secrets: inherit
  166. build-a16-6-12:
  167. if: ${{ inputs.kernel_build_version == 'All' || inputs.kernel_build_version == 'a16-6-12' }}
  168. needs: fetch-commits
  169. uses: ./.github/workflows/prepare.yml
  170. with:
  171. config_file: .github/kernel-config/a16-6.12.json
  172. ksu_commit: ${{ inputs.ksu_commit || needs.fetch-commits.outputs.ksu_commit }}
  173. anykernel_commit: ${{ needs.fetch-commits.outputs.anykernel_commit }}
  174. patches_commit: ${{ needs.fetch-commits.outputs.patches_commit }}
  175. susfs_commit: ${{ needs.fetch-commits.outputs.susfs_commit }}
  176. feature_set: ${{ inputs.feature_set || 'FULL' }}
  177. variant: ${{ inputs.variant || 'Normal' }}
  178. use_repo: ${{ inputs.use_repo }}
  179. secrets: inherit
  180. rej:
  181. if: always()
  182. runs-on: ubuntu-latest
  183. permissions:
  184. actions: read
  185. contents: read
  186. needs:
  187. - build-a12-5-10
  188. - build-a13-5-10
  189. - build-a13-5-15
  190. - build-a14-5-15
  191. - build-a14-6-1
  192. - build-a15-6-6
  193. - build-a16-6-12
  194. steps:
  195. - name: Download Misc Artifacts
  196. uses: actions/download-artifact@v7
  197. with:
  198. path: ./downloaded-artifacts
  199. pattern: '*-Normal-Rejects'
  200. merge-multiple: false
  201. - name: Process Reject Artifacts
  202. run: |
  203. mkdir -p aio-rejects
  204. # Iterate over Rejects artifacts in downloaded-artifacts
  205. for dir in ./downloaded-artifacts/*-Rejects; do
  206. # Ensure it is a directory
  207. [ -d "$dir" ] || continue
  208. dirname=$(basename "$dir")
  209. # Process each reject artifact
  210. # Get original name (remove -Rejects suffix)
  211. original_name=${dirname%-Rejects}
  212. mkdir -p "aio-rejects/$original_name"
  213. # Check for patch-rejects folder (legacy structure) or direct contents
  214. if [ -d "$dir/patch-rejects" ]; then
  215. # Legacy structure
  216. cp -r "$dir/patch-rejects/." "aio-rejects/$original_name/"
  217. else
  218. # Current structure
  219. cp -r "$dir/." "aio-rejects/$original_name/"
  220. fi
  221. done
  222. # Zip and upload if we found anything
  223. if [ "$(ls -A aio-rejects)" ]; then
  224. # Create a single zip of all rejects
  225. cd aio-rejects
  226. zip -r -q -9 ../AIO-REJ.zip .
  227. cd ..
  228. else
  229. echo "No rejects found to upload."
  230. fi
  231. - name: Upload AIO-REJ Artifact
  232. uses: actions/upload-artifact@v7
  233. with:
  234. name: AIO-REJ
  235. path: AIO-REJ.zip
  236. if-no-files-found: ignore
  237. release:
  238. runs-on: ubuntu-latest
  239. if: ${{ github.event_name == 'workflow_dispatch' && inputs.release_type != 'Actions' }}
  240. permissions:
  241. contents: write
  242. needs:
  243. - fetch-commits
  244. - build-a12-5-10
  245. - build-a13-5-10
  246. - build-a13-5-15
  247. - build-a14-5-15
  248. - build-a14-6-1
  249. - build-a15-6-6
  250. - build-a16-6-12
  251. env:
  252. GH_TOKEN: ${{ github.token }}
  253. RELEASE_NAME: "GKI Kernels With KernelSU-Next & SUSFS v2.1.0"
  254. RELEASE_BODY: ""
  255. outputs:
  256. new_tag: ${{ steps.tag.outputs.new_tag }}
  257. steps:
  258. - name: Validate Selected Builds
  259. run: |
  260. set -euo pipefail
  261. failed=0
  262. current_type="${{ inputs.kernel_build_version }}"
  263. check_selected() {
  264. local target="$1"
  265. local job_name="$2"
  266. local result="$3"
  267. if [[ "$current_type" == "all" || "$current_type" == "$target" ]]; then
  268. if [[ "$result" != "success" ]]; then
  269. echo "Required job $job_name did not succeed (result: $result)"
  270. failed=1
  271. fi
  272. fi
  273. }
  274. check_selected "a12-5-10" "build-a12-5-10" "${{ needs.build-a12-5-10.result }}"
  275. check_selected "a13-5-10" "build-a13-5-10" "${{ needs.build-a13-5-10.result }}"
  276. check_selected "a13-5-15" "build-a13-5-15" "${{ needs.build-a13-5-15.result }}"
  277. check_selected "a14-5-15" "build-a14-5-15" "${{ needs.build-a14-5-15.result }}"
  278. check_selected "a14-6-1" "build-a14-6-1" "${{ needs.build-a14-6-1.result }}"
  279. check_selected "a15-6-6" "build-a15-6-6" "${{ needs.build-a15-6-6.result }}"
  280. check_selected "a16-6-12" "build-a16-6-12" "${{ needs.build-a16-6-12.result }}"
  281. if [[ "$failed" -ne 0 ]]; then
  282. exit 1
  283. fi
  284. - name: Free Disk Space
  285. if: true
  286. uses: endersonmenezes/free-disk-space@v3 # Use @main for latest, @v3 for stable
  287. with:
  288. remove_android: true
  289. remove_dotnet: true
  290. remove_haskell: true
  291. remove_tool_cache: true
  292. remove_swap: true
  293. remove_packages: "azure-cli google-cloud-cli microsoft-edge-stable google-chrome-stable firefox postgresql* temurin-* *llvm* mysql* dotnet-sdk-*"
  294. remove_packages_one_command: true
  295. 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"
  296. rm_cmd: "rmz" # Use 'rmz' for faster deletion (default: 'rm')
  297. rmz_version: "3.1.1" # Required when rm_cmd is 'rmz'
  298. testing: false
  299. - name: Checkout code
  300. uses: actions/checkout@v5
  301. - name: Generate New Tag
  302. id: tag
  303. if: inputs.release_type != 'Actions'
  304. run: |
  305. LATEST_TAG=$(gh api repos/${{ github.repository }}/tags --jq '.[0].name' 2>/dev/null || echo "v0.0.0")
  306. if [[ -z "$LATEST_TAG" || "$LATEST_TAG" == "null" ]]; then
  307. LATEST_TAG="v0.0.0"
  308. fi
  309. if [[ "$LATEST_TAG" =~ ^(.*)-r([0-9]+)$ ]]; then
  310. VERSION="${BASH_REMATCH[1]}"
  311. REV="${BASH_REMATCH[2]}"
  312. NEW_REV=$((REV + 1))
  313. NEW_TAG="${VERSION}-r${NEW_REV}"
  314. else
  315. NEW_TAG="${LATEST_TAG}-r1"
  316. fi
  317. echo "Latest tag: $LATEST_TAG"
  318. echo "New tag: $NEW_TAG"
  319. echo "NEW_TAG=${NEW_TAG}" >> $GITHUB_ENV
  320. echo "new_tag=$NEW_TAG" >> $GITHUB_OUTPUT
  321. - name: Set release body
  322. run: |
  323. set -e
  324. FEATURE_SET="${{ inputs.feature_set }}"
  325. KSUN_COMMIT="${{ needs.fetch-commits.outputs.ksu_commit }}"
  326. KSUN_TAG="${{ needs.fetch-commits.outputs.ksu_tag }}"
  327. AK3_COMMIT="${{ needs.fetch-commits.outputs.anykernel_commit }}"
  328. PATCHES_COMMIT="${{ needs.fetch-commits.outputs.patches_commit }}"
  329. SUSFS_MAP="${{ needs.fetch-commits.outputs.susfs_commit }}"
  330. BBG_COMMIT="${{ needs.fetch-commits.outputs.bbg_commit }}"
  331. SUSFS_VERSION="v2.1.0"
  332. : > release_body.md
  333. {
  334. echo
  335. echo "**IMPORTANT DISCLAIMER**"
  336. echo "This software is provided for testing and educational purposes only. Use at your own risk."
  337. echo "The developers are not responsible for any damage, data loss, or issues that may occur."
  338. echo "Please ensure you have proper backups before installation."
  339. echo
  340. echo "## 🔧 Build Configuration"
  341. echo "| Component | Version/Setting |"
  342. echo "|---|---|"
  343. echo "| Feature Set | ${FEATURE_SET} |"
  344. echo "| KernelSU-Next Commit | ${KSUN_COMMIT} |"
  345. echo "| KernelSU-Next Tag | ${KSUN_TAG:-None} |"
  346. echo "| SUSFS Version | ${SUSFS_VERSION} |"
  347. echo "| AnyKernel3 Commit | ${AK3_COMMIT} |"
  348. echo "| Kernel Patches Commit | ${PATCHES_COMMIT} |"
  349. echo "| BBG Commit | ${BBG_COMMIT} |"
  350. echo "| Optimization Level | O2 |"
  351. echo "| Clean Build | ❌ No (ccache enabled) |"
  352. echo
  353. echo "## 📌 SUSFS Branch Mapping"
  354. echo "| Kernel Version | SUSFS Commit |"
  355. echo "|---|---|"
  356. } >> release_body.md
  357. echo "$SUSFS_MAP" | tr ',' '\n' | while IFS=':' read -r branch commit; do
  358. [ -n "${branch:-}" ] || continue
  359. [ -n "${commit:-}" ] || continue
  360. kernel_version="${branch#gki-}"
  361. echo "| ${kernel_version} | ${commit} |" >> release_body.md
  362. done
  363. {
  364. echo
  365. echo "## ✨ Features & Capabilities"
  366. } >> release_body.md
  367. if [[ "$FEATURE_SET" == *"KSUN"* ]]; then
  368. {
  369. echo "### 🔐 Root Management"
  370. echo "- KernelSU-Next (kernel-level root)"
  371. } >> release_body.md
  372. fi
  373. if [[ "$FEATURE_SET" == *"SUSFS"* ]]; then
  374. echo "- SUSFS ${SUSFS_VERSION}" >> release_body.md
  375. fi
  376. {
  377. echo
  378. echo "### 🚀 Performance & Networking"
  379. echo "- BBRv3 TCP Congestion Control"
  380. echo "- IP Set support"
  381. echo "- TTL target support (IPv4/IPv6)"
  382. echo
  383. echo "### 🔹 Bypass Builds"
  384. echo "- Includes module check bypass variant (Bypass)"
  385. echo
  386. echo "## 📦 Release Files"
  387. echo "- AnyKernel3: uploaded as ZIP in the Release"
  388. echo "- Boot images: uploaded as raw .img files in the Release"
  389. echo
  390. echo "## 📥 Recommended Tools"
  391. echo "- Kernel Flasher: https://github.com/fatalcoder524/KernelFlasher/"
  392. echo "- KernelSU-Next Manager: https://github.com/KernelSU-Next/KernelSU-Next"
  393. echo "- SUSFS Module: https://github.com/sidex15/ksu_module_susfs"
  394. } >> release_body.md
  395. if [[ "$FEATURE_SET" == *"BBG"* ]]; then
  396. {
  397. echo
  398. echo "### 🛡️ Security & Privacy"
  399. echo "- Baseband Guard (BBG): https://github.com/vc-teahouse/Baseband-guard"
  400. } >> release_body.md
  401. fi
  402. - name: Workflow Summary
  403. if: ${{ always() }}
  404. run: |
  405. set -e
  406. KSUN_COMMIT="${{ needs.fetch-commits.outputs.ksu_commit }}"
  407. KSUN_TAG="${{ needs.fetch-commits.outputs.ksu_tag }}"
  408. AK3_COMMIT="${{ needs.fetch-commits.outputs.anykernel_commit }}"
  409. PATCHES_COMMIT="${{ needs.fetch-commits.outputs.patches_commit }}"
  410. SUSFS_MAP="${{ needs.fetch-commits.outputs.susfs_commit }}"
  411. BBG_COMMIT="${{ needs.fetch-commits.outputs.bbg_commit }}"
  412. short() { echo "${1:0:8}"; }
  413. {
  414. echo "## 📦 Components"
  415. echo "| Component | Branch / Tag | Commit / Version |"
  416. echo "|---|---|---|"
  417. echo "| KernelSU-Next | ${KSUN_TAG:-dev} | $(short "$KSUN_COMMIT") |"
  418. echo "| AnyKernel3 | gki-2.0 | $(short "$AK3_COMMIT") |"
  419. echo "| Kernel Patches | main | $(short "$PATCHES_COMMIT") |"
  420. echo "| BBG | main | $(short "$BBG_COMMIT") |"
  421. } >> "$GITHUB_STEP_SUMMARY"
  422. {
  423. echo
  424. echo "## 📌 SUSFS Branch Mapping"
  425. echo "| Kernel Version | SUSFS Commit |"
  426. echo "|---|---|"
  427. } >> "$GITHUB_STEP_SUMMARY"
  428. echo "$SUSFS_MAP" | tr ',' '\n' | while IFS=':' read -r branch commit; do
  429. [ -n "${branch:-}" ] || continue
  430. [ -n "${commit:-}" ] || continue
  431. kernel_version="${branch#gki-}"
  432. echo "| ${kernel_version} | ${commit} |" >> "$GITHUB_STEP_SUMMARY"
  433. done
  434. - name: Download AnyKernel3 Artifacts
  435. uses: actions/download-artifact@v7
  436. with:
  437. path: release-assets
  438. pattern: '*-AnyKernel3'
  439. merge-multiple: false
  440. - name: Download Boot Image Artifacts
  441. uses: actions/download-artifact@v7
  442. with:
  443. path: release-assets
  444. pattern: '*-BootImages'
  445. merge-multiple: false
  446. - name: Zip AnyKernel3 for Release
  447. run: |
  448. set -e
  449. shopt -s nullglob
  450. for dir in release-assets/*-AnyKernel3; do
  451. zip_name="${dir}.zip"
  452. rm -f "$zip_name"
  453. cd "$dir"
  454. zip -r -q -9 "../$(basename "$zip_name")" .
  455. cd - >/dev/null
  456. done
  457. - name: Create Release
  458. uses: softprops/action-gh-release@v1
  459. with:
  460. tag_name: ${{ steps.tag.outputs.new_tag }}
  461. name: ${{ steps.tag.outputs.new_tag }}
  462. body_path: release_body.md
  463. draft: false
  464. prerelease: ${{ inputs.release_type == 'Pre-Release' }}
  465. files: |
  466. release-assets/**/*.zip
  467. release-assets/**/*-boot*.img