build.yml 23 KB

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