build.yml 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666
  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. optimizations:
  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: Free Disk Space
  49. if: true
  50. uses: endersonmenezes/free-disk-space@v3 # Use @main for latest, @v3 for stable
  51. with:
  52. remove_android: true
  53. remove_dotnet: true
  54. remove_haskell: true
  55. remove_tool_cache: true
  56. remove_swap: true
  57. remove_packages: "azure-cli google-cloud-cli microsoft-edge-stable google-chrome-stable firefox postgresql* temurin-* *llvm* mysql* dotnet-sdk-*"
  58. remove_packages_one_command: true
  59. 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"
  60. rm_cmd: "rmz" # Use 'rmz' for faster deletion (default: 'rm')
  61. rmz_version: "3.1.1" # Required when rm_cmd is 'rmz'
  62. testing: false
  63. - name: Setup more Swap (for LTO)
  64. uses: thejerrybao/setup-swap-space@v1 # or pierotofy/set-swap-space
  65. with:
  66. swap-size-gb: 25 # 10-24 GB is common for heavy LTO
  67. # swap-space-path: /mnt/swapfile # optional
  68. - name: Set CONFIG Environment Variable
  69. run: |
  70. # Set CONFIG dynamically based on inputs values
  71. CONFIG="${{ inputs.branch }}-${{ inputs.android_version }}-${{ inputs.kernel_version }}"
  72. # Set CONFIG as an environment variable for future steps
  73. echo "CONFIG=$CONFIG" >> $GITHUB_ENV
  74. - name: dependencies
  75. uses: ./.github/actions/dependencies
  76. with:
  77. zeromount: ${{ inputs.zeromount }}
  78. susfs: ${{ inputs.susfs }}
  79. android_version: ${{ inputs.android_version }}
  80. kernel_version: ${{ inputs.kernel_version }}
  81. - name: Download Kernel
  82. uses: ./.github/actions/clone-kernel
  83. with:
  84. branch: ${{ inputs.branch }}
  85. - name: Set Path Environment Variables
  86. run: |
  87. ROOT="$GITHUB_WORKSPACE"
  88. if [[ ${{ inputs.susfs }} == 'true' ]]; then
  89. SUSFS4KSU="$ROOT/susfs4ksu"
  90. KERNEL_PATCHES="$ROOT/kernel_patches"
  91. echo "SUSFS4KSU=$SUSFS4KSU" >> $GITHUB_ENV
  92. echo "KERNEL_PATCHES=$KERNEL_PATCHES" >> $GITHUB_ENV
  93. fi
  94. ANYKERNEL3="$ROOT/AnyKernel3"
  95. if [[ ${{ inputs.zeromount }} == 'true' ]]; then
  96. ZEROMOUNT="$ROOT/Super-Builders"
  97. echo "ZEROMOUNT=$ZEROMOUNT" >> $GITHUB_ENV
  98. fi
  99. if [[ ${{ inputs.branch }} == SM-A546* || "${{ inputs.branch }}" == "SM-M146B-Oneui7-ADYJ2" || "${{ inputs.branch }}" == "SM-S908B-Oneui8-bitK" ]]; then
  100. COMMON="$CONFIG"
  101. elif [[ "${{ inputs.branch }}" == "SM-A566B" || ${{ inputs.branch }} == SM-A055* ]]; then
  102. COMMON="$CONFIG/kernel-6.6"
  103. elif [[ "${{ inputs.branch }}" == "SM-S926B-Oneui8" || ${{ inputs.branch }} == SM-A556* ]]; then
  104. COMMON="$CONFIG/kernel"
  105. else
  106. COMMON="$CONFIG/kernel_platform/common"
  107. fi
  108. if [[ "${{ inputs.branch }}" == "SM-A546B-Oneui7" || "${{ inputs.branch }}" == "SM-A546B-Oneui8" ]]; then
  109. GKI_DEFCONFIG="$COMMON/arch/arm64/configs/s5e8835-a54xnaxx_defconfig"
  110. elif [[ "${{ inputs.branch }}" == "SM-A546E-Oneui7" || "${{ inputs.branch }}" == "SM-A546E-Oneui8" ]]; then
  111. GKI_DEFCONFIG="$COMMON/arch/arm64/configs/s5e8835-a54xnsxx_defconfig"
  112. elif [[ "${{ inputs.branch }}" == "SM-M146B-Oneui7-ADYJ2" ]]; then
  113. GKI_DEFCONFIG="$COMMON/arch/arm64/configs/s5e8535-m14xnsxx_defconfig"
  114. elif [[ "${{ inputs.branch }}" == "SM-S908B-Oneui8-bitK" ]]; then
  115. GKI_DEFCONFIG="$COMMON/arch/arm64/configs/s5e9925-b0sxxx_defconfig"
  116. else
  117. GKI_DEFCONFIG="$COMMON/arch/arm64/configs/gki_defconfig"
  118. fi
  119. echo "ROOT=$ROOT" >> $GITHUB_ENV
  120. echo "ANYKERNEL3=$ANYKERNEL3" >> $GITHUB_ENV
  121. echo "COMMON=$COMMON" >> $GITHUB_ENV
  122. echo "GKI_DEFCONFIG=$GKI_DEFCONFIG" >> $GITHUB_ENV
  123. - name: Extract all tar.xz files and delete them
  124. run: |
  125. cd "$CONFIG"
  126. find . -type f -name '*.tar.xz' -print0 | while IFS= read -r -d '' file; do
  127. echo "Extracting $file"
  128. tar -xf "$file"
  129. rm "$file"
  130. done
  131. - name: Add KernelSU-Next
  132. if: inputs.wksu == 'true'
  133. uses: ./.github/actions/ksun
  134. # - name: Getting KernelSU-Next Version
  135. # if: inputs.wksu == 'true'
  136. # run: |
  137. # cd "$COMMON/KernelSU-Next/kernel"
  138. #
  139. # KSU_DIR=$(pwd)
  140. # KBUILD="Kbuild"
  141. # BASE_VERSION=30000
  142. #if [ -d "$KSU_DIR/.git" ]; then
  143. # echo "✔ Git repo detected"
  144. # # Unshallow if needed
  145. # if [ -f "$KSU_DIR/.git/shallow" ]; then
  146. # git -C "$KSU_DIR" fetch --unshallow || true
  147. # fi
  148. # Get commit count
  149. # KSU_GIT_VERSION=$(git -C "$KSU_DIR" rev-list --count HEAD)
  150. # Calculate version
  151. # KSU_VERSION=$((BASE_VERSION + KSU_GIT_VERSION))
  152. # Get latest tag (safe)
  153. # KSU_GIT_TAG=$(git -C "$KSU_DIR" describe --tags --abbrev=0 2>/dev/null || echo "v0.0.1")
  154. # else
  155. # echo "⚠ Not a git repo, using defaults"
  156. # KSU_VERSION=33129
  157. # KSU_GIT_TAG="v3.2.0"
  158. # fi
  159. # echo "Computed version: $KSU_VERSION"
  160. # echo "Computed tag: $KSU_GIT_TAG"
  161. # Export for CI (optional)
  162. # echo "KSU_VERSION=$KSU_VERSION" >> $GITHUB_ENV
  163. # echo "KSU_VERSION_TAG=$KSU_GIT_TAG" >> $GITHUB_ENV
  164. # --- Update Kbuild fallback values ---
  165. # Update numeric fallback
  166. # sed -i "s/KSU_VERSION_FALLBACK := [0-9]\+/KSU_VERSION_FALLBACK := ${KSU_VERSION}/" "$KBUILD"
  167. # Update tag fallback
  168. # sed -i "s/KSU_VERSION_TAG_FALLBACK := .*/KSU_VERSION_TAG_FALLBACK := ${KSU_GIT_TAG}/" "$KBUILD"
  169. # echo "✅ Updated fallback values in $KBUILD"
  170. - name: Download susfs and kernel patches
  171. if: inputs.susfs == 'true'
  172. uses: ./.github/actions/susfs-clone
  173. with:
  174. android_version: ${{ inputs.android_version }}
  175. kernel_version: ${{ inputs.kernel_version }}
  176. - name: Apply SUSFS Patches
  177. if: inputs.susfs == 'true'
  178. uses: ./.github/actions/susfs-patches
  179. with:
  180. android_version: ${{ inputs.android_version }}
  181. kernel_version: ${{ inputs.kernel_version }}
  182. - name: Apply zeromount Patches
  183. if: inputs.susfs == 'true' && inputs.zeromount == 'true'
  184. uses: ./.github/actions/zeromount
  185. with:
  186. android_version: ${{ inputs.android_version }}
  187. kernel_version: ${{ inputs.kernel_version }}
  188. - name: Fix WiFi and Bluetooth on Samsung 6.6 GKI devices
  189. if: inputs.kernel_version == '6.6'
  190. uses: ./.github/actions/6.6-fix
  191. with:
  192. kernel_version: ${{ inputs.kernel_version }}
  193. - name: Add BBG
  194. if: inputs.bbg == 'true'
  195. run: |
  196. cd "$COMMON"
  197. echo "Adding BBG..."
  198. curl -LSs https://github.com/vc-teahouse/Baseband-guard/raw/main/setup.sh | bash
  199. echo "CONFIG_BBG=y" >> arch/arm64/configs/gki_defconfig
  200. sed -i '/^config LSM$/,/^help$/{ /^[[:space:]]*default/ { /baseband_guard/! s/selinux/selinux,baseband_guard/ } }' security/Kconfig
  201. cd "$GITHUB_WORKSPACE"
  202. sed -i '/^CONFIG_LSM=/ s/"$/,baseband_guard"/' "$GKI_DEFCONFIG"
  203. - name: temp fix for m55 bootloop maybe
  204. if: inputs.branch == 'SM-M556B-Oneui8'
  205. run: |
  206. cd "$COMMON"
  207. curl -L -s https://raw.githubusercontent.com/jimsterino98/Android-Kernel-Tutorials/refs/heads/main/patches/010.Disable-CRC-Checks.patch | patch -p1 --forward
  208. cd "$GITHUB_WORKSPACE"
  209. cat >> "$GKI_DEFCONFIG" << 'EOF'
  210. #Force Load Kernel Modules
  211. CONFIG_MODULES=y
  212. CONFIG_MODULE_FORCE_LOAD=y
  213. CONFIG_MODULE_UNLOAD=y
  214. CONFIG_MODULE_FORCE_UNLOAD=y
  215. CONFIG_MODVERSIONS=y
  216. CONFIG_MODULE_SRCVERSION_ALL=n
  217. CONFIG_MODULE_SIG=n
  218. CONFIG_MODULE_COMPRESS=n
  219. CONFIG_TRIM_UNUSED_KSYMS=n
  220. #Add btrfs user request
  221. CONFIG_BTRFS_FS=y
  222. EOF
  223. - name: Add unicodefix
  224. if: inputs.unicodefix == 'true'
  225. run: |
  226. cd "$COMMON"
  227. echo "detected kernel version: ${{ inputs.kernel_version }}"
  228. if [[ ${{ inputs.kernel_version }} == 6.* ]]; then
  229. cp "$KERNEL_PATCHES/common/unicode_bypass_fix_6.1+.patch" .
  230. patch -p1 < unicode_bypass_fix_6.1+.patch
  231. else
  232. cp "$KERNEL_PATCHES/common/unicode_bypass_fix_6.1-.patch" .
  233. patch -p1 < unicode_bypass_fix_6.1-.patch
  234. fi
  235. - name: Add droidspace support
  236. if: inputs.droidspace == 'true'
  237. run: |
  238. cd "$COMMON"
  239. # ABI: use ABI padding for SYSVIPC This commit allows us to enable CONFIG_SYSVIPC in defconfig without breaking kernel ABI
  240. curl -Ls https://github.com/nullptr-t-oss/android_kernel_common_oneplus_sm8550/commit/769a5cfdc17b98d8e0bd491d45f5651180e42196.patch | patch -p1 --forward
  241. cd "$GITHUB_WORKSPACE"
  242. cat >> "$GKI_DEFCONFIG" << 'EOF'
  243. # IPC
  244. CONFIG_SYSVIPC=y
  245. CONFIG_POSIX_MQUEUE=y
  246. # Namespaces
  247. CONFIG_IPC_NC=y
  248. CONFIG_PID_NS=y
  249. # HW Access Support
  250. CONFIG_DEVTMPFS=y
  251. # Below configs are optional
  252. # Docker NAT
  253. CONFIG_NETFILTER_XT_MATCH_ADDRTYPE=y
  254. # UFW
  255. CONFIG_NETFILTER_XT_TARGET_REJECT=y
  256. CONFIG_NETFILTER_XT_TARGET_LOG=y
  257. CONFIG_NETFILTER_XT_MATCH_RECENT
  258. # Fail2Ban
  259. CONFIG_IP_SET=y
  260. CONFIG_IP_SET_HASH_IP=y
  261. CONFIG_IP_SET_HASH_NET=y
  262. CONFIG_NETFILTER_XT_SET=y
  263. EOF
  264. - name: Set Kernel Configuration Variables
  265. if: inputs.wksu == 'true'
  266. run: |
  267. echo "Initializing kernel configuration..."
  268. cat >> "$GKI_DEFCONFIG" << 'EOF'
  269. # Mountify Support
  270. CONFIG_OVERLAY_FS=y
  271. CONFIG_TMPFS_XATTR=y
  272. CONFIG_TMPFS_POSIX_ACL=y
  273. # increase log buffer size to show bbg version in wksu homepage
  274. CONFIG_LOG_BUF_SHIFT=20
  275. EOF
  276. if [[ "${{ inputs.branch }}" == "SM-S938B-Oneui7" || "${{ inputs.branch }}" == "SM-S931B-Oneui8" ]]; then
  277. echo "nothing to see here moving on"
  278. elif [[ "${{ inputs.branch }}" == "SM-S926B-Oneui8" ]]; then
  279. cat >> "$COMMON/arch/arm64/configs/s5e9945-bazel_defconfig" << 'EOF'
  280. # nuke root protection
  281. CONFIG_UH=n
  282. CONFIG_UH_RKP=n
  283. CONFIG_UH_LKMAUTH=n
  284. CONFIG_UH_LKM_BLOCK=n
  285. CONFIG_RKP_CFP_JOPP=n
  286. CONFIG_RKP_CFP=n
  287. CONFIG_SECURITY_DEFEX=n
  288. CONFIG_PROCA=n
  289. CONFIG_FIVE=n
  290. CONFIG_RKP=n
  291. CONFIG_KDP_NS=n
  292. CONFIG_KDP=n
  293. EOF
  294. elif [[ ${{ inputs.branch }} == SM-A556* ]]; then
  295. cat >> "$COMMON/arch/arm64/configs/s5e8845-bazel_defconfig" << 'EOF'
  296. # nuke root protection
  297. CONFIG_UH=n
  298. CONFIG_UH_RKP=n
  299. CONFIG_UH_LKMAUTH=n
  300. CONFIG_UH_LKM_BLOCK=n
  301. CONFIG_RKP_CFP_JOPP=n
  302. CONFIG_RKP_CFP=n
  303. CONFIG_SECURITY_DEFEX=n
  304. CONFIG_PROCA=n
  305. CONFIG_FIVE=n
  306. CONFIG_RKP=n
  307. CONFIG_KDP_NS=n
  308. CONFIG_KDP=n
  309. EOF
  310. else
  311. cat >> "$GKI_DEFCONFIG" << 'EOF'
  312. # nuke root protection
  313. CONFIG_UH=n
  314. CONFIG_UH_RKP=n
  315. CONFIG_UH_LKMAUTH=n
  316. CONFIG_UH_LKM_BLOCK=n
  317. CONFIG_RKP_CFP_JOPP=n
  318. CONFIG_RKP_CFP=n
  319. CONFIG_SECURITY_DEFEX=n
  320. CONFIG_PROCA=n
  321. CONFIG_FIVE=n
  322. CONFIG_RKP=n
  323. CONFIG_KDP_NS=n
  324. CONFIG_KDP=n
  325. EOF
  326. fi
  327. cd "$COMMON"
  328. # Remove check_defconfig
  329. sed -i 's/check_defconfig//' ./build.config.gki
  330. - name: Add optimizations from kernel patches/common
  331. if: inputs.optimizations == 'true'
  332. run: |
  333. cd "$COMMON"
  334. echo "Optimizing Kernel..."
  335. cp "$KERNEL_PATCHES/common/"*.patch ./
  336. rm -rf unicode_bypass_fix_6.1+.patch
  337. rm -rf unicode_bypass_fix_6.1-.patch
  338. rm -rf IPv6_NAT_FIX.patch
  339. for p in *.patch; do
  340. if patch -p1 --dry-run < "$p"; then
  341. echo "patch is OK, applying $p"
  342. patch -p1 < "$p"
  343. rm -f "$p"
  344. else
  345. echo "$p failed, skipping patch"
  346. fi
  347. done
  348. echo "Kernel Optimized, hehe"
  349. - name: Add ntsync
  350. if: inputs.ntsync == 'true'
  351. run: |
  352. cd "$COMMON"
  353. echo "applying ntsync patches"
  354. cp "$KERNEL_PATCHES/common/ntsync/ntsync_base.patch" .
  355. cp "$KERNEL_PATCHES/common/ntsync/ntsync_compat_${{ inputs.android_version }}-${{ inputs.kernel_version }}.patch" .
  356. patch -p1 < ntsync_base.patch || true
  357. patch -p1 < ntsync_compat_${{ inputs.android_version }}-${{ inputs.kernel_version }}.patch
  358. cd "$GITHUB_WORKSPACE"
  359. cat >> "$GKI_DEFCONFIG" << 'EOF'
  360. CONFIG_NTSYNC=y
  361. EOF
  362. - name: Change Kernel Name and remove protected exports
  363. run: |
  364. cd "$COMMON"
  365. #Add Wild to Kernel Version
  366. sed -i '$s|echo "\$res"|echo "\$res-Wild"|' ./scripts/setlocalversion
  367. #Set Kernel Timestamp
  368. #perl -pi -e 's{UTS_VERSION="\$\(echo \$UTS_VERSION \$CONFIG_FLAGS \$TIMESTAMP \| cut -b -\$UTS_LEN\)"}{UTS_VERSION="#1 SMP PREEMPT Sun Apr 20 04:20:00 UTC 2025"}' ./scripts/mkcompile_h
  369. #Remove Abi Exports and Error
  370. rm -rf ./android/abi_gki_protected_exports_*
  371. perl -pi -e 's/^\s*"protected_exports_list"\s*:\s*"android\/abi_gki_protected_exports_aarch64",\s*$//;' ./BUILD.bazel
  372. - name: Clean Dirty Flags
  373. run: |
  374. # remove dirty
  375. sed -i 's/-dirty//' "./$COMMON/scripts/setlocalversion"
  376. - name: Set file name
  377. if: inputs.wksu == 'true'
  378. run: |
  379. ARTIFACT_BASE="${{ inputs.branch }}-${{ inputs.kernel_version }}-${{ inputs.android_version }}"
  380. # This gives: KSUxxxxx-branch-xxx-xxx
  381. FILE_NAME="KSU${KSU_VERSION}-${ARTIFACT_BASE}"
  382. echo "ARTIFACT_BASE=$ARTIFACT_BASE" >> $GITHUB_ENV
  383. echo "FILE_NAME=$FILE_NAME" >> $GITHUB_ENV
  384. echo "✅ Final artifact name: $FILE_NAME"
  385. - name: Build
  386. run : |
  387. set -e
  388. set -x
  389. cd "$CONFIG"
  390. echo "Building the kernel..."
  391. if [[ ${{ inputs.branch }} == SM-S928B* || "${{ inputs.branch }}" == "SM-S938B-Oneui7" || "${{ inputs.branch }}" == "SM-S931B-Oneui8" || "${{ inputs.branch }}" == "SM-F741B-Oneui8" ]]; then
  392. chmod +x build_kernel_GKI.sh
  393. ./build_kernel_GKI.sh || true
  394. elif [[ "${{ inputs.branch }}" == "SM-X916B" || "${{ inputs.branch }}" == "SM-F946N-Oneui7" || "${{ inputs.branch }}" == "SM-S916B-Oneui8" || "${{ inputs.branch }}" == "SM-S918B-Oneui8" || "${{ inputs.branch }}" == "SM-F946B-Oneui8" || "${{ inputs.branch }}" == "SM-S901E-Oneui8" || "${{ inputs.branch }}" == "SM-X800-Oneui8" || "${{ inputs.branch }}" == "SM-S911B-Oneui8-bit8" || "${{ inputs.branch }}" == "SM-M556B-Oneui8" ]]; then
  395. chmod +x build_kernel_GKI.sh
  396. #LTO=thin ./build_kernel_GKI.sh || true
  397. ./build_kernel_GKI.sh || true
  398. elif [[ ${{ inputs.branch }} == SM-A546* || "${{ inputs.branch }}" == "SM-M146B-Oneui7-ADYJ2" || "${{ inputs.branch }}" == "SM-S908B-Oneui8-bitK" ]]; then
  399. sudo apt update
  400. sudo apt-get install -y libyaml-dev
  401. chmod +x build_kernel.sh
  402. #LTO=thin ./build_kernel.sh || true
  403. ./build_kernel.sh || true
  404. elif [[ "${{ inputs.branch }}" == "SM-A566B" ]]; then
  405. chmod +x build_script.sh
  406. touch ./kernel-6.6/abi_symbollist.raw
  407. touch ./kernel-6.6/abi_symbollist
  408. ./build_script.sh || true
  409. elif [[ "${{ inputs.branch }}" == "SM-S926B-Oneui8" ]]; then
  410. tools/bazel run --nocheck_bzl_visibility --config=stamp --sandbox_debug --verbose_failures --debug_make_verbosity=I //projects/s5e9945:s5e9945_user_dist
  411. elif [[ ${{ inputs.branch }} == SM-A556* ]]; then
  412. tools/bazel run --nocheck_bzl_visibility --config=stamp --sandbox_debug --verbose_failures --debug_make_verbosity=I //projects/s5e8845:s5e8845_user_dist
  413. elif [[ ${{ inputs.branch }} == SM-A055* ]]; then
  414. chmod +x build_kernel.sh
  415. ./build_kernel.sh
  416. else
  417. #temporarily using this until i can figure out the other phones build script issues
  418. cd kernel_platform
  419. tools/bazel build --config=fast --lto=thin //common:kernel_aarch64_dist || exit 1
  420. fi
  421. - name: Prepare AnyKernel3
  422. run: |
  423. cd "$CONFIG"
  424. # Copy Image from normal build locations
  425. #if [ -f "./$CONFIG/out/${{ inputs.android_version }}-${{ inputs.kernel_version }}/dist/Image" ]; then
  426. # cp ./$CONFIG/out/${{ inputs.android_version }}-${{ inputs.kernel_version }}/dist/Image AnyKernel3/Image
  427. #elif [ -f "./$CONFIG/bazel-bin/common/kernel_aarch64/Image" ]; then
  428. # cp ./$CONFIG/bazel-bin/common/kernel_aarch64/Image AnyKernel3/Image
  429. #else
  430. # echo "Error: Image file not found in any expected location"
  431. # exit 1
  432. #fi
  433. if [[ "${{ inputs.branch }}" == "SM-S928B-Oneui7" || "${{ inputs.branch }}" == "SM-S928B-Oneui8-bit4" || "${{ inputs.branch }}" == "SM-S928B-Oneui8-bit5" || "${{ inputs.branch }}" == "SM-F741B-Oneui8" ]]; then
  434. cp ./kernel_platform/sec/dist/Image "$ANYKERNEL3/Image"
  435. elif [[ "${{ inputs.branch }}" == "SM-S928B-Oneui6.1" ]]; then
  436. cp ./out/msm-pineapple-pineapple-gki/dist/Image "$ANYKERNEL3/Image"
  437. elif [[ "${{ inputs.branch }}" == "SM-S938B-Oneui7" || "${{ inputs.branch }}" == "SM-S931B-Oneui8" || "${{ inputs.branch }}" == "SM-M556B-Oneui8" ]]; then
  438. cp ./kernel_platform/gki/dist/Image "$ANYKERNEL3/Image"
  439. elif [[ -f ./$CONFIG/bazel-bin/common/kernel_aarch64/Image ]]; then
  440. cp ./$CONFIG/bazel-bin/common/kernel_aarch64/Image "$ANYKERNEL3/Image"
  441. elif [[ "${{ inputs.branch }}" == "SM-X916B" || "${{ inputs.branch }}" == "SM-F946N-Oneui7" || "${{ inputs.branch }}" == "SM-F946B-Oneui8" || "${{ inputs.branch }}" == "SM-S916B-Oneui8" || "${{ inputs.branch }}" == "SM-S918B-Oneui8" || "${{ inputs.branch }}" == "SM-S911B-Oneui8-bit8" ]]; then
  442. cp ./out/msm-kalama-kalama-gki/dist/Image "$ANYKERNEL3/Image"
  443. elif [[ ${{ inputs.branch }} == SM-A546* || "${{ inputs.branch }}" == "SM-M146B-Oneui7-ADYJ2" || "${{ inputs.branch }}" == "SM-S908B-Oneui8-bitK" ]]; then
  444. cp ./arch/arm64/boot/Image "$ANYKERNEL3/Image"
  445. elif [[ "${{ inputs.branch }}" == "SM-A566B" ]]; then
  446. cp ./kernel-6.6/out/arch/arm64/boot/Image "$ANYKERNEL3/Image"
  447. elif [[ "${{ inputs.branch }}" == "SM-S926B-Oneui8" ]]; then
  448. cp ./out/s5e9945_user/dist/Image "$ANYKERNEL3/Image"
  449. elif [[ ${{ inputs.branch }} == SM-A556* ]]; then
  450. cp ./out/s5e8845_user/dist/Image "$ANYKERNEL3/Image"
  451. elif [[ "${{ inputs.branch }}" == "SM-S901E-Oneui8" || "${{ inputs.branch }}" == "SM-X800-Oneui8" ]]; then
  452. cp ./out/msm-waipio-waipio-gki/dist/Image "$ANYKERNEL3/Image"
  453. elif [[ ${{ inputs.branch }} == SM-A055* ]]; then
  454. cp ./out/target/product/a05m/obj/KLEAF_OBJ/dist/kernel_device_modules-6.6/mgk_64_k66_kernel_aarch64.user/Image.gz "$ANYKERNEL3/Image.gz"
  455. else
  456. echo "Error: Image file not found in any expected location"
  457. exit 1
  458. fi
  459. - name: Upload AnyKernel3 Artifacts
  460. id: upload_ak3
  461. uses: actions/upload-artifact@v6
  462. with:
  463. name: ${{ env.FILE_NAME }}-AnyKernel3
  464. path: |
  465. ./AnyKernel3/**
  466. compression-level: 9
  467. - name: Scan and collect patch rejects
  468. if: ${{ always() }}
  469. run: |
  470. set -e
  471. CONFIG_DIR="$CONFIG"
  472. REJECTS_DIR="$GITHUB_WORKSPACE/patch-rejects"
  473. mkdir -p "$REJECTS_DIR"
  474. # Find all .rej files under the configuration directory
  475. mapfile -t REJS < <(find "$CONFIG_DIR" -type f -name '*.rej')
  476. REJ_COUNT=${#REJS[@]}
  477. echo "Found $REJ_COUNT .rej files under $CONFIG_DIR"
  478. echo "REJ_COUNT=$REJ_COUNT" >> $GITHUB_ENV
  479. if [ "$REJ_COUNT" -gt 0 ]; then
  480. for REJ in "${REJS[@]}"; do
  481. # Relative path from $CONFIG
  482. REL="${REJ#"$CONFIG_DIR"/}"
  483. DEST="$REJECTS_DIR/$REL"
  484. mkdir -p "$(dirname "$DEST")"
  485. cp "$REJ" "$DEST"
  486. # Copy the associated original file alongside the .rej
  487. ORIG="${REJ%.rej}"
  488. if [ -f "$ORIG" ]; then
  489. ORIG_DEST="$REJECTS_DIR/${REL%.rej}"
  490. mkdir -p "$(dirname "$ORIG_DEST")"
  491. cp "$ORIG" "$ORIG_DEST"
  492. fi
  493. echo "$REL" >> "$REJECTS_DIR/index.txt"
  494. done
  495. fi
  496. - name: Generate Build Summary
  497. if: ${{ always() }}
  498. run: |
  499. # Create build summary file for inclusion in Misc artifact
  500. echo "# Kernel Build Summary" > build_summary.md
  501. # Add build variant header
  502. echo "## ${{ env.FILE_NAME }}" >> build_summary.md
  503. # Add build info
  504. echo "## Build Information" >> build_summary.md
  505. echo "- **Android Version**: ${{ inputs.android_version }}" >> build_summary.md
  506. echo "- **Kernel Version**: ${{ inputs.kernel_version }}.${{ inputs.sub_level }}" >> build_summary.md
  507. echo "- **BBG**: Installed" >> build_summary.md
  508. echo "- **Bypass Mode**: ${{ matrix.apply_bypass }}" >> build_summary.md
  509. echo "" >> build_summary.md
  510. # Get KernelSU-Next commit
  511. if [ -d "$CONFIG/KernelSU-Next" ]; then
  512. cd "$CONFIG/KernelSU-Next"
  513. KSUN_COMMIT=$(git rev-parse HEAD)
  514. KSUN_URL="https://github.com/WildKernels/KernelSU-Next/commit/$KSUN_COMMIT"
  515. echo "- **KernelSU-Next**: [$KSUN_COMMIT]($KSUN_URL)" >> "$GITHUB_WORKSPACE/build_summary.md"
  516. cd "$GITHUB_WORKSPACE"
  517. else
  518. echo "- **KernelSU-Next**: not present" >> build_summary.md
  519. fi
  520. # Get Baseband-guard commit
  521. if [ -d "$CONFIG/Baseband-guard" ]; then
  522. cd "$CONFIG/Baseband-guard"
  523. BBG_COMMIT=$(git rev-parse HEAD)
  524. BBG_URL="https://github.com/vc-teahouse/Baseband-guard/commit/$BBG_COMMIT"
  525. echo "- **Baseband-guard**: [$BBG_COMMIT]($BBG_URL)" >> "$GITHUB_WORKSPACE/build_summary.md"
  526. cd "$GITHUB_WORKSPACE"
  527. else
  528. echo "- **Baseband-guard**: not present" >> build_summary.md
  529. fi
  530. # Get SUSFS4KSU commit
  531. if [ -d "$GITHUB_WORKSPACE/susfs4ksu" ]; then
  532. cd "$GITHUB_WORKSPACE/susfs4ksu"
  533. SUSFS_COMMIT=$(git rev-parse HEAD)
  534. SUSFS_URL="https://gitlab.com/simonpunk/susfs4ksu/-/commit/$SUSFS_COMMIT"
  535. echo "- **SUSFS4KSU (v2.1.0)**: [$SUSFS_COMMIT]($SUSFS_URL)" >> "$GITHUB_WORKSPACE/build_summary.md"
  536. cd "$GITHUB_WORKSPACE"
  537. else
  538. echo "- **SUSFS4KSU (v2.1.0)**: not present" >> build_summary.md
  539. fi
  540. echo "" >> build_summary.md
  541. # Add artifact summary with presence verification
  542. echo "## Build Artifacts" >> build_summary.md
  543. # Verify AnyKernel3 contents - check if kernel Image was actually copied (indicates successful build)
  544. if [ -d "AnyKernel3" ] && [ -f "AnyKernel3/Image" ]; then
  545. AK3_STATUS="✅"
  546. else
  547. AK3_STATUS="❌"
  548. fi
  549. echo "- **AnyKernel3**: $AK3_STATUS ${{ env.FILE_NAME }}-AnyKernel3" >> build_summary.md
  550. echo "### Misc (uploaded files)" >> build_summary.md
  551. FILES_PRESENT=0
  552. 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
  553. if [ -f "$f" ]; then FILES_PRESENT=$((FILES_PRESENT+1)); fi
  554. done
  555. if [ "$FILES_PRESENT" -gt 0 ]; then
  556. MISC_STATUS="✅"
  557. else
  558. MISC_STATUS="❌"
  559. fi
  560. echo "- **Set**: $MISC_STATUS ${{ env.FILE_NAME }}-Misc" >> build_summary.md
  561. if [ "$MISC_STATUS" = "✅" ]; then
  562. echo " Included:" >> build_summary.md
  563. 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
  564. if [ -f "$f" ]; then
  565. echo " - $f" >> build_summary.md
  566. fi
  567. done
  568. fi
  569. echo "### Diagnostics" >> build_summary.md
  570. echo "- **Rejected Patches**: ${{ env.FILE_NAME }}-Rejected-Patches" >> build_summary.md
  571. if [ -f patch-rejects/index.txt ]; then
  572. if [ -s patch-rejects/index.txt ]; then
  573. echo " Rejected files:" >> build_summary.md
  574. while IFS= read -r line; do
  575. echo " - $line" >> build_summary.md
  576. done < patch-rejects/index.txt
  577. else
  578. echo " Rejected file list is empty." >> build_summary.md
  579. fi
  580. else
  581. echo " No rejected patches found." >> build_summary.md
  582. fi