main.yml 18 KB

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