build.yml 17 KB

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