main.yml 18 KB

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