build.yml 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498
  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 }} (${{ matrix.variant }})"
  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@v5
  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. VARIANT="${{ matrix.variant }}"
  144. FILE_NAME="$KERNEL_VERSION.$SUBLEVEL-$ANDROID_VERSION-$OS_PATCH_LEVEL-$VARIANT"
  145. echo "SUBLEVEL=$SUBLEVEL" >> $GITHUB_ENV
  146. echo "FILE_NAME=$FILE_NAME" >> $GITHUB_ENV
  147. # Set step outputs for parse-time YAML context access
  148. echo "file_name=$FILE_NAME" >> $GITHUB_OUTPUT
  149. echo "sublevel=$SUBLEVEL" >> $GITHUB_OUTPUT
  150. - name: Apply glibc 2.38 Compatibility Fix
  151. if: true
  152. run: |
  153. # Use SUBLEVEL for LTS builds, otherwise use the input sub_level
  154. if [[ "$ANDROID_VERSION" == "android13" && "$KERNEL_VERSION" == "5.10" && $SUBLEVEL -le 186 ]] ||
  155. [[ "$ANDROID_VERSION" == "android13" && "$KERNEL_VERSION" == "5.15" && $SUBLEVEL -le 119 ]] ||
  156. [[ "$ANDROID_VERSION" == "android14" && "$KERNEL_VERSION" == "5.15" && $SUBLEVEL -le 110 ]] ||
  157. [[ "$ANDROID_VERSION" == "android14" && "$KERNEL_VERSION" == "6.1" && $SUBLEVEL -le 43 ]]; then
  158. GLIBC_VERSION=$(ldd --version 2>/dev/null | head -n 1 | awk '{print $NF}')
  159. if [ "$(printf '%s\n' "2.38" "$GLIBC_VERSION" | sort -V | head -n1)" = "2.38" ]; then
  160. cd "$GITHUB_WORKSPACE/kernel/common"
  161. 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
  162. if [[ "$ANDROID_VERSION" == "android13" && "$KERNEL_VERSION" == "5.10" && $SUBLEVEL -le 186 ]] ||
  163. [[ "$ANDROID_VERSION" == "android13" && "$KERNEL_VERSION" == "5.15" && $SUBLEVEL -le 119 ]] ||
  164. [[ "$ANDROID_VERSION" == "android14" && "$KERNEL_VERSION" == "5.15" && $SUBLEVEL -le 110 ]]; then
  165. sed -i '/char \*buf = NULL;/a int i;' tools/lib/subcmd/parse-options.c 2>/dev/null || true
  166. 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
  167. sed -i '/if (subcommands) {/a int i;' tools/lib/subcmd/parse-options.c 2>/dev/null || true
  168. 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
  169. fi
  170. fi
  171. fi
  172. - name: Fix Less Than 6.6.50 Builds
  173. if: ${{ steps.parse.outputs.android_version == 'android15' && steps.parse.outputs.kernel_version == '6.6'}}
  174. working-directory: ${{ github.workspace }}/kernel/common
  175. run: |
  176. if ! grep -qxF '#include <trace/hooks/fs.h>' ./fs/namespace.c; then
  177. sed -i '/#include <trace\/hooks\/blk.h>/a #include <trace\/hooks\/fs.h>' ./fs/namespace.c
  178. fi
  179. - name: Setup KernelSU-Next
  180. if: contains(inputs.feature_set, 'KSUN')
  181. uses: ./.github/actions/kernelsu
  182. with:
  183. ksu_commit: ${{ inputs.ksu_commit }}
  184. - name: Setup SUSFS
  185. if: contains(inputs.feature_set, 'SUSFS')
  186. uses: ./.github/actions/susfs
  187. with:
  188. android_version: ${{ steps.parse.outputs.android_version }}
  189. kernel_version: ${{ steps.parse.outputs.kernel_version }}
  190. os_patch_level: ${{ steps.parse.outputs.os_patch_level }}
  191. sublevel: ${{ steps.extract.outputs.sublevel }}
  192. susfs_commit: ${{ inputs.susfs_commit }}
  193. - name: Setup SUSFS Patches
  194. if: contains(inputs.feature_set, 'SUSFS')
  195. uses: ./.github/actions/susfs-patches
  196. with:
  197. android_version: ${{ steps.parse.outputs.android_version }}
  198. kernel_version: ${{ steps.parse.outputs.kernel_version }}
  199. os_patch_level: ${{ steps.parse.outputs.os_patch_level }}
  200. sublevel: ${{ steps.extract.outputs.sublevel }}
  201. - name: Setup Baseband Guard
  202. if: contains(inputs.feature_set, 'BBG')
  203. uses: ./.github/actions/bbg
  204. - name: Apply Module Check Bypass
  205. if: ${{ matrix.variant == 'Bypass' }}
  206. run: |
  207. if [[ "$KERNEL_VERSION" == "6.1" || "$KERNEL_VERSION" == "6.6" || "$KERNEL_VERSION" == "6.12" ]]; then
  208. TARGET_FILE="$GITHUB_WORKSPACE/kernel/common/kernel/module/version.c"
  209. else
  210. TARGET_FILE="$GITHUB_WORKSPACE/kernel/common/kernel/module.c"
  211. fi
  212. # Apply bypass patch to the target file
  213. sed -i '/bad_version:/{:a;n;/return 0;/{s/return 0;/return 1;/;b};ba}' "$TARGET_FILE"
  214. # Verify the bypass
  215. if grep -A 5 "bad_version:" "$TARGET_FILE" | grep -q "return 1;"; then
  216. echo "SUCCESS: Module check bypass verified in $TARGET_FILE"
  217. else
  218. echo "FAILED: Module check bypass not found in $TARGET_FILE"
  219. grep -A 5 "bad_version:" "$TARGET_FILE" || true
  220. exit 1
  221. fi
  222. - name: Apply Device-Specific Patches
  223. uses: ./.github/actions/apply-device-patches
  224. with:
  225. kernel_version: ${{ steps.parse.outputs.kernel_version }}
  226. - name: Setup netfilter/ipset options
  227. uses: ./.github/actions/netfilter-ipset
  228. with:
  229. kernel_version: ${{ steps.parse.outputs.kernel_version }}
  230. - name: Setup BBRv3
  231. uses: ./.github/actions/bbr
  232. with:
  233. kernel_version: ${{ steps.parse.outputs.kernel_version }}
  234. - name: Apply ABI Compare Bypass
  235. if: false
  236. working-directory: ${{ github.workspace }}/kernel
  237. run: |
  238. # ABI compare bypass per kernel/android version
  239. # Edit each block as needed per version
  240. if [[ "$ANDROID_VERSION" == "android12" && "$KERNEL_VERSION" == "5.10" ]]; then
  241. sed -i 's/^\s*exit 1$/ echo "Who Cares? Bypassing Now!"/' build/abi/compare_to_symbol_list
  242. elif [[ "$ANDROID_VERSION" == "android13" && "$KERNEL_VERSION" == "5.10" ]]; then
  243. sed -i 's/^\s*exit 1$/ echo "Who Cares? Bypassing Now!"/' build/kernel/abi/compare_to_symbol_list
  244. elif [[ "$ANDROID_VERSION" == "android13" && "$KERNEL_VERSION" == "5.15" ]]; then
  245. sed -i 's/^\s*exit 1$/ echo "Who Cares? Bypassing Now!"/' build/kernel/abi/compare_to_symbol_list
  246. elif [[ "$ANDROID_VERSION" == "android14" && "$KERNEL_VERSION" == "5.15" ]]; then
  247. 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
  248. elif [[ "$ANDROID_VERSION" == "android14" && "$KERNEL_VERSION" == "6.1" ]]; then
  249. 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
  250. elif [[ "$ANDROID_VERSION" == "android15" && "$KERNEL_VERSION" == "6.6" ]]; then
  251. 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
  252. fi
  253. - name: Apply Kernel Branding
  254. uses: ./.github/actions/apply-kernel-branding
  255. with:
  256. build_type: ${{ matrix.variant }}
  257. kernel_version: ${{ steps.parse.outputs.kernel_version }}
  258. - name: Remove Protected Exports
  259. working-directory: ${{ github.workspace }}/kernel
  260. run: |
  261. set -ex
  262. if [ ! -f "build/build.sh" ]; then
  263. # Bazel build system (newer kernels)
  264. # Remove ABI protected exports to prevent build errors
  265. rm -rf common/android/abi_gki_protected_exports_*
  266. perl -pi -e 's/^\s*"protected_exports_list"\s*:\s*"android\/abi_gki_protected_exports_aarch64",\s*$//;' common/BUILD.bazel
  267. sed -i 's/protected_modules = \[.*\]/protected_modules = []/' common/modules.bzl || true
  268. fi
  269. - name: Clean Kernel Flags
  270. uses: ./.github/actions/clean-kernel-flags
  271. - name: Build Kernel
  272. working-directory: ${{ github.workspace }}/kernel
  273. env:
  274. SOURCE_DATE_EPOCH: ${{ env.SOURCE_DATE_EPOCH }}
  275. KBUILD_BUILD_TIMESTAMP: ${{ env.KBUILD_BUILD_TIMESTAMP }}
  276. run: |
  277. set -ex
  278. if [ -f "build/build.sh" ]; then
  279. #SKIP_MRPROPER=1
  280. GKI_DEFCONFIG_FRAGMENT="$GITHUB_WORKSPACE/wild_gki.fragment" BUILD_CONFIG=common/build.config.gki.aarch64 build/build.sh || exit 1
  281. else
  282. # Copy fragment to kernel tree for bazel
  283. cp "$GITHUB_WORKSPACE/wild_gki.fragment" common/arch/arm64/configs/wild_gki.fragment
  284. tools/bazel build --config=release --stamp --defconfig_fragment=//common:arch/arm64/configs/wild_gki.fragment //common:kernel_aarch64_dist || exit 1
  285. fi
  286. fi
  287. - name: Create Bootimgs Folder and Build Boot Images
  288. working-directory: ${{ github.workspace }}
  289. run: |
  290. set -e
  291. mkdir -p bootimgs
  292. mkdir -p boot-artifacts
  293. echo "Creating bootimgs folder and copying images..."
  294. if [ -f "$GITHUB_WORKSPACE/kernel/out/$ANDROID_VERSION-$KERNEL_VERSION/dist/Image" ]; then
  295. cp "$GITHUB_WORKSPACE/kernel/out/$ANDROID_VERSION-$KERNEL_VERSION/dist/Image" "$GITHUB_WORKSPACE/bootimgs/Image"
  296. cp "$GITHUB_WORKSPACE/kernel/out/$ANDROID_VERSION-$KERNEL_VERSION/dist/Image.lz4" "$GITHUB_WORKSPACE/bootimgs/Image.lz4"
  297. else
  298. cp "$GITHUB_WORKSPACE/kernel/bazel-bin/common/kernel_aarch64/Image" "$GITHUB_WORKSPACE/bootimgs/Image"
  299. cp "$GITHUB_WORKSPACE/kernel/bazel-bin/common/kernel_aarch64/Image.lz4" "$GITHUB_WORKSPACE/bootimgs/Image.lz4"
  300. fi
  301. gzip -n -k -f -9 "$GITHUB_WORKSPACE/bootimgs/Image" > "$GITHUB_WORKSPACE/bootimgs/Image.gz"
  302. cd "$GITHUB_WORKSPACE/bootimgs"
  303. case "$ANDROID_VERSION" in
  304. android12)
  305. echo "Android 12: downloading certified boot image to extract ramdisk..."
  306. GKI_URL="https://dl.google.com/android/gki/gki-certified-boot-android12-5.10-${OS_PATCH_LEVEL}_r1.zip"
  307. FALLBACK_URL="https://dl.google.com/android/gki/gki-certified-boot-android12-5.10-2023-01_r1.zip"
  308. echo "Checking if GKI kernel URL is reachable: $GKI_URL"
  309. status="$(curl -sL -w "%{http_code}" "$GKI_URL" -o /dev/null || true)"
  310. if [ "$status" = "200" ]; then
  311. echo "Downloading from GKI_URL"
  312. curl -L -o gki-kernel.zip "$GKI_URL"
  313. else
  314. echo "$GKI_URL not found (HTTP $status), using $FALLBACK_URL"
  315. curl -L -o gki-kernel.zip "$FALLBACK_URL"
  316. fi
  317. echo "Unzipping the downloaded kernel..."
  318. unzip -q gki-kernel.zip
  319. rm -f gki-kernel.zip
  320. echo "Unpacking boot image to extract ramdisk..."
  321. if [ -f "./boot-5.10.img" ]; then
  322. BOOT_IMG="./boot-5.10.img"
  323. else
  324. BOOT_IMG="$(ls -1 ./boot-*.img 2>/dev/null | head -n 1 || true)"
  325. fi
  326. if [ -z "${BOOT_IMG:-}" ]; then
  327. echo "Error: could not find extracted boot-*.img in $PWD"
  328. ls -la
  329. exit 1
  330. fi
  331. "$UNPACK_BOOTIMG" --boot_img="$PWD/$BOOT_IMG"
  332. ;;
  333. esac
  334. for kernel_image in Image Image.gz Image.lz4; do
  335. case "$kernel_image" in
  336. Image) output_image="boot.img" ;;
  337. Image.gz) output_image="boot-gz.img" ;;
  338. Image.lz4) output_image="boot-lz4.img" ;;
  339. esac
  340. echo "Building $output_image"
  341. if [ "$ANDROID_VERSION" = "android12" ]; then
  342. "$MKBOOTIMG" --header_version 4 --kernel "$kernel_image" --output "$output_image" --ramdisk out/ramdisk --os_version 12.0.0 --os_patch_level "$OS_PATCH_LEVEL"
  343. else
  344. "$MKBOOTIMG" --header_version 4 --kernel "$kernel_image" --output "$output_image"
  345. fi
  346. "$AVBTOOL" add_hash_footer --partition_name boot --partition_size $((64 * 1024 * 1024)) --image "$output_image" --algorithm SHA256_RSA2048 --key "$BOOT_SIGN_KEY_PATH"
  347. cp "$output_image" "$GITHUB_WORKSPACE/boot-artifacts/${FILE_NAME}-${output_image}"
  348. done
  349. - name: Upload Boot Images
  350. uses: actions/upload-artifact@v4
  351. with:
  352. name: ${{ steps.extract.outputs.file_name }}-BootImages
  353. path: ${{ github.workspace }}/boot-artifacts/*.img
  354. if-no-files-found: error
  355. compression-level: 0
  356. - name: Prepare AnyKernel3 Zip
  357. run: |
  358. # Copy Image from normal build locations
  359. if [ -f "$GITHUB_WORKSPACE/kernel/out/$ANDROID_VERSION-$KERNEL_VERSION/dist/Image" ]; then
  360. cp "$GITHUB_WORKSPACE/kernel/out/$ANDROID_VERSION-$KERNEL_VERSION/dist/Image" "$GITHUB_WORKSPACE/AnyKernel3/Image"
  361. elif [ -f "$GITHUB_WORKSPACE/kernel/bazel-bin/common/kernel_aarch64/Image" ]; then
  362. cp "$GITHUB_WORKSPACE/kernel/bazel-bin/common/kernel_aarch64/Image" "$GITHUB_WORKSPACE/AnyKernel3/Image"
  363. else
  364. echo "Error: Image file not found in any expected location"
  365. exit 1
  366. fi
  367. - name: Scan and collect patch rejects
  368. id: scan
  369. if: ${{ always() }}
  370. run: |
  371. set -e
  372. CONFIG_DIR="$GITHUB_WORKSPACE/kernel"
  373. REJECTS_DIR="$GITHUB_WORKSPACE/patch-rejects"
  374. mkdir -p "$REJECTS_DIR"
  375. # Find all .rej files under the configuration directory
  376. mapfile -t REJS < <(find "$CONFIG_DIR" -type f -name '*.rej')
  377. REJ_COUNT=${#REJS[@]}
  378. echo "Found $REJ_COUNT .rej files under $CONFIG_DIR"
  379. echo "REJ_COUNT=$REJ_COUNT" >> $GITHUB_ENV
  380. echo "rej_count=$REJ_COUNT" >> $GITHUB_OUTPUT
  381. if [ "$REJ_COUNT" -gt 0 ]; then
  382. for REJ in "${REJS[@]}"; do
  383. # Relative path from $CONFIG
  384. REL="${REJ#"$CONFIG_DIR"/}"
  385. DEST="$REJECTS_DIR/$REL"
  386. mkdir -p "$(dirname "$DEST")"
  387. cp "$REJ" "$DEST"
  388. # Copy the associated original file alongside the .rej
  389. ORIG="${REJ%.rej}"
  390. if [ -f "$ORIG" ]; then
  391. ORIG_DEST="$REJECTS_DIR/${REL%.rej}"
  392. mkdir -p "$(dirname "$ORIG_DEST")"
  393. cp "$ORIG" "$ORIG_DEST"
  394. fi
  395. echo "$REL" >> "$REJECTS_DIR/index.txt"
  396. done
  397. fi
  398. - name: Upload Artifacts
  399. uses: actions/upload-artifact@v4
  400. with:
  401. name: ${{ steps.extract.outputs.file_name }}-AnyKernel3
  402. path: ${{ github.workspace }}/AnyKernel3/**
  403. if-no-files-found: ignore
  404. compression-level: 9
  405. - name: Upload Rejects
  406. if: ${{ always() }}
  407. uses: actions/upload-artifact@v4
  408. with:
  409. name: ${{ steps.extract.outputs.file_name }}-Rejects
  410. path: patch-rejects/
  411. if-no-files-found: ignore
  412. compression-level: 9
  413. - name: Build Summary
  414. if: ${{ always() }}
  415. run: |
  416. # Kernel info
  417. echo "Android Version : $ANDROID_VERSION"
  418. echo "Kernel Version : $KERNEL_VERSION"
  419. echo "Sub Level : $SUB_LEVEL"
  420. echo "Sub level (Makefile): $SUBLEVEL"
  421. echo "Patch Level : $OS_PATCH_LEVEL"
  422. # Branch info
  423. echo "Repo Branch : common-$KERNEL_VERSION-$ANDROID_VERSION-$OS_PATCH_LEVEL || 'normal'"
  424. echo "Deprecated : $DEPRECATED_BRANCH"
  425. # Build info
  426. echo "Build Type : ${{ matrix.variant }}"
  427. # Features info
  428. echo "Features : ${{ inputs.feature_set || 'None' }}"
  429. echo "KSUN Commit : ${{ inputs.ksu_commit || 'canary' }}"
  430. echo "KSUN Tag : $KSU_GIT_TAG"
  431. echo "KSUN Version : $KSU_VERSION"
  432. echo "BBG Commit : $BBG_COMMIT"
  433. echo "BBG Version : $BBG_VERSION"
  434. # Variant info
  435. echo "Variant : ${{ matrix.variant }}"
  436. echo "Features : ${{ inputs.feature_set || 'None' }}"
  437. # End of workflow