build.yml 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321
  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. - name: Apply zeromount Patches
  108. if: inputs.susfs == 'true' && inputs.zeromount == 'true'
  109. uses: ./.github/actions/zeromount
  110. with:
  111. android_version: ${{ inputs.android_version }}
  112. kernel_version: ${{ inputs.kernel_version }}
  113. - name: Fix WiFi and Bluetooth on Samsung 6.6 GKI devices
  114. if: inputs.kernel_version == '6.6'
  115. uses: ./.github/actions/6.6-fix
  116. with:
  117. branch: ${{ inputs.branch }}
  118. - name: Add BBG
  119. if: inputs.bbg == 'true'
  120. uses: ./.github/actions/bbg
  121. - name: temp fix for m55 bootloop maybe
  122. if: inputs.branch == 'SM-M556B-Oneui8'
  123. uses: ./.github/actions/m55-fix
  124. - name: Add unicodefix
  125. if: inputs.unicodefix == 'true'
  126. uses: ./.github/actions/unicode
  127. with:
  128. kernel_version: ${{ inputs.kernel_version }}
  129. - name: Add droidspace support
  130. if: inputs.droidspace == 'true'
  131. uses: ./.github/actions/droidspaces
  132. - name: Set Kernel Configuration Variables
  133. if: inputs.wksu == 'true'
  134. uses: ./.github/actions/configs
  135. - name: Add ntsync
  136. if: inputs.ntsync == 'true'
  137. uses: ./.github/actions/ntsync
  138. with:
  139. android_version: ${{ inputs.android_version }}
  140. kernel_version: ${{ inputs.kernel_version }}
  141. - name: Change Kernel Name and clean dirty
  142. uses: ./.github/actions/kernel-name
  143. - name: remove protected exports
  144. uses: ./.github/actions/abi-export
  145. - name: Set file name
  146. if: inputs.wksu == 'true'
  147. uses: ./.github/actions/file-name
  148. with:
  149. branch: ${{ inputs.branch }}
  150. android_version: ${{ inputs.android_version }}
  151. kernel_version: ${{ inputs.kernel_version }}
  152. - name: Build
  153. uses: ./.github/actions/build
  154. with:
  155. branch: ${{ inputs.branch }}
  156. - name: Prepare AnyKernel3
  157. uses: ./.github/actions/ak3zip-prep
  158. with:
  159. branch: ${{ inputs.branch }}
  160. - name: Upload AnyKernel3 Artifacts
  161. id: upload_ak3
  162. uses: actions/upload-artifact@v6
  163. with:
  164. name: ${{ env.FILE_NAME }}-AnyKernel3
  165. path: |
  166. ./AnyKernel3/**
  167. compression-level: 9
  168. - name: Scan and collect patch rejects
  169. if: ${{ always() }}
  170. run: |
  171. set -e
  172. CONFIG_DIR="$CONFIG"
  173. REJECTS_DIR="$GITHUB_WORKSPACE/patch-rejects"
  174. mkdir -p "$REJECTS_DIR"
  175. # Find all .rej files under the configuration directory
  176. mapfile -t REJS < <(find "$CONFIG_DIR" -type f -name '*.rej')
  177. REJ_COUNT=${#REJS[@]}
  178. echo "Found $REJ_COUNT .rej files under $CONFIG_DIR"
  179. echo "REJ_COUNT=$REJ_COUNT" >> $GITHUB_ENV
  180. if [ "$REJ_COUNT" -gt 0 ]; then
  181. for REJ in "${REJS[@]}"; do
  182. # Relative path from $CONFIG
  183. REL="${REJ#"$CONFIG_DIR"/}"
  184. DEST="$REJECTS_DIR/$REL"
  185. mkdir -p "$(dirname "$DEST")"
  186. cp "$REJ" "$DEST"
  187. # Copy the associated original file alongside the .rej
  188. ORIG="${REJ%.rej}"
  189. if [ -f "$ORIG" ]; then
  190. ORIG_DEST="$REJECTS_DIR/${REL%.rej}"
  191. mkdir -p "$(dirname "$ORIG_DEST")"
  192. cp "$ORIG" "$ORIG_DEST"
  193. fi
  194. echo "$REL" >> "$REJECTS_DIR/index.txt"
  195. done
  196. fi
  197. - name: Generate Build Summary
  198. if: ${{ always() }}
  199. run: |
  200. # Create build summary file for inclusion in Misc artifact
  201. echo "# Kernel Build Summary" > build_summary.md
  202. # Add build variant header
  203. echo "## ${{ env.FILE_NAME }}" >> build_summary.md
  204. # Add build info
  205. echo "## Build Information" >> build_summary.md
  206. echo "- **Android Version**: ${{ inputs.android_version }}" >> build_summary.md
  207. echo "- **Kernel Version**: ${{ inputs.kernel_version }}.${{ inputs.sub_level }}" >> build_summary.md
  208. echo "- **BBG**: Installed" >> build_summary.md
  209. echo "" >> build_summary.md
  210. # Get KernelSU-Next commit
  211. if [ -d "$CONFIG/KernelSU-Next" ]; then
  212. cd "$CONFIG/KernelSU-Next"
  213. KSUN_COMMIT=$(git rev-parse HEAD)
  214. KSUN_URL="https://github.com/WildKernels/KernelSU-Next/commit/$KSUN_COMMIT"
  215. echo "- **KernelSU-Next**: [$KSUN_COMMIT]($KSUN_URL)" >> "$GITHUB_WORKSPACE/build_summary.md"
  216. cd "$GITHUB_WORKSPACE"
  217. else
  218. echo "- **KernelSU-Next**: not present" >> build_summary.md
  219. fi
  220. # Get Baseband-guard commit
  221. if [ -d "$CONFIG/Baseband-guard" ]; then
  222. cd "$CONFIG/Baseband-guard"
  223. BBG_COMMIT=$(git rev-parse HEAD)
  224. BBG_URL="https://github.com/vc-teahouse/Baseband-guard/commit/$BBG_COMMIT"
  225. echo "- **Baseband-guard**: [$BBG_COMMIT]($BBG_URL)" >> "$GITHUB_WORKSPACE/build_summary.md"
  226. cd "$GITHUB_WORKSPACE"
  227. else
  228. echo "- **Baseband-guard**: not present" >> build_summary.md
  229. fi
  230. # Get SUSFS4KSU commit
  231. if [ -d "$GITHUB_WORKSPACE/susfs4ksu" ]; then
  232. cd "$GITHUB_WORKSPACE/susfs4ksu"
  233. SUSFS_COMMIT=$(git rev-parse HEAD)
  234. SUSFS_URL="https://gitlab.com/simonpunk/susfs4ksu/-/commit/$SUSFS_COMMIT"
  235. echo "- **SUSFS4KSU (v2.1.0)**: [$SUSFS_COMMIT]($SUSFS_URL)" >> "$GITHUB_WORKSPACE/build_summary.md"
  236. cd "$GITHUB_WORKSPACE"
  237. else
  238. echo "- **SUSFS4KSU (v2.1.0)**: not present" >> build_summary.md
  239. fi
  240. echo "" >> build_summary.md
  241. # Add artifact summary with presence verification
  242. echo "## Build Artifacts" >> build_summary.md
  243. # Verify AnyKernel3 contents - check if kernel Image was actually copied (indicates successful build)
  244. if [ -d "AnyKernel3" ] && [ -f "AnyKernel3/Image" ]; then
  245. AK3_STATUS="✅"
  246. else
  247. AK3_STATUS="❌"
  248. fi
  249. echo "- **AnyKernel3**: $AK3_STATUS ${{ env.FILE_NAME }}-AnyKernel3" >> build_summary.md
  250. echo "### Misc (uploaded files)" >> build_summary.md
  251. FILES_PRESENT=0
  252. 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
  253. if [ -f "$f" ]; then FILES_PRESENT=$((FILES_PRESENT+1)); fi
  254. done
  255. if [ "$FILES_PRESENT" -gt 0 ]; then
  256. MISC_STATUS="✅"
  257. else
  258. MISC_STATUS="❌"
  259. fi
  260. echo "- **Set**: $MISC_STATUS ${{ env.FILE_NAME }}-Misc" >> build_summary.md
  261. if [ "$MISC_STATUS" = "✅" ]; then
  262. echo " Included:" >> build_summary.md
  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
  265. echo " - $f" >> build_summary.md
  266. fi
  267. done
  268. fi
  269. echo "### Diagnostics" >> build_summary.md
  270. echo "- **Rejected Patches**: ${{ env.FILE_NAME }}-Rejected-Patches" >> build_summary.md
  271. if [ -f patch-rejects/index.txt ]; then
  272. if [ -s patch-rejects/index.txt ]; then
  273. echo " Rejected files:" >> build_summary.md
  274. while IFS= read -r line; do
  275. echo " - $line" >> build_summary.md
  276. done < patch-rejects/index.txt
  277. else
  278. echo " Rejected file list is empty." >> build_summary.md
  279. fi
  280. else
  281. echo " No rejected patches found." >> build_summary.md
  282. fi