build.yml 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627
  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. bbrv3:
  24. required: true
  25. type: string
  26. unicodefix:
  27. required: true
  28. type: string
  29. jobs:
  30. build-samsung-gki:
  31. name: "${{ inputs.branch }}-${{ inputs.kernel_version }}-${{ inputs.android_version }}"
  32. runs-on: ubuntu-latest
  33. strategy:
  34. fail-fast: false
  35. steps:
  36. - name: Free Disk Space
  37. if: true
  38. uses: endersonmenezes/free-disk-space@v3 # Use @main for latest, @v3 for stable
  39. with:
  40. remove_android: true
  41. remove_dotnet: true
  42. remove_haskell: true
  43. remove_tool_cache: true
  44. remove_swap: true
  45. remove_packages: "azure-cli google-cloud-cli microsoft-edge-stable google-chrome-stable firefox postgresql* temurin-* *llvm* mysql* dotnet-sdk-*"
  46. remove_packages_one_command: true
  47. 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"
  48. rm_cmd: "rmz" # Use 'rmz' for faster deletion (default: 'rm')
  49. rmz_version: "3.1.1" # Required when rm_cmd is 'rmz'
  50. testing: false
  51. - name: Set CONFIG Environment Variable
  52. run: |
  53. # Set CONFIG dynamically based on inputs values
  54. CONFIG="${{ inputs.branch }}-${{ inputs.android_version }}-${{ inputs.kernel_version }}"
  55. # Set CONFIG as an environment variable for future steps
  56. echo "CONFIG=$CONFIG" >> $GITHUB_ENV
  57. - name: Clone AnyKernel3 and Other Dependencies
  58. run: |
  59. ANYKERNEL_BRANCH="gki-2.0"
  60. SUSFS_BRANCH="gki-${{ inputs.android_version }}-${{ inputs.kernel_version }}"
  61. git clone https://github.com/WildKernels/AnyKernel3.git -b "$ANYKERNEL_BRANCH"
  62. git clone https://github.com/WildKernels/kernel_patches.git
  63. git clone https://gitlab.com/simonpunk/susfs4ksu.git -b "$SUSFS_BRANCH"
  64. - name: Clone Kernel Source
  65. run: |
  66. git clone --depth 1 -b ${{ inputs.branch }} --single-branch https://github.com/WildKernels/Samsung_Kernels.git $CONFIG
  67. - name: Set Path Environment Variables
  68. run: |
  69. ROOT="$GITHUB_WORKSPACE"
  70. SUSFS4KSU="$ROOT/susfs4ksu"
  71. KERNEL_PATCHES="$ROOT/kernel_patches"
  72. ANYKERNEL3="$ROOT/AnyKernel3"
  73. if [[ "${{ inputs.branch }}" == "SM-A546B-Oneui7" || "${{ inputs.branch }}" == "SM-A546E-Oneui7" || "${{ inputs.branch }}" == "SM-M146B-Oneui7-ADYJ2" ]]; then
  74. COMMON="$CONFIG"
  75. elif [[ "${{ inputs.branch }}" == "SM-A566B" ]]; then
  76. COMMON="$CONFIG/kernel-6.6"
  77. elif [[ "${{ inputs.branch }}" == "SM-S926B-Oneui8" ]]; then
  78. COMMON="$CONFIG/kernel"
  79. else
  80. COMMON="$CONFIG/kernel_platform/common"
  81. fi
  82. if [[ "${{ inputs.branch }}" == "SM-A546B-Oneui7" ]]; then
  83. DEFCONFIG="$COMMON/arch/arm64/configs/s5e8835-a54xnaxx_defconfig"
  84. elif [[ "${{ inputs.branch }}" == "SM-A546E-Oneui7" ]]; then
  85. DEFCONFIG="$COMMON/arch/arm64/configs/s5e8835-a54xnsxx_defconfig"
  86. elif [[ "${{ inputs.branch }}" == "SM-M146B-Oneui7-ADYJ2" ]]; then
  87. DEFCONFIG="$COMMON/arch/arm64/configs/s5e8535-m14xnsxx_defconfig"
  88. else
  89. DEFCONFIG="$COMMON/arch/arm64/configs/gki_defconfig"
  90. fi
  91. echo "ROOT=$ROOT" >> $GITHUB_ENV
  92. echo "SUSFS4KSU=$SUSFS4KSU" >> $GITHUB_ENV
  93. echo "KERNEL_PATCHES=$KERNEL_PATCHES" >> $GITHUB_ENV
  94. echo "ANYKERNEL3=$ANYKERNEL3" >> $GITHUB_ENV
  95. echo "COMMON=$COMMON" >> $GITHUB_ENV
  96. echo "DEFCONFIG=$DEFCONFIG" >> $GITHUB_ENV
  97. - name: Extract all tar.xz files and delete them
  98. run: |
  99. cd "$CONFIG"
  100. find . -type f -name '*.tar.xz' -print0 | while IFS= read -r -d '' file; do
  101. echo "Extracting $file"
  102. tar -xf "$file"
  103. rm "$file"
  104. done
  105. - name: Add Wild_KSU
  106. run: |
  107. cd "$COMMON"
  108. curl -LSs "https://raw.githubusercontent.com/WildKernels/Wild_KSU/wild/kernel/setup.sh" | bash -s canary
  109. cd "$GITHUB_WORKSPACE"
  110. cat >> "$DEFCONFIG" << 'EOF'
  111. # KernelSU Configuration
  112. CONFIG_KSU=y
  113. EOF
  114. - name: Getting Wild_KSU Version
  115. run: |
  116. cd "$COMMON/Wild_KSU/kernel"
  117. KSU_DIR=$(pwd)
  118. KBUILD="Kbuild"
  119. BASE_VERSION=30000
  120. if [ -d "$KSU_DIR/.git" ]; then
  121. echo "✔ Git repo detected"
  122. # Unshallow if needed
  123. if [ -f "$KSU_DIR/.git/shallow" ]; then
  124. git -C "$KSU_DIR" fetch --unshallow || true
  125. fi
  126. # Get commit count
  127. KSU_GIT_VERSION=$(git -C "$KSU_DIR" rev-list --count HEAD)
  128. # Calculate version
  129. KSU_VERSION=$((BASE_VERSION + KSU_GIT_VERSION))
  130. # Get latest tag (safe)
  131. KSU_GIT_TAG=$(git -C "$KSU_DIR" describe --tags --abbrev=0 2>/dev/null || echo "v0.0.1")
  132. else
  133. echo "⚠ Not a git repo, using defaults"
  134. KSU_VERSION=33208
  135. KSU_GIT_TAG="v3.1.2"
  136. fi
  137. echo "Computed version: $KSU_VERSION"
  138. echo "Computed tag: $KSU_GIT_TAG"
  139. # Export for CI (optional)
  140. echo "KSU_VERSION=$KSU_VERSION" >> $GITHUB_ENV
  141. echo "KSU_VERSION_TAG=$KSU_GIT_TAG" >> $GITHUB_ENV
  142. # --- Update Kbuild fallback values ---
  143. # Update numeric fallback
  144. sed -i "s/KSU_VERSION_FALLBACK := [0-9]\+/KSU_VERSION_FALLBACK := ${KSU_VERSION}/" "$KBUILD"
  145. # Update tag fallback
  146. sed -i "s/KSU_VERSION_TAG_FALLBACK := .*/KSU_VERSION_TAG_FALLBACK := ${KSU_GIT_TAG}/" "$KBUILD"
  147. echo "✅ Updated fallback values in $KBUILD"
  148. - name: Apply SUSFS Patches
  149. if: inputs.susfs == 'true'
  150. run: |
  151. cd "$COMMON"
  152. # Apply compatibility fixes
  153. SUSFS_VERSION="2.1.0"
  154. cp "$SUSFS4KSU/kernel_patches/fs/"* ./fs/
  155. cp "$SUSFS4KSU/kernel_patches/include/linux/"* ./include/linux/
  156. cp "$SUSFS4KSU/kernel_patches/50_add_susfs_in_gki-${{ inputs.android_version }}-${{ inputs.kernel_version }}.patch" ./
  157. #Prepare open.c for susfs patching
  158. sed -i '/#ifdef CONFIG_SECURITY_DEFEX/,/^#endif/d' fs/open.c
  159. #Prepare namespace.c for susfs patching
  160. perl -0777 -i -pe '
  161. s/#include <linux\/fslog\.h>\n#ifdef CONFIG_KDP_NS\n#include <linux\/kdp\.h>\n#endif\n//;
  162. s/(#include <linux\/sched\/task\.h>\n)/$1#include <linux\/fslog.h>\n#ifdef CONFIG_KDP_NS\n#include <linux\/kdp.h>\n#endif\n/;
  163. ' fs/namespace.c
  164. sed -i '/copy_flags = CL_COPY_UNBINDABLE | CL_EXPIRE;/,/#endif/ {
  165. /#ifdef CONFIG_KDP_NS/,/#endif/ {
  166. /#else/,/#endif/!d
  167. /#else/d
  168. /#endif/d
  169. }
  170. }' fs/namespace.c
  171. # Apply SUSFS core patch
  172. #curl -L -s https://raw.githubusercontent.com/Enginex0/Super-Builders/refs/heads/main/android14-6.1/samsung-fixes/SM-S928B/fix_namespace_context.patch | patch -p1 --forward
  173. patch -p1 < 50_add_susfs_in_gki-${{ inputs.android_version }}-${{ inputs.kernel_version }}.patch || true
  174. #rm -rf 50_add_susfs_in_gki-${{ inputs.android_version }}-${{ inputs.kernel_version }}.patch
  175. #cp "$KERNEL_PATCHES/samsung/${{ inputs.branch }}/"* ./
  176. # Fix SUSFS rejects
  177. #for p in *.patch; do
  178. # patch -p1 < "$p"
  179. #done
  180. cd "$GITHUB_WORKSPACE"
  181. cat >> "$DEFCONFIG" << 'EOF'
  182. # SUSFS Configuration
  183. CONFIG_KSU_SUSFS=y
  184. EOF
  185. - name: Fix WiFi and Bluetooth on Samsung 6.6 GKI devices
  186. if: ${{ inputs.kernel_version == '6.6' }}
  187. run: |
  188. cd "$COMMON"
  189. SYMBOL_LIST=android/abi_gki_aarch64_galaxy
  190. echo "kdp_set_cred_non_rcu" >> $SYMBOL_LIST
  191. echo "kdp_usecount_dec_and_test" >> $SYMBOL_LIST
  192. echo "kdp_usecount_inc" >> $SYMBOL_LIST
  193. if [[ "${{ inputs.branch }}" == "SM-S931B-Oneui8" ]]; then
  194. echo "snd_soc_find_dai" >> $SYMBOL_LIST
  195. sed -i '
  196. /"kernel_aarch64": {/,/},/ {
  197. s/"kmi_symbol_list_strict_mode": True/"kmi_symbol_list_strict_mode": False/
  198. s/"trim_nonlisted_kmi": True/"trim_nonlisted_kmi": False/
  199. }
  200. /"kernel_aarch64_16k": {/,/},/ {
  201. s/"kmi_symbol_list_strict_mode": True/"kmi_symbol_list_strict_mode": False/
  202. s/"trim_nonlisted_kmi": True/"trim_nonlisted_kmi": False/
  203. }
  204. ' BUILD.bazel
  205. fi
  206. cp "$KERNEL_PATCHES/samsung/min_kdp/min_kdp.c" drivers/min_kdp.c
  207. echo "obj-y += min_kdp.o" >> drivers/Makefile
  208. - name: Add BBG
  209. if: inputs.bbg == 'true'
  210. run: |
  211. cd "$COMMON"
  212. echo "Adding BBG..."
  213. curl -LSs https://github.com/vc-teahouse/Baseband-guard/raw/main/setup.sh | bash
  214. echo "CONFIG_BBG=y" >> arch/arm64/configs/gki_defconfig
  215. sed -i '/^config LSM$/,/^help$/{ /^[[:space:]]*default/ { /baseband_guard/! s/selinux/selinux,baseband_guard/ } }' security/Kconfig
  216. # if grep -qxF $'\t\tconst char* symlink_target_link = inode->i_op->get_link(dentry, inode, NULL);' ./Baseband-guard/baseband_guard.c; then
  217. # echo "Applying BBG get_link fix"
  218. # patch -p1 --forward < "$KERNEL_PATCHES/experimental/bbg/bbg_fix_get_link.patch"
  219. # fi
  220. - name: Add unicodefix
  221. if: inputs.unicodefix == 'true'
  222. run: |
  223. cd "$COMMON"
  224. echo "detected kernel version: ${{ inputs.kernel_version }}"
  225. if [[ ${{ inputs.kernel_version }} == 6.* ]]; then
  226. cp "$KERNEL_PATCHES/common/unicode_bypass_fix_6.1+.patch" .
  227. patch -p1 < unicode_bypass_fix_6.1+.patch
  228. else
  229. cp "$KERNEL_PATCHES/common/unicode_bypass_fix_6.1-.patch" .
  230. patch -p1 < unicode_bypass_fix_6.1-.patch
  231. fi
  232. - name: Add BBRv3
  233. if: inputs.bbrv3 == 'true'
  234. run: |
  235. cd "$COMMON"
  236. echo "applying BBRv3"
  237. curl -L -s https://raw.githubusercontent.com/ahmed-alnassif/GKI-Duchamp/refs/heads/dev/kernel-patches/bbrv3/bbrv3.patch | patch -p1 --forward
  238. cd "$GITHUB_WORKSPACE"
  239. cat >> "$DEFCONFIG" << 'EOF'
  240. # Networking extras
  241. CONFIG_IP_NF_TARGET_TTL=y
  242. CONFIG_NET_SCH_FQ=y
  243. CONFIG_TCP_CONG_ADVANCED=y
  244. CONFIG_DEFAULT_BBR=y
  245. CONFIG_TCP_CONG_BBR=y
  246. CONFIG_TCP_CONG_WESTWOOD=y
  247. CONFIG_IP6_NF_TARGET_HL=y
  248. CONFIG_IP6_NF_MATCH_HL=y
  249. EOF
  250. - name: Set Kernel Configuration Variables
  251. run: |
  252. echo "Initializing kernel configuration..."
  253. cat >> "$DEFCONFIG" << 'EOF'
  254. # Mountify Support
  255. CONFIG_OVERLAY_FS=y
  256. CONFIG_TMPFS_XATTR=y
  257. CONFIG_TMPFS_POSIX_ACL=y
  258. # increase log buffer size to show bbg version in wksu homepage
  259. CONFIG_LOG_BUF_SHIFT=20
  260. EOF
  261. if [[ "${{ inputs.branch }}" == "SM-S938B-Oneui7" || "${{ inputs.branch }}" == "SM-S931B-Oneui8" ]]; then
  262. echo "nothing needs to be done"
  263. elif [[ "${{ inputs.branch }}" == "SM-A546B-Oneui7" || "${{ inputs.branch }}" == "SM-A546E-Oneui7" || "${{ inputs.branch }}" == "SM-M146B-Oneui7-ADYJ2" ]]; then
  264. cat >> "$DEFCONFIG" << 'EOF'
  265. # nuke root protection
  266. CONFIG_UH=n
  267. CONFIG_UH_RKP=n
  268. CONFIG_UH_LKMAUTH=n
  269. CONFIG_UH_LKM_BLOCK=n
  270. CONFIG_RKP_CFP_JOPP=n
  271. CONFIG_RKP_CFP=n
  272. CONFIG_SECURITY_DEFEX=n
  273. CONFIG_PROCA=n
  274. CONFIG_FIVE=n
  275. CONFIG_RKP=n
  276. CONFIG_KDP_NS=n
  277. CONFIG_KDP=n
  278. #Force Load Kernel Modules
  279. CONFIG_MODULES=y
  280. CONFIG_MODULE_FORCE_LOAD=y
  281. CONFIG_MODULE_UNLOAD=y
  282. CONFIG_MODULE_FORCE_UNLOAD=y
  283. CONFIG_MODVERSIONS=y
  284. CONFIG_MODULE_SRCVERSION_ALL=n
  285. CONFIG_MODULE_SIG=n
  286. CONFIG_MODULE_COMPRESS=n
  287. CONFIG_TRIM_UNUSED_KSYMS=n
  288. EOF
  289. elif [[ "${{ inputs.branch }}" == "SM-S926B-Oneui8" ]]; then
  290. cat >> "$COMMON/arch/arm64/configs/s5e9945-bazel_defconfig" << 'EOF'
  291. # nuke root protection
  292. CONFIG_UH=n
  293. CONFIG_UH_RKP=n
  294. CONFIG_UH_LKMAUTH=n
  295. CONFIG_UH_LKM_BLOCK=n
  296. CONFIG_RKP_CFP_JOPP=n
  297. CONFIG_RKP_CFP=n
  298. CONFIG_SECURITY_DEFEX=n
  299. CONFIG_PROCA=n
  300. CONFIG_FIVE=n
  301. CONFIG_RKP=n
  302. CONFIG_KDP_NS=n
  303. CONFIG_KDP=n
  304. EOF
  305. else
  306. cat >> "$DEFCONFIG" << 'EOF'
  307. # nuke root protection
  308. CONFIG_UH=n
  309. CONFIG_UH_RKP=n
  310. CONFIG_UH_LKMAUTH=n
  311. CONFIG_UH_LKM_BLOCK=n
  312. CONFIG_RKP_CFP_JOPP=n
  313. CONFIG_RKP_CFP=n
  314. CONFIG_SECURITY_DEFEX=n
  315. CONFIG_PROCA=n
  316. CONFIG_FIVE=n
  317. CONFIG_RKP=n
  318. CONFIG_KDP_NS=n
  319. CONFIG_KDP=n
  320. EOF
  321. fi
  322. cd "$COMMON"
  323. # Remove check_defconfig
  324. sed -i 's/check_defconfig//' ./build.config.gki
  325. - name: Change Kernel Name
  326. run: |
  327. cd "$COMMON"
  328. #Add Wild to Kernel Version
  329. sed -i '$s|echo "\$res"|echo "\$res-Wild"|' ./scripts/setlocalversion
  330. #Set Kernel Timestamp
  331. 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
  332. #Remove Abi Exports and Error
  333. rm -rf ./android/abi_gki_protected_exports_*
  334. perl -pi -e 's/^\s*"protected_exports_list"\s*:\s*"android\/abi_gki_protected_exports_aarch64",\s*$//;' ./BUILD.bazel
  335. - name: Clean Dirty Flags
  336. run: |
  337. # remove dirty
  338. sed -i 's/-dirty//' "./$COMMON/scripts/setlocalversion"
  339. - name: Set file name
  340. run: |
  341. ARTIFACT_BASE="${{ inputs.branch }}-${{ inputs.kernel_version }}-${{ inputs.android_version }}"
  342. # This gives: KSU33208-branch-xxx-xxx
  343. FILE_NAME="KSU${KSU_VERSION}-${ARTIFACT_BASE}"
  344. echo "ARTIFACT_BASE=$ARTIFACT_BASE" >> $GITHUB_ENV
  345. echo "FILE_NAME=$FILE_NAME" >> $GITHUB_ENV
  346. echo "✅ Final artifact name: $FILE_NAME"
  347. - name: Build
  348. run : |
  349. set -e
  350. set -x
  351. cd "$CONFIG"
  352. echo "Building the kernel..."
  353. if [[ "${{ inputs.branch }}" == "SM-S928B-Oneui7" || "${{ inputs.branch }}" == "SM-S928B-Oneui8-bit4" || "${{ inputs.branch }}" == "SM-S928B-Oneui6.1" || "${{ inputs.branch }}" == "SM-S938B-Oneui7" || "${{ inputs.branch }}" == "SM-S931B-Oneui8" ]]; then
  354. chmod +x build_kernel_GKI.sh
  355. ./build_kernel_GKI.sh || true
  356. 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" ]]; then
  357. chmod +x build_kernel_GKI.sh
  358. LTO=thin ./build_kernel_GKI.sh || true
  359. elif [[ "${{ inputs.branch }}" == "SM-A546B-Oneui7" || "${{ inputs.branch }}" == "SM-A546E-Oneui7" || "${{ inputs.branch }}" == "SM-M146B-Oneui7-ADYJ2" ]]; then
  360. sudo apt update
  361. sudo apt-get install -y libyaml-dev
  362. LTO=thin ./build_kernel.sh || true
  363. elif [[ "${{ inputs.branch }}" == "SM-A566B" ]]; then
  364. chmod +x build_script.sh
  365. touch ./kernel-6.6/abi_symbollist.raw
  366. touch ./kernel-6.6/abi_symbollist
  367. ./build_script.sh || true
  368. elif [[ "${{ inputs.branch }}" == "SM-S926B-Oneui8" ]]; then
  369. tools/bazel run --nocheck_bzl_visibility --config=stamp --sandbox_debug --verbose_failures --debug_make_verbosity=I //projects/s5e9945:s5e9945_user_dist
  370. else
  371. #temporarily using this until i can figure out the other phones build script issues
  372. cd kernel_platform
  373. tools/bazel build --config=fast --lto=thin //common:kernel_aarch64_dist || exit 1
  374. fi
  375. - name: Prepare AnyKernel3
  376. run: |
  377. cd "$CONFIG"
  378. # Copy Image from normal build locations
  379. #if [ -f "./$CONFIG/out/${{ inputs.android_version }}-${{ inputs.kernel_version }}/dist/Image" ]; then
  380. # cp ./$CONFIG/out/${{ inputs.android_version }}-${{ inputs.kernel_version }}/dist/Image AnyKernel3/Image
  381. #elif [ -f "./$CONFIG/bazel-bin/common/kernel_aarch64/Image" ]; then
  382. # cp ./$CONFIG/bazel-bin/common/kernel_aarch64/Image AnyKernel3/Image
  383. #else
  384. # echo "Error: Image file not found in any expected location"
  385. # exit 1
  386. #fi
  387. if [[ "${{ inputs.branch }}" == "SM-S928B-Oneui7" || "${{ inputs.branch }}" == "SM-S928B-Oneui8-bit4" ]]; then
  388. cp ./kernel_platform/sec/dist/Image "$ANYKERNEL3/Image"
  389. elif [[ "${{ inputs.branch }}" == "SM-S928B-Oneui6.1" ]]; then
  390. cp ./out/msm-pineapple-pineapple-gki/dist/Image "$ANYKERNEL3/Image"
  391. elif [[ "${{ inputs.branch }}" == "SM-S938B-Oneui7" || "${{ inputs.branch }}" == "SM-S931B-Oneui8" ]]; then
  392. cp ./kernel_platform/gki/dist/Image "$ANYKERNEL3/Image"
  393. elif [[ -f ./$CONFIG/bazel-bin/common/kernel_aarch64/Image ]]; then
  394. cp ./$CONFIG/bazel-bin/common/kernel_aarch64/Image "$ANYKERNEL3/Image"
  395. 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" ]]; then
  396. cp ./out/msm-kalama-kalama-gki/dist/Image "$ANYKERNEL3/Image"
  397. elif [[ "${{ inputs.branch }}" == "SM-A546B-Oneui7" || "${{ inputs.branch }}" == "SM-A546E-Oneui7" || "${{ inputs.branch }}" == "SM-M146B-Oneui7-ADYJ2" ]]; then
  398. cp ./arch/arm64/boot/Image "$ANYKERNEL3/Image"
  399. elif [[ "${{ inputs.branch }}" == "SM-A566B" ]]; then
  400. cp ./kernel-6.6/out/arch/arm64/boot/Image "$ANYKERNEL3/Image"
  401. elif [[ "${{ inputs.branch }}" == "SM-S926B-Oneui8" ]]; then
  402. cp ./out/s5e9945_user/dist/Image "$ANYKERNEL3/Image"
  403. elif [[ "${{ inputs.branch }}" == "SM-S901E-Oneui8" ]]; then
  404. cp ./out/msm-waipio-waipio-gki/dist/Image "$ANYKERNEL3/Image"
  405. else
  406. echo "Error: Image file not found in any expected location"
  407. exit 1
  408. fi
  409. # - name: Create Bootimgs Folder and Copy Images for Android 14/15
  410. # if: ${{ inputs.android_version == 'android14' || inputs.android_version == 'android15' }}
  411. # run: |
  412. # #mkdir bootimgs
  413. # #cp ./$CONFIG/bazel-bin/common/kernel_aarch64/Image ./bootimgs
  414. # #cp ./$CONFIG/bazel-bin/common/kernel_aarch64/Image.lz4 ./bootimgs
  415. # #cp ./$CONFIG/bazel-bin/common/kernel_aarch64/Image ./${{ env.FILE_NAME }}-Image
  416. # #cp ./$CONFIG/bazel-bin/common/kernel_aarch64/Image.lz4 ./${{ env.FILE_NAME }}-Image.lz4
  417. #
  418. # # Create gzip of the Image file
  419. # #gzip -n -k -f -9 ./${{ env.FILE_NAME }}-Image > ./${{ env.FILE_NAME }}-Image.gz
  420. # #gzip -n -k -f -9 ./bootimgs/Image > ./bootimgs/Image.gz
  421. # #cp ./boot-lz4.img ../${{ env.FILE_NAME }}-boot-lz4.img
  422. - name: Upload AnyKernel3 Artifacts
  423. id: upload_ak3
  424. uses: actions/upload-artifact@v6
  425. with:
  426. name: ${{ env.FILE_NAME }}-AnyKernel3
  427. path: |
  428. ./AnyKernel3/**
  429. compression-level: 9
  430. - name: Scan and collect patch rejects
  431. if: ${{ always() }}
  432. run: |
  433. set -e
  434. CONFIG_DIR="$CONFIG"
  435. REJECTS_DIR="$GITHUB_WORKSPACE/patch-rejects"
  436. mkdir -p "$REJECTS_DIR"
  437. # Find all .rej files under the configuration directory
  438. mapfile -t REJS < <(find "$CONFIG_DIR" -type f -name '*.rej')
  439. REJ_COUNT=${#REJS[@]}
  440. echo "Found $REJ_COUNT .rej files under $CONFIG_DIR"
  441. echo "REJ_COUNT=$REJ_COUNT" >> $GITHUB_ENV
  442. if [ "$REJ_COUNT" -gt 0 ]; then
  443. for REJ in "${REJS[@]}"; do
  444. # Relative path from $CONFIG
  445. REL="${REJ#"$CONFIG_DIR"/}"
  446. DEST="$REJECTS_DIR/$REL"
  447. mkdir -p "$(dirname "$DEST")"
  448. cp "$REJ" "$DEST"
  449. # Copy the associated original file alongside the .rej
  450. ORIG="${REJ%.rej}"
  451. if [ -f "$ORIG" ]; then
  452. ORIG_DEST="$REJECTS_DIR/${REL%.rej}"
  453. mkdir -p "$(dirname "$ORIG_DEST")"
  454. cp "$ORIG" "$ORIG_DEST"
  455. fi
  456. echo "$REL" >> "$REJECTS_DIR/index.txt"
  457. done
  458. fi
  459. - name: Generate Build Summary
  460. if: ${{ always() }}
  461. run: |
  462. # Create build summary file for inclusion in Misc artifact
  463. echo "# Kernel Build Summary" > build_summary.md
  464. # Add build variant header
  465. echo "## ${{ env.FILE_NAME }}" >> build_summary.md
  466. # Add build info
  467. echo "## Build Information" >> build_summary.md
  468. echo "- **Android Version**: ${{ inputs.android_version }}" >> build_summary.md
  469. echo "- **Kernel Version**: ${{ inputs.kernel_version }}.${{ inputs.sub_level }}" >> build_summary.md
  470. echo "- **BBG**: Installed" >> build_summary.md
  471. echo "- **Bypass Mode**: ${{ matrix.apply_bypass }}" >> build_summary.md
  472. echo "" >> build_summary.md
  473. # Get Wild_KSU commit
  474. if [ -d "$CONFIG/Wild_KSU" ]; then
  475. cd "$CONFIG/Wild_KSU"
  476. WKSU_COMMIT=$(git rev-parse HEAD)
  477. WKSU_URL="https://github.com/WildKernels/Wild_KSU/commit/$WKSU_COMMIT"
  478. echo "- **Wild_KSU**: [$WKSU_COMMIT]($WKSU_URL)" >> "$GITHUB_WORKSPACE/build_summary.md"
  479. cd "$GITHUB_WORKSPACE"
  480. else
  481. echo "- **Wild_KSU**: not present" >> build_summary.md
  482. fi
  483. # Get Baseband-guard commit
  484. if [ -d "$CONFIG/Baseband-guard" ]; then
  485. cd "$CONFIG/Baseband-guard"
  486. BBG_COMMIT=$(git rev-parse HEAD)
  487. BBG_URL="https://github.com/vc-teahouse/Baseband-guard/commit/$BBG_COMMIT"
  488. echo "- **Baseband-guard**: [$BBG_COMMIT]($BBG_URL)" >> "$GITHUB_WORKSPACE/build_summary.md"
  489. cd "$GITHUB_WORKSPACE"
  490. else
  491. echo "- **Baseband-guard**: not present" >> build_summary.md
  492. fi
  493. # Get SUSFS4KSU commit
  494. if [ -d "$GITHUB_WORKSPACE/susfs4ksu" ]; then
  495. cd "$GITHUB_WORKSPACE/susfs4ksu"
  496. SUSFS_COMMIT=$(git rev-parse HEAD)
  497. SUSFS_URL="https://gitlab.com/simonpunk/susfs4ksu/-/commit/$SUSFS_COMMIT"
  498. echo "- **SUSFS4KSU (v1.5.12)**: [$SUSFS_COMMIT]($SUSFS_URL)" >> "$GITHUB_WORKSPACE/build_summary.md"
  499. cd "$GITHUB_WORKSPACE"
  500. else
  501. echo "- **SUSFS4KSU (v1.5.12)**: not present" >> build_summary.md
  502. fi
  503. echo "" >> build_summary.md
  504. # Add artifact summary with presence verification
  505. echo "## Build Artifacts" >> build_summary.md
  506. # Verify AnyKernel3 contents - check if kernel Image was actually copied (indicates successful build)
  507. if [ -d "AnyKernel3" ] && [ -f "AnyKernel3/Image" ]; then
  508. AK3_STATUS="✅"
  509. else
  510. AK3_STATUS="❌"
  511. fi
  512. echo "- **AnyKernel3**: $AK3_STATUS ${{ env.FILE_NAME }}-AnyKernel3" >> build_summary.md
  513. echo "### Misc (uploaded files)" >> build_summary.md
  514. FILES_PRESENT=0
  515. 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
  516. if [ -f "$f" ]; then FILES_PRESENT=$((FILES_PRESENT+1)); fi
  517. done
  518. if [ "$FILES_PRESENT" -gt 0 ]; then
  519. MISC_STATUS="✅"
  520. else
  521. MISC_STATUS="❌"
  522. fi
  523. echo "- **Set**: $MISC_STATUS ${{ env.FILE_NAME }}-Misc" >> build_summary.md
  524. if [ "$MISC_STATUS" = "✅" ]; then
  525. echo " Included:" >> build_summary.md
  526. 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
  527. if [ -f "$f" ]; then
  528. echo " - $f" >> build_summary.md
  529. fi
  530. done
  531. fi
  532. echo "### Diagnostics" >> build_summary.md
  533. echo "- **Rejected Patches**: ${{ env.FILE_NAME }}-Rejected-Patches" >> build_summary.md
  534. if [ -f patch-rejects/index.txt ]; then
  535. if [ -s patch-rejects/index.txt ]; then
  536. echo " Rejected files:" >> build_summary.md
  537. while IFS= read -r line; do
  538. echo " - $line" >> build_summary.md
  539. done < patch-rejects/index.txt
  540. else
  541. echo " Rejected file list is empty." >> build_summary.md
  542. fi
  543. else
  544. echo " No rejected patches found." >> build_summary.md
  545. fi