main.yml 17 KB

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