build.yml 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488
  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. build_type:
  12. required: false
  13. type: string
  14. root_flavor:
  15. description: "next / kernelsu / resukisu"
  16. required: false
  17. type: string
  18. default: "next"
  19. root_commit:
  20. required: false
  21. type: string
  22. default: ""
  23. variant:
  24. required: false
  25. type: string
  26. default: ""
  27. susfs_commit:
  28. required: false
  29. type: string
  30. default: ""
  31. susfs_commit_android12_5_10:
  32. required: false
  33. type: string
  34. default: ""
  35. susfs_commit_android13_5_10:
  36. required: false
  37. type: string
  38. default: ""
  39. susfs_commit_android13_5_15:
  40. required: false
  41. type: string
  42. default: ""
  43. susfs_commit_android14_5_15:
  44. required: false
  45. type: string
  46. default: ""
  47. susfs_commit_android14_6_1:
  48. required: false
  49. type: string
  50. default: ""
  51. susfs_commit_android15_6_6:
  52. required: false
  53. type: string
  54. default: ""
  55. susfs_commit_android16_6_12:
  56. required: false
  57. type: string
  58. default: ""
  59. nomount_commit:
  60. required: false
  61. type: string
  62. default: ""
  63. susfs:
  64. required: true
  65. type: string
  66. bbg:
  67. required: true
  68. type: string
  69. unicodefix:
  70. required: true
  71. type: string
  72. zeromount:
  73. required: true
  74. type: string
  75. nomount:
  76. required: true
  77. type: string
  78. droidspace:
  79. required: true
  80. type: string
  81. ntsync:
  82. required: true
  83. type: string
  84. bbrv3:
  85. required: true
  86. type: string
  87. cache:
  88. required: true
  89. type: string
  90. ipv6_nat:
  91. required: true
  92. type: string
  93. optimization:
  94. required: true
  95. type: string
  96. ttl:
  97. required: true
  98. type: string
  99. lto:
  100. required: true
  101. type: string
  102. jobs:
  103. build-samsung-gki:
  104. name: "${{ inputs.branch }} (${{ inputs.variant || inputs.root_flavor }})"
  105. runs-on: ubuntu-latest
  106. strategy:
  107. fail-fast: false
  108. steps:
  109. - name: Checkout Repository
  110. uses: actions/checkout@v5
  111. - name: Store branch as env variable
  112. run: BRANCH=${{ inputs.branch }} && echo "BRANCH=$BRANCH" >> $GITHUB_ENV
  113. - name: get kernel version before cloning
  114. uses: ./.github/actions/kernel-info
  115. - name: Store LTO as env variable
  116. run: |
  117. if [[ $KERNEL_VER != 6.6 ]]; then
  118. BUILD_LTO=${{ inputs.lto }} && echo "BUILD_LTO=$BUILD_LTO" >> $GITHUB_ENV
  119. else
  120. BUILD_LTO="default" && echo "BUILD_LTO=$BUILD_LTO" >> $GITHUB_ENV
  121. fi
  122. - name: Free Disk Space
  123. if: true
  124. uses: endersonmenezes/free-disk-space@v3
  125. with:
  126. remove_android: true
  127. remove_dotnet: true
  128. remove_haskell: true
  129. remove_tool_cache: true
  130. remove_swap: true
  131. remove_packages: "azure-cli google-cloud-cli microsoft-edge-stable google-chrome-stable firefox postgresql* temurin-* *llvm* mysql* dotnet-sdk-*"
  132. remove_packages_one_command: true
  133. 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"
  134. rm_cmd: "rmz"
  135. rmz_version: "3.1.1"
  136. testing: false
  137. - name: Setup more Swap (for LTO)
  138. uses: pierotofy/set-swap-space@master
  139. with:
  140. swap-size-gb: 25
  141. - name: Parse branch for cache keys
  142. if: inputs.cache == 'true' && inputs.build_type == 'make'
  143. uses: ./.github/actions/parse-branch
  144. - name: Install ccache
  145. if: inputs.cache == 'true' && inputs.build_type == 'make'
  146. run: sudo apt-get update && sudo apt-get install -y ccache
  147. - name: Export ccache + determinism
  148. if: inputs.cache == 'true' && inputs.build_type == 'make'
  149. run: |
  150. CACHE_DIR="${{ github.workspace }}/.ccache"
  151. mkdir -p "$CACHE_DIR"
  152. CCACHE_LOG="${{ github.workspace }}/ccache.log"
  153. SETTINGS=(
  154. "CCACHE_DIR=$CACHE_DIR"
  155. "CCACHE_MAXSIZE=12G"
  156. "CCACHE_COMPILERCHECK=content"
  157. "CCACHE_BASEDIR=${GITHUB_WORKSPACE}"
  158. "CCACHE_NOHASHDIR=true"
  159. "CCACHE_IGNOREOPTIONS=-sysroot* -fdebug-prefix-map=* -fmacro-prefix-map=*"
  160. "CCACHE_COMPRESS=true"
  161. "CCACHE_COMPRESSLEVEL=8"
  162. "CCACHE_DIRECT=true"
  163. "CCACHE_FILE_CLONE=true"
  164. "CCACHE_INODE_CACHE=true"
  165. "CCACHE_IS_KERNEL_COMPILING=true"
  166. "CCACHE_UMASK=002"
  167. "KBUILD_BUILD_TIMESTAMP=2026-01-01"
  168. "CCACHE_SLOPPINESS=file_macro,time_macros,include_file_mtime,include_file_ctime,pch_defines,system_headers,locale,file_stat_matches"
  169. )
  170. for setting in "${SETTINGS[@]}"; do
  171. export "$setting"
  172. echo "$setting" >> $GITHUB_ENV
  173. done
  174. if ccache --help 2>&1 | grep -q 'depend_mode'; then
  175. export CCACHE_DEPEND=true
  176. echo "CCACHE_DEPEND=true" >> "$GITHUB_ENV"
  177. fi
  178. - name: restore ccache
  179. if: inputs.cache == 'true' && inputs.build_type == 'make'
  180. uses: actions/cache@v6
  181. with:
  182. path: ${{ env.CCACHE_DIR }}
  183. key: ccache-${{ runner.os }}-${{ inputs.build_type }}-${{ env.BASE_BRANCH }}-${{ inputs.root_flavor }}-${{ inputs.variant }}
  184. restore-keys: |
  185. ccache-${{ runner.os }}-${{ inputs.build_type }}-${{ env.BASE_BRANCH }}-${{ inputs.root_flavor }}-
  186. ccache-${{ runner.os }}-${{ inputs.build_type }}-${{ env.BASE_BRANCH }}-
  187. ccache-${{ runner.os }}-${{ inputs.build_type }}-
  188. - name: Ensure ccache is used
  189. if: inputs.cache == 'true' && inputs.build_type == 'make'
  190. run: |
  191. echo "/usr/lib/ccache" >> $GITHUB_PATH
  192. echo "CC='ccache clang'" >> $GITHUB_ENV
  193. echo "CXX='ccache clang++'" >> $GITHUB_ENV
  194. - name: Set CONFIG Environment Variable
  195. run: |
  196. CONFIG="$BRANCH-${ANDROID_VER}_${KERNEL_VER}"
  197. echo "CONFIG=$CONFIG" >> $GITHUB_ENV
  198. - name: dependencies
  199. uses: ./.github/actions/dependencies
  200. - name: Download Kernel
  201. uses: ./.github/actions/clone-kernel
  202. - name: Set Path Environment Variables
  203. uses: ./.github/actions/env-variables
  204. - name: Extract all tar.xz files and delete them
  205. run: |
  206. cd "$CONFIG"
  207. find . -type f -name '*.tar.xz' -print0 | while IFS= read -r -d '' file; do
  208. echo "Extracting $file"
  209. tar -xf "$file"
  210. rm "$file"
  211. done
  212. - name: Setup Selected Root Implementation
  213. if: inputs.root_flavor != ''
  214. uses: ./.github/actions/root-setup
  215. with:
  216. flavor: ${{ inputs.root_flavor }}
  217. commit: ${{ inputs.root_commit }}
  218. - name: Disable SUSFS for ReSukiSU without SUSFS feature
  219. if: inputs.root_flavor == 'resukisu' && inputs.susfs != 'true'
  220. run: |
  221. "$COMMON/scripts/config" --file "$GKI_DEFCONFIG" --disable CONFIG_KSU_SUSFS || true
  222. echo "Disabled SUSFS for resukisu without SUSFS"
  223. - name: Resolve SUSFS commit
  224. id: susfs-cm
  225. if: inputs.susfs == 'true'
  226. shell: bash
  227. run: |
  228. set -euo pipefail
  229. # KernelSU-Next (next) always uses latest tip so SUSFS stays API-matched.
  230. # Other flavors use pinned verified commit per kernel version.
  231. # We receive all per-version pins from kernel-samsung.yml inputs.
  232. KVER="$KERNEL_VER"
  233. AVER="$ANDROID_VER"
  234. echo "KERNEL_VER=$KVER ANDROID_VER=$AVER root_flavor=${{ inputs.root_flavor }}"
  235. pick_pin() {
  236. case "$KVER" in
  237. 5.10) if [ "$AVER" = "android12" ]; then echo "${{ inputs.susfs_commit_android12_5_10 }}"; else echo "${{ inputs.susfs_commit_android13_5_10 }}"; fi ;;
  238. 5.15) if [ "$AVER" = "android14" ]; then echo "${{ inputs.susfs_commit_android14_5_15 }}"; else echo "${{ inputs.susfs_commit_android13_5_15 }}"; fi ;;
  239. 6.1) echo "${{ inputs.susfs_commit_android14_6_1 }}" ;;
  240. 6.6) echo "${{ inputs.susfs_commit_android15_6_6 }}" ;;
  241. 6.12) echo "${{ inputs.susfs_commit_android16_6_12 }}" ;;
  242. *) echo "${{ inputs.susfs_commit }}" ;;
  243. esac
  244. }
  245. if [ "${{ inputs.root_flavor }}" = "next" ]; then
  246. BRANCH="gki-${AVER}-${KVER}"
  247. # try android version fallback if branch missing
  248. SUSFS_COMMIT="$(git ls-remote https://gitlab.com/simonpunk/susfs4ksu.git "refs/heads/${BRANCH}" | cut -f1)"
  249. if [ -z "$SUSFS_COMMIT" ]; then
  250. # fallback to generic gki branch
  251. for b in "gki-android12-5.10" "gki-android13-5.15" "gki-android14-6.1" "gki-android15-6.6"; do
  252. SUSFS_COMMIT="$(git ls-remote https://gitlab.com/simonpunk/susfs4ksu.git "refs/heads/${b}" | cut -f1 || true)"
  253. [ -n "$SUSFS_COMMIT" ] && break
  254. done
  255. fi
  256. # last resort: use pinned
  257. if [ -z "$SUSFS_COMMIT" ]; then SUSFS_COMMIT="$(pick_pin)"; fi
  258. echo "KernelSU-Next: resolving SUSFS at latest on ${BRANCH} -> ${SUSFS_COMMIT}"
  259. else
  260. SUSFS_COMMIT="$(pick_pin)"
  261. if [ -z "$SUSFS_COMMIT" ]; then SUSFS_COMMIT="${{ inputs.susfs_commit }}"; fi
  262. echo "Using pinned SUSFS commit: ${SUSFS_COMMIT}"
  263. fi
  264. echo "commit=${SUSFS_COMMIT}" >> "$GITHUB_OUTPUT"
  265. echo "SUSFS_COMMIT=${SUSFS_COMMIT}" >> "$GITHUB_ENV"
  266. - name: Add SUSFS
  267. if: inputs.susfs == 'true'
  268. uses: ./.github/actions/susfs-patches
  269. with:
  270. nomount: ${{ inputs.nomount }}
  271. susfs_commit: ${{ steps.susfs-cm.outputs.commit }}
  272. - name: Add Zeromount
  273. if: inputs.susfs == 'true' && inputs.zeromount == 'true'
  274. uses: ./.github/actions/zeromount
  275. - name: add nomount
  276. if: inputs.nomount == 'true'
  277. uses: ./.github/actions/nomount
  278. with:
  279. commit: ${{ inputs.nomount_commit }}
  280. - name: Add BBG
  281. if: inputs.bbg == 'true'
  282. uses: ./.github/actions/bbg
  283. - name: Add unicodefix
  284. if: inputs.unicodefix == 'true'
  285. uses: ./.github/actions/unicode
  286. - name: Add droidspace support
  287. if: inputs.droidspace == 'true'
  288. uses: ./.github/actions/droidspaces
  289. - name: Add ntsync
  290. if: inputs.ntsync == 'true'
  291. uses: ./.github/actions/ntsync
  292. - name: Add bbrv3
  293. if: inputs.bbrv3 == 'true'
  294. uses: ./.github/actions/bbrv3
  295. - name: Add IP-SET and IPv6_NAT support
  296. if: inputs.ipv6_nat == 'true'
  297. uses: ./.github/actions/IPv6_NAT
  298. - name: Add TTL support
  299. if: inputs.ttl == 'true'
  300. uses: ./.github/actions/TTL
  301. - name: add optimization patches
  302. if: inputs.optimization == 'true' && !startsWith(env.BRANCH, 'SM-S711')
  303. uses: ./.github/actions/optimization
  304. - name: Fix WiFi and Bluetooth on Samsung 6.6 GKI devices
  305. if: ${{ env.KERNEL_VER == '6.6' }}
  306. uses: ./.github/actions/6.6-fix
  307. - name: temp fix for m55 bootloop maybe
  308. if: inputs.branch == 'SM-M556B-Oneui8'
  309. uses: ./.github/actions/m55-fix
  310. - name: Set Kernel Configuration Variables
  311. uses: ./.github/actions/configs
  312. - name: Change Kernel Name and clean dirty
  313. uses: ./.github/actions/kernel-name
  314. - name: remove protected exports
  315. uses: ./.github/actions/abi-export
  316. - name: Set file name
  317. uses: ./.github/actions/file-name
  318. with:
  319. root_flavor: ${{ inputs.root_flavor }}
  320. variant: ${{ inputs.variant }}
  321. ksun: "true"
  322. susfs: ${{ inputs.susfs }}
  323. zeromount: ${{ inputs.zeromount }}
  324. nomount: ${{ inputs.nomount }}
  325. bbg: ${{ inputs.bbg }}
  326. bbrv3: ${{ inputs.bbrv3 }}
  327. droidspaces: ${{ inputs.droidspace }}
  328. ntsync: ${{ inputs.ntsync }}
  329. ipv6_nat: ${{ inputs.ipv6_nat }}
  330. ttl: ${{ inputs.ttl }}
  331. unicodefix: ${{ inputs.unicodefix }}
  332. - name: change variables to ccache
  333. if: inputs.cache == 'true' && inputs.build_type == 'make'
  334. uses: ./.github/actions/use-ccache
  335. - name: configure LTO
  336. uses: ./.github/actions/lto
  337. - name: Build
  338. uses: ./.github/actions/build
  339. with:
  340. build_type: ${{ inputs.build_type }}
  341. - name: clean up ccache
  342. if: inputs.cache == 'true' && inputs.build_type == 'make'
  343. run: ccache -c
  344. - name: ccache stats
  345. if: inputs.cache == 'true' && inputs.build_type == 'make'
  346. run: ccache -s -v || ccache -s
  347. - name: Prepare AnyKernel3
  348. uses: ./.github/actions/ak3zip-prep
  349. - name: Upload AnyKernel3 Artifacts
  350. id: upload_ak3
  351. uses: actions/upload-artifact@v6
  352. with:
  353. name: ${{ env.FILE_NAME }}-AnyKernel3
  354. path: |
  355. ./AnyKernel3/**
  356. compression-level: 9
  357. - name: Scan and collect patch rejects
  358. if: ${{ always() }}
  359. run: |
  360. set -e
  361. CONFIG_DIR="$CONFIG"
  362. REJECTS_DIR="$GITHUB_WORKSPACE/patch-rejects"
  363. mkdir -p "$REJECTS_DIR"
  364. mapfile -t REJS < <(find "$CONFIG_DIR" -type f -name '*.rej')
  365. REJ_COUNT=${#REJS[@]}
  366. echo "Found $REJ_COUNT .rej files under $CONFIG_DIR"
  367. echo "REJ_COUNT=$REJ_COUNT" >> $GITHUB_ENV
  368. if [ "$REJ_COUNT" -gt 0 ]; then
  369. for REJ in "${REJS[@]}"; do
  370. REL="${REJ#"$CONFIG_DIR"/}"
  371. DEST="$REJECTS_DIR/$REL"
  372. mkdir -p "$(dirname "$DEST")"
  373. cp "$REJ" "$DEST"
  374. ORIG="${REJ%.rej}"
  375. if [ -f "$ORIG" ]; then
  376. ORIG_DEST="$REJECTS_DIR/${REL%.rej}"
  377. mkdir -p "$(dirname "$ORIG_DEST")"
  378. cp "$ORIG" "$ORIG_DEST"
  379. fi
  380. echo "$REL" >> "$REJECTS_DIR/index.txt"
  381. done
  382. fi
  383. - name: Generate Build Summary
  384. if: ${{ always() }}
  385. run: |
  386. echo "# Kernel Build Summary" > build_summary.md
  387. echo "## ${{ env.FILE_NAME }}" >> build_summary.md
  388. echo "## Build Information" >> build_summary.md
  389. echo "- **Branch**: ${{ inputs.branch }}" >> build_summary.md
  390. echo "- **Root**: ${{ inputs.variant || inputs.root_flavor }} @ ${{ inputs.root_commit }}" >> build_summary.md
  391. echo "- **Kernel Version**: ${{ env.KERNEL_VER }}" >> build_summary.md
  392. echo "- **Android Version**: ${{ env.ANDROID_VER }}" >> build_summary.md
  393. echo "- **SUSFS**: ${{ env.SUSFS_COMMIT || 'disabled' }}" >> build_summary.md
  394. echo "- **BBG**: Installed" >> build_summary.md
  395. echo "" >> build_summary.md
  396. if [ -d "$CONFIG/KernelSU-Next" ]; then
  397. cd "$CONFIG/KernelSU-Next"
  398. KSUN_COMMIT=$(git rev-parse HEAD 2>/dev/null || echo "unknown")
  399. echo "- **KernelSU-Next**: $KSUN_COMMIT" >> "$GITHUB_WORKSPACE/build_summary.md"
  400. cd "$GITHUB_WORKSPACE"
  401. elif [ -d "$CONFIG/KernelSU" ]; then
  402. cd "$CONFIG/KernelSU"
  403. KSU_COMMIT=$(git rev-parse HEAD 2>/dev/null || echo "unknown")
  404. echo "- **KernelSU**: $KSU_COMMIT" >> "$GITHUB_WORKSPACE/build_summary.md"
  405. cd "$GITHUB_WORKSPACE"
  406. elif [ -d "$CONFIG/ReSukiSU" ]; then
  407. cd "$CONFIG/ReSukiSU"
  408. RS_COMMIT=$(git rev-parse HEAD 2>/dev/null || echo "unknown")
  409. echo "- **ReSukiSU**: $RS_COMMIT" >> "$GITHUB_WORKSPACE/build_summary.md"
  410. cd "$GITHUB_WORKSPACE"
  411. fi
  412. if [ -d "$CONFIG/Baseband-guard" ]; then
  413. cd "$CONFIG/Baseband-guard"
  414. BBG_COMMIT=$(git rev-parse HEAD)
  415. echo "- **Baseband-guard**: $BBG_COMMIT" >> "$GITHUB_WORKSPACE/build_summary.md"
  416. cd "$GITHUB_WORKSPACE"
  417. fi
  418. if [ -d "$GITHUB_WORKSPACE/susfs4ksu" ]; then
  419. cd "$GITHUB_WORKSPACE/susfs4ksu"
  420. SUSFS_COMMIT=$(git rev-parse HEAD)
  421. echo "- **SUSFS4KSU**: $SUSFS_COMMIT" >> "$GITHUB_WORKSPACE/build_summary.md"
  422. cd "$GITHUB_WORKSPACE"
  423. fi
  424. echo "" >> build_summary.md
  425. echo "## Build Artifacts" >> build_summary.md
  426. if [ -d "AnyKernel3" ] && [ -f "AnyKernel3/Image" ]; then
  427. AK3_STATUS="✅"
  428. else
  429. AK3_STATUS="❌"
  430. fi
  431. echo "- **AnyKernel3**: $AK3_STATUS ${{ env.FILE_NAME }}-AnyKernel3" >> build_summary.md