main.yml 18 KB

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