main.yml 18 KB

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