build.yml 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333
  1. name: Kernel Build Process
  2. permissions:
  3. contents: write
  4. actions: write
  5. on:
  6. workflow_call:
  7. inputs:
  8. branch:
  9. required: true
  10. type: string
  11. android_version:
  12. required: true
  13. type: string
  14. kernel_version:
  15. required: true
  16. type: string
  17. susfs:
  18. required: true
  19. type: string
  20. bbg:
  21. required: true
  22. type: string
  23. unicodefix:
  24. required: true
  25. type: string
  26. zeromount:
  27. required: true
  28. type: string
  29. ksun:
  30. required: true
  31. type: string
  32. droidspace:
  33. required: true
  34. type: string
  35. ntsync:
  36. required: true
  37. type: string
  38. bbr:
  39. required: true
  40. type: string
  41. jobs:
  42. build-samsung-gki:
  43. name: "${{ inputs.branch }}-${{ inputs.kernel_version }}-${{ inputs.android_version }}"
  44. runs-on: ubuntu-latest
  45. strategy:
  46. fail-fast: false
  47. steps:
  48. - name: Checkout Repository
  49. uses: actions/checkout@v5
  50. - name: Free Disk Space
  51. if: true
  52. uses: endersonmenezes/free-disk-space@v3 # Use @main for latest, @v3 for stable
  53. with:
  54. remove_android: true
  55. remove_dotnet: true
  56. remove_haskell: true
  57. remove_tool_cache: true
  58. remove_swap: true
  59. remove_packages: "azure-cli google-cloud-cli microsoft-edge-stable google-chrome-stable firefox postgresql* temurin-* *llvm* mysql* dotnet-sdk-*"
  60. remove_packages_one_command: true
  61. 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"
  62. rm_cmd: "rmz" # Use 'rmz' for faster deletion (default: 'rm')
  63. rmz_version: "3.1.1" # Required when rm_cmd is 'rmz'
  64. testing: false
  65. - name: Setup more Swap (for LTO)
  66. uses: thejerrybao/setup-swap-space@v1 # or pierotofy/set-swap-space
  67. with:
  68. swap-size-gb: 25 # 10-24 GB is common for heavy LTO
  69. # swap-space-path: /mnt/swapfile # optional
  70. - name: Set CONFIG Environment Variable
  71. run: |
  72. # Set CONFIG dynamically based on inputs values
  73. CONFIG="${{ inputs.branch }}-${{ inputs.android_version }}-${{ inputs.kernel_version }}"
  74. # Set CONFIG as an environment variable for future steps
  75. echo "CONFIG=$CONFIG" >> $GITHUB_ENV
  76. - name: dependencies
  77. uses: ./.github/actions/dependencies
  78. with:
  79. zeromount: ${{ inputs.zeromount }}
  80. susfs: ${{ inputs.susfs }}
  81. android_version: ${{ inputs.android_version }}
  82. kernel_version: ${{ inputs.kernel_version }}
  83. - name: Download Kernel
  84. uses: ./.github/actions/clone-kernel
  85. with:
  86. branch: ${{ inputs.branch }}
  87. - name: Set Path Environment Variables
  88. uses: ./.github/actions/env-variables
  89. with:
  90. branch: ${{ inputs.branch }}
  91. susfs: ${{ inputs.susfs }}
  92. zeromount: ${{ inputs.zeromount }}
  93. - name: Extract all tar.xz files and delete them
  94. run: |
  95. cd "$CONFIG"
  96. find . -type f -name '*.tar.xz' -print0 | while IFS= read -r -d '' file; do
  97. echo "Extracting $file"
  98. tar -xf "$file"
  99. rm "$file"
  100. done
  101. - name: Add KernelSU-Next
  102. if: inputs.ksun == 'true'
  103. uses: ./.github/actions/ksun
  104. - name: Apply SUSFS Patches
  105. if: inputs.susfs == 'true'
  106. uses: ./.github/actions/susfs-patches
  107. with:
  108. android_version: ${{ inputs.android_version }}
  109. kernel_version: ${{ inputs.kernel_version }}
  110. branch: ${{ inputs.branch }}
  111. - name: Apply zeromount Patches
  112. if: inputs.susfs == 'true' && inputs.zeromount == 'true'
  113. uses: ./.github/actions/zeromount
  114. with:
  115. android_version: ${{ inputs.android_version }}
  116. kernel_version: ${{ inputs.kernel_version }}
  117. - name: Fix WiFi and Bluetooth on Samsung 6.6 GKI devices
  118. if: inputs.kernel_version == '6.6'
  119. uses: ./.github/actions/6.6-fix
  120. with:
  121. branch: ${{ inputs.branch }}
  122. - name: Add bbrv1
  123. if: inputs.bbr == 'true'
  124. uses: ./.github/actions/bbr
  125. - name: Add BBG
  126. if: inputs.bbg == 'true'
  127. uses: ./.github/actions/bbg
  128. - name: temp fix for m55 bootloop maybe
  129. if: inputs.branch == 'SM-M556B-Oneui8'
  130. uses: ./.github/actions/m55-fix
  131. - name: Add unicodefix
  132. if: inputs.unicodefix == 'true'
  133. uses: ./.github/actions/unicode
  134. with:
  135. kernel_version: ${{ inputs.kernel_version }}
  136. - name: Add droidspace support
  137. if: inputs.droidspace == 'true'
  138. uses: ./.github/actions/droidspaces
  139. with:
  140. kernel_version: ${{ inputs.kernel_version }}
  141. - name: Add ntsync
  142. if: inputs.ntsync == 'true'
  143. uses: ./.github/actions/ntsync
  144. with:
  145. android_version: ${{ inputs.android_version }}
  146. kernel_version: ${{ inputs.kernel_version }}
  147. - name: Set Kernel Configuration Variables
  148. if: inputs.ksun == 'true'
  149. uses: ./.github/actions/configs
  150. with:
  151. branch: ${{ inputs.branch }}
  152. - name: Change Kernel Name and clean dirty
  153. uses: ./.github/actions/kernel-name
  154. - name: remove protected exports
  155. uses: ./.github/actions/abi-export
  156. - name: Set file name
  157. if: inputs.ksun == 'true'
  158. uses: ./.github/actions/file-name
  159. with:
  160. branch: ${{ inputs.branch }}
  161. android_version: ${{ inputs.android_version }}
  162. kernel_version: ${{ inputs.kernel_version }}
  163. - name: Build
  164. uses: ./.github/actions/build
  165. with:
  166. branch: ${{ inputs.branch }}
  167. - name: Prepare AnyKernel3
  168. uses: ./.github/actions/ak3zip-prep
  169. with:
  170. branch: ${{ inputs.branch }}
  171. - name: Upload AnyKernel3 Artifacts
  172. id: upload_ak3
  173. uses: actions/upload-artifact@v6
  174. with:
  175. name: ${{ env.FILE_NAME }}-AnyKernel3
  176. path: |
  177. ./AnyKernel3/**
  178. compression-level: 9
  179. - name: Scan and collect patch rejects
  180. if: ${{ always() }}
  181. run: |
  182. set -e
  183. CONFIG_DIR="$CONFIG"
  184. REJECTS_DIR="$GITHUB_WORKSPACE/patch-rejects"
  185. mkdir -p "$REJECTS_DIR"
  186. # Find all .rej files under the configuration directory
  187. mapfile -t REJS < <(find "$CONFIG_DIR" -type f -name '*.rej')
  188. REJ_COUNT=${#REJS[@]}
  189. echo "Found $REJ_COUNT .rej files under $CONFIG_DIR"
  190. echo "REJ_COUNT=$REJ_COUNT" >> $GITHUB_ENV
  191. if [ "$REJ_COUNT" -gt 0 ]; then
  192. for REJ in "${REJS[@]}"; do
  193. # Relative path from $CONFIG
  194. REL="${REJ#"$CONFIG_DIR"/}"
  195. DEST="$REJECTS_DIR/$REL"
  196. mkdir -p "$(dirname "$DEST")"
  197. cp "$REJ" "$DEST"
  198. # Copy the associated original file alongside the .rej
  199. ORIG="${REJ%.rej}"
  200. if [ -f "$ORIG" ]; then
  201. ORIG_DEST="$REJECTS_DIR/${REL%.rej}"
  202. mkdir -p "$(dirname "$ORIG_DEST")"
  203. cp "$ORIG" "$ORIG_DEST"
  204. fi
  205. echo "$REL" >> "$REJECTS_DIR/index.txt"
  206. done
  207. fi
  208. - name: Generate Build Summary
  209. if: ${{ always() }}
  210. run: |
  211. # Create build summary file for inclusion in Misc artifact
  212. echo "# Kernel Build Summary" > build_summary.md
  213. # Add build variant header
  214. echo "## ${{ env.FILE_NAME }}" >> build_summary.md
  215. # Add build info
  216. echo "## Build Information" >> build_summary.md
  217. echo "- **Android Version**: ${{ inputs.android_version }}" >> build_summary.md
  218. echo "- **Kernel Version**: ${{ inputs.kernel_version }}.${{ inputs.sub_level }}" >> build_summary.md
  219. echo "- **BBG**: Installed" >> build_summary.md
  220. echo "" >> build_summary.md
  221. # Get KernelSU-Next commit
  222. if [ -d "$CONFIG/KernelSU-Next" ]; then
  223. cd "$CONFIG/KernelSU-Next"
  224. KSUN_COMMIT=$(git rev-parse HEAD)
  225. KSUN_URL="https://github.com/WildKernels/KernelSU-Next/commit/$KSUN_COMMIT"
  226. echo "- **KernelSU-Next**: [$KSUN_COMMIT]($KSUN_URL)" >> "$GITHUB_WORKSPACE/build_summary.md"
  227. cd "$GITHUB_WORKSPACE"
  228. else
  229. echo "- **KernelSU-Next**: not present" >> build_summary.md
  230. fi
  231. # Get Baseband-guard commit
  232. if [ -d "$CONFIG/Baseband-guard" ]; then
  233. cd "$CONFIG/Baseband-guard"
  234. BBG_COMMIT=$(git rev-parse HEAD)
  235. BBG_URL="https://github.com/vc-teahouse/Baseband-guard/commit/$BBG_COMMIT"
  236. echo "- **Baseband-guard**: [$BBG_COMMIT]($BBG_URL)" >> "$GITHUB_WORKSPACE/build_summary.md"
  237. cd "$GITHUB_WORKSPACE"
  238. else
  239. echo "- **Baseband-guard**: not present" >> build_summary.md
  240. fi
  241. # Get SUSFS4KSU commit
  242. if [ -d "$GITHUB_WORKSPACE/susfs4ksu" ]; then
  243. cd "$GITHUB_WORKSPACE/susfs4ksu"
  244. SUSFS_COMMIT=$(git rev-parse HEAD)
  245. SUSFS_URL="https://gitlab.com/simonpunk/susfs4ksu/-/commit/$SUSFS_COMMIT"
  246. echo "- **SUSFS4KSU (v2.1.0)**: [$SUSFS_COMMIT]($SUSFS_URL)" >> "$GITHUB_WORKSPACE/build_summary.md"
  247. cd "$GITHUB_WORKSPACE"
  248. else
  249. echo "- **SUSFS4KSU (v2.1.0)**: not present" >> build_summary.md
  250. fi
  251. echo "" >> build_summary.md
  252. # Add artifact summary with presence verification
  253. echo "## Build Artifacts" >> build_summary.md
  254. # Verify AnyKernel3 contents - check if kernel Image was actually copied (indicates successful build)
  255. if [ -d "AnyKernel3" ] && [ -f "AnyKernel3/Image" ]; then
  256. AK3_STATUS="✅"
  257. else
  258. AK3_STATUS="❌"
  259. fi
  260. echo "- **AnyKernel3**: $AK3_STATUS ${{ env.FILE_NAME }}-AnyKernel3" >> build_summary.md
  261. echo "### Misc (uploaded files)" >> build_summary.md
  262. FILES_PRESENT=0
  263. for f in "${{ env.FILE_NAME }}-Image" "${{ env.FILE_NAME }}-Image.gz" "${{ env.FILE_NAME }}-Image.lz4" "${{ env.FILE_NAME }}-boot.img" "${{ env.FILE_NAME }}-boot-gz.img" "${{ env.FILE_NAME }}-boot-lz4.img"; do
  264. if [ -f "$f" ]; then FILES_PRESENT=$((FILES_PRESENT+1)); fi
  265. done
  266. if [ "$FILES_PRESENT" -gt 0 ]; then
  267. MISC_STATUS="✅"
  268. else
  269. MISC_STATUS="❌"
  270. fi
  271. echo "- **Set**: $MISC_STATUS ${{ env.FILE_NAME }}-Misc" >> build_summary.md
  272. if [ "$MISC_STATUS" = "✅" ]; then
  273. echo " Included:" >> build_summary.md
  274. for f in "${{ env.FILE_NAME }}-Image" "${{ env.FILE_NAME }}-Image.gz" "${{ env.FILE_NAME }}-Image.lz4" "${{ env.FILE_NAME }}-boot.img" "${{ env.FILE_NAME }}-boot-gz.img" "${{ env.FILE_NAME }}-boot-lz4.img"; do
  275. if [ -f "$f" ]; then
  276. echo " - $f" >> build_summary.md
  277. fi
  278. done
  279. fi
  280. echo "### Diagnostics" >> build_summary.md
  281. echo "- **Rejected Patches**: ${{ env.FILE_NAME }}-Rejected-Patches" >> build_summary.md
  282. if [ -f patch-rejects/index.txt ]; then
  283. if [ -s patch-rejects/index.txt ]; then
  284. echo " Rejected files:" >> build_summary.md
  285. while IFS= read -r line; do
  286. echo " - $line" >> build_summary.md
  287. done < patch-rejects/index.txt
  288. else
  289. echo " Rejected file list is empty." >> build_summary.md
  290. fi
  291. else
  292. echo " No rejected patches found." >> build_summary.md
  293. fi