main.yml 15 KB

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