build.yml 12 KB

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