build.yml 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492
  1. name: Kernel Build Process
  2. permissions:
  3. contents: write
  4. actions: write
  5. on:
  6. workflow_call:
  7. inputs:
  8. kernel_version:
  9. required: true
  10. type: string
  11. variant:
  12. required: false
  13. type: string
  14. ksu_commit:
  15. required: false
  16. type: string
  17. anykernel_commit:
  18. required: false
  19. type: string
  20. patches_commit:
  21. required: false
  22. type: string
  23. susfs_commit:
  24. required: false
  25. type: string
  26. feature_set:
  27. required: true
  28. type: string
  29. jobs:
  30. build-gki:
  31. name: "${{ inputs.kernel_version }}"
  32. strategy:
  33. fail-fast: false
  34. matrix:
  35. variant: ['Normal', 'Bypass']
  36. runs-on: ubuntu-latest
  37. timeout-minutes: 60
  38. steps:
  39. - name: Checkout Repository
  40. uses: actions/checkout@v4
  41. - name: Parse kernel version
  42. id: parse
  43. run: |
  44. # Parse version string.
  45. # Format: [KERNEL_VERSION].[SUBLEVEL]-[ANDROID_VERSION]-[PATCH_LEVEL]
  46. # Example 1: 5.10.198-android12-2024-01 -> K=5.10, S=198, A=android12, P=2024-01
  47. # Example 2: 5.10.X-android12-lts -> K=5.10, S=X, A=android12, P=lts
  48. INPUT_VERSION="${{ inputs.kernel_version }}"
  49. # Split by hyphens
  50. IFS='-' read -r KERNEL_PART ANDROID_PART REST <<< "$INPUT_VERSION"
  51. # Extract Kernel Version and Sublevel
  52. KERNEL_VERSION="${KERNEL_PART%.*}"
  53. SUB_LEVEL="${KERNEL_PART##*.}"
  54. # Extract Android Version
  55. ANDROID_VERSION="$ANDROID_PART"
  56. # Everything after the android version is the patch level
  57. OS_PATCH_LEVEL="$REST"
  58. echo "Parsed: KERNEL=$KERNEL_VERSION, SUB=$SUB_LEVEL, ANDROID=$ANDROID_VERSION, PATCH=$OS_PATCH_LEVEL"
  59. # Set environment variables for subsequent steps and shell scripts
  60. echo "ANDROID_VERSION=$ANDROID_VERSION" >> "$GITHUB_ENV"
  61. echo "KERNEL_VERSION=$KERNEL_VERSION" >> "$GITHUB_ENV"
  62. echo "SUB_LEVEL=$SUB_LEVEL" >> "$GITHUB_ENV"
  63. echo "OS_PATCH_LEVEL=$OS_PATCH_LEVEL" >> "$GITHUB_ENV"
  64. # Set step outputs for immediate YAML context access (avoids validation warnings)
  65. echo "android_version=$ANDROID_VERSION" >> $GITHUB_OUTPUT
  66. echo "kernel_version=$KERNEL_VERSION" >> $GITHUB_OUTPUT
  67. echo "sub_level=$SUB_LEVEL" >> $GITHUB_OUTPUT
  68. echo "os_patch_level=$OS_PATCH_LEVEL" >> $GITHUB_OUTPUT
  69. - name: Free Disk Space
  70. if: true
  71. uses: endersonmenezes/free-disk-space@v3 # Use @main for latest, @v3 for stable
  72. with:
  73. remove_android: true
  74. remove_dotnet: true
  75. remove_haskell: true
  76. remove_tool_cache: true
  77. remove_packages: "azure-cli google-cloud-cli microsoft-edge-stable google-chrome-stable firefox postgresql* temurin-* *llvm* mysql* dotnet-sdk-*"
  78. remove_packages_one_command: true
  79. 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"
  80. rm_cmd: "rmz" # Use 'rmz' for faster deletion (default: 'rm')
  81. rmz_version: "3.1.1" # Required when rm_cmd is 'rmz'
  82. testing: false
  83. - name: Setup more Swap (for LTO)
  84. uses: thejerrybao/setup-swap-space@v1 # or pierotofy/set-swap-space
  85. with:
  86. swap-size-gb: 25 # 10-24 GB is common for heavy LTO
  87. # swap-space-path: /mnt/swapfile # optional
  88. - name: Setup Build Environment
  89. run: |
  90. mkdir -p "$GITHUB_WORKSPACE/kernel"
  91. mkdir -p "$GITHUB_WORKSPACE/git-repo"
  92. curl -L https://storage.googleapis.com/git-repo-downloads/repo -o "$GITHUB_WORKSPACE/git-repo/repo"
  93. chmod +x "$GITHUB_WORKSPACE/git-repo/repo"
  94. echo "$GITHUB_WORKSPACE/git-repo" >> "$GITHUB_PATH"
  95. # Clone patches if commit is provided
  96. if [ -n "${{ inputs.patches_commit }}" ]; then
  97. echo "Cloning Kernel Patches at commit ${{ inputs.patches_commit }}"
  98. if [ -d "$GITHUB_WORKSPACE/kernel_patches" ]; then rm -rf "$GITHUB_WORKSPACE/kernel_patches"; fi
  99. git clone https://github.com/WildKernels/kernel_patches.git "$GITHUB_WORKSPACE/kernel_patches"
  100. cd "$GITHUB_WORKSPACE/kernel_patches"
  101. git checkout "${{ inputs.patches_commit }}"
  102. cd "$GITHUB_WORKSPACE"
  103. else
  104. git clone https://github.com/WildKernels/kernel_patches.git "$GITHUB_WORKSPACE/kernel_patches"
  105. fi
  106. # Use specific commit if provided
  107. if [ -n "${{ inputs.anykernel_commit }}" ]; then
  108. echo "Cloning AnyKernel3 at commit ${{ inputs.anykernel_commit }}"
  109. if [ -d "$GITHUB_WORKSPACE/AnyKernel3" ]; then rm -rf "$GITHUB_WORKSPACE/AnyKernel3"; fi
  110. git clone https://github.com/WildKernels/AnyKernel3.git "$GITHUB_WORKSPACE/AnyKernel3"
  111. cd "$GITHUB_WORKSPACE/AnyKernel3"
  112. git checkout "${{ inputs.anykernel_commit }}"
  113. cd "$GITHUB_WORKSPACE"
  114. elif [ ! -d "$GITHUB_WORKSPACE/AnyKernel3" ]; then
  115. # Fallback if not downloaded
  116. git clone https://github.com/WildKernels/AnyKernel3.git -b gki-2.0 "$GITHUB_WORKSPACE/AnyKernel3"
  117. fi
  118. AOSP_MIRROR=https://android.googlesource.com
  119. BRANCH=main-kernel-2025
  120. git clone $AOSP_MIRROR/kernel/prebuilts/build-tools -b $BRANCH --depth 1 kernel-build-tools
  121. git clone $AOSP_MIRROR/platform/system/tools/mkbootimg -b $BRANCH --depth 1 mkbootimg
  122. echo "AVBTOOL=$GITHUB_WORKSPACE/kernel-build-tools/linux-x86/bin/avbtool" >> $GITHUB_ENV
  123. echo "MKBOOTIMG=$GITHUB_WORKSPACE/mkbootimg/mkbootimg.py" >> $GITHUB_ENV
  124. echo "UNPACK_BOOTIMG=$GITHUB_WORKSPACE/mkbootimg/unpack_bootimg.py" >> $GITHUB_ENV
  125. echo "BOOT_SIGN_KEY_PATH=$GITHUB_WORKSPACE/kernel-build-tools/linux-x86/share/avb/testkey_rsa2048.pem" >> $GITHUB_ENV
  126. mkdir -p "$GITHUB_WORKSPACE/kernel-build-tools/linux-x86/share/avb"
  127. openssl genpkey -algorithm RSA -pkeyopt rsa_keygen_bits:2048 -out "$GITHUB_WORKSPACE/kernel-build-tools/linux-x86/share/avb/testkey_rsa2048.pem"
  128. chmod 600 "$GITHUB_WORKSPACE/kernel-build-tools/linux-x86/share/avb/testkey_rsa2048.pem"
  129. - name: Download Kernel Repository
  130. uses: ./.github/actions/download-kernel
  131. with:
  132. android_version: ${{ steps.parse.outputs.android_version }}
  133. kernel_version: ${{ steps.parse.outputs.kernel_version }}
  134. os_patch_level: ${{ steps.parse.outputs.os_patch_level }}
  135. - name: Extract Sublevel and Set File Name
  136. id: extract
  137. run: |
  138. SUBLEVEL="$SUB_LEVEL"
  139. if [[ -f "$GITHUB_WORKSPACE/kernel/common/Makefile" ]]; then
  140. EXTRACTED=$(grep '^SUBLEVEL = ' "$GITHUB_WORKSPACE/kernel/common/Makefile" | awk '{print $3}')
  141. [[ -n "$EXTRACTED" ]] && SUBLEVEL="$EXTRACTED"
  142. fi
  143. FILE_NAME="$KERNEL_VERSION.$SUBLEVEL-$ANDROID_VERSION-$OS_PATCH_LEVEL${{ inputs.variant && format('-{0}', inputs.variant) || '' }}"
  144. echo "SUBLEVEL=$SUBLEVEL" >> $GITHUB_ENV
  145. echo "FILE_NAME=$FILE_NAME" >> $GITHUB_ENV
  146. # Set step outputs for parse-time YAML context access
  147. echo "file_name=$FILE_NAME" >> $GITHUB_OUTPUT
  148. echo "sublevel=$SUBLEVEL" >> $GITHUB_OUTPUT
  149. - name: Apply glibc 2.38 Compatibility Fix
  150. if: true
  151. run: |
  152. # Use SUBLEVEL for LTS builds, otherwise use the input sub_level
  153. if [[ "$ANDROID_VERSION" == "android13" && "$KERNEL_VERSION" == "5.10" && $SUBLEVEL -le 186 ]] ||
  154. [[ "$ANDROID_VERSION" == "android13" && "$KERNEL_VERSION" == "5.15" && $SUBLEVEL -le 119 ]] ||
  155. [[ "$ANDROID_VERSION" == "android14" && "$KERNEL_VERSION" == "5.15" && $SUBLEVEL -le 110 ]] ||
  156. [[ "$ANDROID_VERSION" == "android14" && "$KERNEL_VERSION" == "6.1" && $SUBLEVEL -le 43 ]]; then
  157. GLIBC_VERSION=$(ldd --version 2>/dev/null | head -n 1 | awk '{print $NF}')
  158. if [ "$(printf '%s\n' "2.38" "$GLIBC_VERSION" | sort -V | head -n1)" = "2.38" ]; then
  159. cd "$GITHUB_WORKSPACE/kernel/common"
  160. sed -i '/\$(Q)\$(MAKE) -C \$(SUBCMD_SRC) OUTPUT=\$(abspath \$(dir \$@))\/ \$(abspath \$@)/s//$(Q)$(MAKE) -C $(SUBCMD_SRC) EXTRA_CFLAGS="$(CFLAGS)" OUTPUT=$(abspath $(dir $@))\/ $(abspath $@)/' tools/bpf/resolve_btfids/Makefile 2>/dev/null || true
  161. if [[ "$ANDROID_VERSION" == "android13" && "$KERNEL_VERSION" == "5.10" && $SUBLEVEL -le 186 ]] ||
  162. [[ "$ANDROID_VERSION" == "android13" && "$KERNEL_VERSION" == "5.15" && $SUBLEVEL -le 119 ]] ||
  163. [[ "$ANDROID_VERSION" == "android14" && "$KERNEL_VERSION" == "5.15" && $SUBLEVEL -le 110 ]]; then
  164. sed -i '/char \*buf = NULL;/a int i;' tools/lib/subcmd/parse-options.c 2>/dev/null || true
  165. sed -i 's/for (int i = 0; subcommands\[i\]; i++) {/for (i = 0; subcommands[i]; i++) {/' tools/lib/subcmd/parse-options.c 2>/dev/null || true
  166. sed -i '/if (subcommands) {/a int i;' tools/lib/subcmd/parse-options.c 2>/dev/null || true
  167. sed -i 's/for (int i = 0; subcommands\[i\]; i++)/for (i = 0; subcommands[i]; i++)/' tools/lib/subcmd/parse-options.c 2>/dev/null || true
  168. fi
  169. fi
  170. fi
  171. - name: Fix Less Than 6.6.50 Builds
  172. if: ${{ steps.parse.outputs.android_version == 'android15' && steps.parse.outputs.kernel_version == '6.6'}}
  173. working-directory: ${{ github.workspace }}/kernel/common
  174. run: |
  175. if ! grep -qxF '#include <trace/hooks/fs.h>' ./fs/namespace.c; then
  176. sed -i '/#include <trace\/hooks\/blk.h>/a #include <trace\/hooks\/fs.h>' ./fs/namespace.c
  177. fi
  178. - name: Setup Wild KSU
  179. if: contains(inputs.feature_set, 'WKSU')
  180. uses: ./.github/actions/wksu
  181. with:
  182. ksu_commit: ${{ inputs.ksu_commit }}
  183. - name: Setup SUSFS
  184. if: contains(inputs.feature_set, 'SUSFS')
  185. uses: ./.github/actions/susfs
  186. with:
  187. android_version: ${{ steps.parse.outputs.android_version }}
  188. kernel_version: ${{ steps.parse.outputs.kernel_version }}
  189. os_patch_level: ${{ steps.parse.outputs.os_patch_level }}
  190. sublevel: ${{ steps.extract.outputs.sublevel }}
  191. susfs_commit: ${{ inputs.susfs_commit }}
  192. - name: Setup SUSFS Patches
  193. if: contains(inputs.feature_set, 'SUSFS')
  194. uses: ./.github/actions/susfs-patches
  195. with:
  196. android_version: ${{ steps.parse.outputs.android_version }}
  197. kernel_version: ${{ steps.parse.outputs.kernel_version }}
  198. os_patch_level: ${{ steps.parse.outputs.os_patch_level }}
  199. sublevel: ${{ steps.extract.outputs.sublevel }}
  200. - name: Setup Baseband Guard
  201. if: contains(inputs.feature_set, 'BBG')
  202. uses: ./.github/actions/bbg
  203. - name: Apply Module Check Bypass
  204. if: ${{ inputs.variant == 'Bypass' }}
  205. run: |
  206. if [[ "$KERNEL_VERSION" == "6.1" || "$KERNEL_VERSION" == "6.6" || "$KERNEL_VERSION" == "6.12" ]]; then
  207. TARGET_FILE="$GITHUB_WORKSPACE/kernel/common/kernel/module/version.c"
  208. else
  209. TARGET_FILE="$GITHUB_WORKSPACE/kernel/common/kernel/module.c"
  210. fi
  211. # Apply bypass patch to the target file
  212. sed -i '/bad_version:/{:a;n;/return 0;/{s/return 0;/return 1;/;b};ba}' "$TARGET_FILE"
  213. # Verify the bypass
  214. if grep -A 5 "bad_version:" "$TARGET_FILE" | grep -q "return 1;"; then
  215. echo "SUCCESS: Module check bypass verified in $TARGET_FILE"
  216. else
  217. echo "FAILED: Module check bypass not found in $TARGET_FILE"
  218. grep -A 5 "bad_version:" "$TARGET_FILE" || true
  219. exit 1
  220. fi
  221. - name: Apply Device-Specific Patches
  222. uses: ./.github/actions/apply-device-patches
  223. with:
  224. kernel_version: ${{ steps.parse.outputs.kernel_version }}
  225. - name: Configure Kernel Options
  226. uses: ./.github/actions/configure-kernel
  227. with:
  228. kernel_version: ${{ steps.parse.outputs.kernel_version }}
  229. - name: Apply ABI Compare Bypass
  230. if: false
  231. working-directory: ${{ github.workspace }}/kernel
  232. run: |
  233. # ABI compare bypass per kernel/android version
  234. # Edit each block as needed per version
  235. if [[ "$ANDROID_VERSION" == "android12" && "$KERNEL_VERSION" == "5.10" ]]; then
  236. sed -i 's/^\s*exit 1$/ echo "Who Cares? Bypassing Now!"/' build/abi/compare_to_symbol_list
  237. elif [[ "$ANDROID_VERSION" == "android13" && "$KERNEL_VERSION" == "5.10" ]]; then
  238. sed -i 's/^\s*exit 1$/ echo "Who Cares? Bypassing Now!"/' build/kernel/abi/compare_to_symbol_list
  239. elif [[ "$ANDROID_VERSION" == "android13" && "$KERNEL_VERSION" == "5.15" ]]; then
  240. sed -i 's/^\s*exit 1$/ echo "Who Cares? Bypassing Now!"/' build/kernel/abi/compare_to_symbol_list
  241. elif [[ "$ANDROID_VERSION" == "android14" && "$KERNEL_VERSION" == "5.15" ]]; then
  242. perl -i -pe 's/^(\s*)return 1$/$1print("Who Cares? Bypassing Now!")\n$1return 0/g if /if missing_symbols:/../return 1/' build/kernel/abi/check_buildtime_symbol_protection.py
  243. elif [[ "$ANDROID_VERSION" == "android14" && "$KERNEL_VERSION" == "6.1" ]]; then
  244. perl -i -pe 's/^(\s*)return 1$/$1print("Who Cares? Bypassing Now!")\n$1return 0/g if /if missing_symbols:/../return 1/' build/kernel/abi/check_buildtime_symbol_protection.py
  245. elif [[ "$ANDROID_VERSION" == "android15" && "$KERNEL_VERSION" == "6.6" ]]; then
  246. perl -i -pe 's/^(\s*)return 1$/$1print("Who Cares? Bypassing Now!")\n$1return 0/g if /if missing_symbols:/../return 1/' build/kernel/abi/check_buildtime_symbol_protection.py
  247. fi
  248. - name: Apply Kernel Branding
  249. uses: ./.github/actions/apply-kernel-branding
  250. with:
  251. build_type: ${{ inputs.variant || 'Normal' }}
  252. kernel_version: ${{ steps.parse.outputs.kernel_version }}
  253. - name: Remove Protected Exports
  254. working-directory: ${{ github.workspace }}/kernel
  255. run: |
  256. set -ex
  257. if [ ! -f "build/build.sh" ]; then
  258. # Bazel build system (newer kernels)
  259. # Remove ABI protected exports to prevent build errors
  260. rm -rf common/android/abi_gki_protected_exports_*
  261. perl -pi -e 's/^\s*"protected_exports_list"\s*:\s*"android\/abi_gki_protected_exports_aarch64",\s*$//;' common/BUILD.bazel
  262. sed -i 's/protected_modules = \[.*\]/protected_modules = []/' common/modules.bzl || true
  263. fi
  264. - name: Clean Kernel Flags
  265. uses: ./.github/actions/clean-kernel-flags
  266. - name: Build Kernel
  267. working-directory: ${{ github.workspace }}/kernel
  268. env:
  269. SOURCE_DATE_EPOCH: ${{ env.SOURCE_DATE_EPOCH }}
  270. KBUILD_BUILD_TIMESTAMP: ${{ env.KBUILD_BUILD_TIMESTAMP }}
  271. run: |
  272. set -ex
  273. if [ -f "build/build.sh" ]; then
  274. #SKIP_MRPROPER=1
  275. GKI_DEFCONFIG_FRAGMENT="$GITHUB_WORKSPACE/wild_gki.fragment" BUILD_CONFIG=common/build.config.gki.aarch64 build/build.sh || exit 1
  276. else
  277. # Copy fragment to kernel tree for bazel
  278. cp "$GITHUB_WORKSPACE/wild_gki.fragment" common/arch/arm64/configs/wild_gki.fragment
  279. tools/bazel build --config=release --stamp --defconfig_fragment=//common:arch/arm64/configs/wild_gki.fragment //common:kernel_aarch64_dist || exit 1
  280. fi
  281. fi
  282. - name: Create Bootimgs Folder and Build Boot Images
  283. working-directory: ${{ github.workspace }}
  284. run: |
  285. set -e
  286. mkdir -p bootimgs
  287. mkdir -p boot-artifacts
  288. echo "Creating bootimgs folder and copying images..."
  289. if [ -f "$GITHUB_WORKSPACE/kernel/out/$ANDROID_VERSION-$KERNEL_VERSION/dist/Image" ]; then
  290. cp "$GITHUB_WORKSPACE/kernel/out/$ANDROID_VERSION-$KERNEL_VERSION/dist/Image" "$GITHUB_WORKSPACE/bootimgs/Image"
  291. cp "$GITHUB_WORKSPACE/kernel/out/$ANDROID_VERSION-$KERNEL_VERSION/dist/Image.lz4" "$GITHUB_WORKSPACE/bootimgs/Image.lz4"
  292. else
  293. cp "$GITHUB_WORKSPACE/kernel/bazel-bin/common/kernel_aarch64/Image" "$GITHUB_WORKSPACE/bootimgs/Image"
  294. cp "$GITHUB_WORKSPACE/kernel/bazel-bin/common/kernel_aarch64/Image.lz4" "$GITHUB_WORKSPACE/bootimgs/Image.lz4"
  295. fi
  296. gzip -n -k -f -9 "$GITHUB_WORKSPACE/bootimgs/Image" > "$GITHUB_WORKSPACE/bootimgs/Image.gz"
  297. cd "$GITHUB_WORKSPACE/bootimgs"
  298. case "$ANDROID_VERSION" in
  299. android12)
  300. echo "Android 12: downloading certified boot image to extract ramdisk..."
  301. GKI_URL="https://dl.google.com/android/gki/gki-certified-boot-android12-5.10-${OS_PATCH_LEVEL}_r1.zip"
  302. FALLBACK_URL="https://dl.google.com/android/gki/gki-certified-boot-android12-5.10-2023-01_r1.zip"
  303. echo "Checking if GKI kernel URL is reachable: $GKI_URL"
  304. status="$(curl -sL -w "%{http_code}" "$GKI_URL" -o /dev/null || true)"
  305. if [ "$status" = "200" ]; then
  306. echo "Downloading from GKI_URL"
  307. curl -L -o gki-kernel.zip "$GKI_URL"
  308. else
  309. echo "$GKI_URL not found (HTTP $status), using $FALLBACK_URL"
  310. curl -L -o gki-kernel.zip "$FALLBACK_URL"
  311. fi
  312. echo "Unzipping the downloaded kernel..."
  313. unzip -q gki-kernel.zip
  314. rm -f gki-kernel.zip
  315. echo "Unpacking boot image to extract ramdisk..."
  316. if [ -f "./boot-5.10.img" ]; then
  317. BOOT_IMG="./boot-5.10.img"
  318. else
  319. BOOT_IMG="$(ls -1 ./boot-*.img 2>/dev/null | head -n 1 || true)"
  320. fi
  321. if [ -z "${BOOT_IMG:-}" ]; then
  322. echo "Error: could not find extracted boot-*.img in $PWD"
  323. ls -la
  324. exit 1
  325. fi
  326. "$UNPACK_BOOTIMG" --boot_img="$PWD/$BOOT_IMG"
  327. ;;
  328. esac
  329. for kernel_image in Image Image.gz Image.lz4; do
  330. case "$kernel_image" in
  331. Image) output_image="boot.img" ;;
  332. Image.gz) output_image="boot-gz.img" ;;
  333. Image.lz4) output_image="boot-lz4.img" ;;
  334. esac
  335. echo "Building $output_image"
  336. if [ "$ANDROID_VERSION" = "android12" ]; then
  337. "$MKBOOTIMG" --header_version 4 --kernel "$kernel_image" --output "$output_image" --ramdisk out/ramdisk --os_version 12.0.0 --os_patch_level "$OS_PATCH_LEVEL"
  338. else
  339. "$MKBOOTIMG" --header_version 4 --kernel "$kernel_image" --output "$output_image"
  340. fi
  341. "$AVBTOOL" add_hash_footer --partition_name boot --partition_size $((64 * 1024 * 1024)) --image "$output_image" --algorithm SHA256_RSA2048 --key "$BOOT_SIGN_KEY_PATH"
  342. cp "$output_image" "$GITHUB_WORKSPACE/boot-artifacts/${FILE_NAME}-${output_image}"
  343. done
  344. - name: Upload Boot Images
  345. uses: actions/upload-artifact@v4
  346. with:
  347. name: ${{ steps.extract.outputs.file_name }}-BootImages
  348. path: ${{ github.workspace }}/boot-artifacts/*.img
  349. if-no-files-found: error
  350. compression-level: 0
  351. - name: Prepare AnyKernel3 Zip
  352. run: |
  353. # Copy Image from normal build locations
  354. if [ -f "$GITHUB_WORKSPACE/kernel/out/$ANDROID_VERSION-$KERNEL_VERSION/dist/Image" ]; then
  355. cp "$GITHUB_WORKSPACE/kernel/out/$ANDROID_VERSION-$KERNEL_VERSION/dist/Image" "$GITHUB_WORKSPACE/AnyKernel3/Image"
  356. elif [ -f "$GITHUB_WORKSPACE/kernel/bazel-bin/common/kernel_aarch64/Image" ]; then
  357. cp "$GITHUB_WORKSPACE/kernel/bazel-bin/common/kernel_aarch64/Image" "$GITHUB_WORKSPACE/AnyKernel3/Image"
  358. else
  359. echo "Error: Image file not found in any expected location"
  360. exit 1
  361. fi
  362. - name: Scan and collect patch rejects
  363. id: scan
  364. if: ${{ always() }}
  365. run: |
  366. set -e
  367. CONFIG_DIR="$GITHUB_WORKSPACE/kernel"
  368. REJECTS_DIR="$GITHUB_WORKSPACE/patch-rejects"
  369. mkdir -p "$REJECTS_DIR"
  370. # Find all .rej files under the configuration directory
  371. mapfile -t REJS < <(find "$CONFIG_DIR" -type f -name '*.rej')
  372. REJ_COUNT=${#REJS[@]}
  373. echo "Found $REJ_COUNT .rej files under $CONFIG_DIR"
  374. echo "REJ_COUNT=$REJ_COUNT" >> $GITHUB_ENV
  375. echo "rej_count=$REJ_COUNT" >> $GITHUB_OUTPUT
  376. if [ "$REJ_COUNT" -gt 0 ]; then
  377. for REJ in "${REJS[@]}"; do
  378. # Relative path from $CONFIG
  379. REL="${REJ#"$CONFIG_DIR"/}"
  380. DEST="$REJECTS_DIR/$REL"
  381. mkdir -p "$(dirname "$DEST")"
  382. cp "$REJ" "$DEST"
  383. # Copy the associated original file alongside the .rej
  384. ORIG="${REJ%.rej}"
  385. if [ -f "$ORIG" ]; then
  386. ORIG_DEST="$REJECTS_DIR/${REL%.rej}"
  387. mkdir -p "$(dirname "$ORIG_DEST")"
  388. cp "$ORIG" "$ORIG_DEST"
  389. fi
  390. echo "$REL" >> "$REJECTS_DIR/index.txt"
  391. done
  392. fi
  393. - name: Upload Artifacts
  394. uses: actions/upload-artifact@v4
  395. with:
  396. name: ${{ steps.extract.outputs.file_name }}-AnyKernel3
  397. path: ${{ github.workspace }}/AnyKernel3/**
  398. if-no-files-found: ignore
  399. compression-level: 9
  400. - name: Upload Rejects
  401. if: ${{ always() && inputs.variant != 'Bypass' && steps.scan.outputs.rej_count > 0 }}
  402. uses: actions/upload-artifact@v4
  403. with:
  404. name: ${{ steps.extract.outputs.file_name }}-Rejects
  405. path: patch-rejects/
  406. if-no-files-found: ignore
  407. compression-level: 9
  408. - name: Build Summary
  409. if: ${{ always() }}
  410. run: |
  411. # Kernel info
  412. echo "Android Version : $ANDROID_VERSION"
  413. echo "Kernel Version : $KERNEL_VERSION"
  414. echo "Sub Level : $SUB_LEVEL"
  415. echo "Sub level (Makefile): $SUBLEVEL"
  416. echo "Patch Level : $OS_PATCH_LEVEL"
  417. # Branch info
  418. echo "Repo Branch : common-$KERNEL_VERSION-$ANDROID_VERSION-$OS_PATCH_LEVEL || 'normal'"
  419. echo "Deprecated : $DEPRECATED_BRANCH"
  420. # Build info
  421. echo "Build Type : ${{ inputs.variant || 'Normal' }}"
  422. # Features info
  423. echo "Features : ${{ inputs.feature_set || 'None' }}"
  424. echo "WKSU Commit : ${{ inputs.ksu_commit || 'canary' }}"
  425. echo "WKSU Tag : $KSU_GIT_TAG"
  426. echo "WKSU Version : $KSU_VERSION"
  427. echo "BBG Commit : $BBG_COMMIT"
  428. echo "BBG Version : $BBG_VERSION"
  429. # Variant info
  430. echo "Variant : ${{ inputs.variant || 'Standard' }}"
  431. echo "Features : ${{ inputs.feature_set || 'None' }}"
  432. # End of workflow