main.yml 18 KB

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