main.yml 18 KB

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