gki-kernel.yml 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470
  1. name: GKI Kernel Build
  2. permissions:
  3. contents: write # Allow writing to repository contents (for pushing tags)
  4. actions: write # Allows triggering actions
  5. on:
  6. workflow_call: # This allows this workflow to be called from another workflow
  7. inputs:
  8. android_version:
  9. required: true
  10. type: string
  11. kernel_version:
  12. required: true
  13. type: string
  14. sub_level:
  15. required: true
  16. type: string
  17. os_patch_level:
  18. required: true
  19. type: string
  20. runner:
  21. required: true
  22. type: string
  23. lto_type:
  24. required: true
  25. type: string
  26. kernelsu_variant:
  27. required: true
  28. type: string
  29. kernelsu_branch:
  30. required: true
  31. type: string
  32. kernelsu_branch_other:
  33. required: false
  34. type: string
  35. revision:
  36. required: false
  37. type: string
  38. jobs:
  39. build-kernel-kernelsu-susfs:
  40. runs-on: ${{ inputs.runner }}
  41. steps:
  42. - name: Maximize build space
  43. if: ${{ inputs.runner == 'ubuntu-22.04' }}
  44. uses: easimon/maximize-build-space@master
  45. with:
  46. root-reserve-mb: 8192
  47. temp-reserve-mb: 2048
  48. swap-size-mb: 8192
  49. remove-dotnet: "true"
  50. remove-android: "true"
  51. remove-haskell: "true"
  52. remove-codeql: "true"
  53. - name: Clean up workspace
  54. run: rm -rf ${{ github.workspace }}/*
  55. - name: Set CONFIG Environment Variable
  56. run: |
  57. # Set CONFIG dynamically based on inputs values
  58. CONFIG="${{ inputs.android_version }}-${{ inputs.kernel_version }}-${{ inputs.sub_level }}"
  59. # Set CONFIG as an environment variable for future steps
  60. echo "CONFIG=$CONFIG" >> $GITHUB_ENV
  61. echo "CONFIG set to: $CONFIG"
  62. - name: Setup ccache
  63. #if: inputs.use_cache == true
  64. uses: hendrikmuhs/ccache-action@v1
  65. with:
  66. key: ${{ inputs.android_version }}-${{ inputs.kernel_version }}-${{ inputs.sub_level }}
  67. max-size: 2G
  68. - name: Cache toolchain
  69. id: cache-toolchain
  70. uses: actions/cache@v4
  71. with:
  72. path: |
  73. kernel-build-tools
  74. mkbootimg
  75. key: toolchain-${{ runner.os }}-v1
  76. # Step 2: Download toolchain if cache was not found
  77. - name: Download toolchain (if cache not found)
  78. if: steps.cache-toolchain.outputs.cache-hit != 'true'
  79. run: |
  80. AOSP_MIRROR=https://android.googlesource.com
  81. BRANCH=main-kernel-build-2024
  82. git clone $AOSP_MIRROR/kernel/prebuilts/build-tools -b $BRANCH --depth 1 kernel-build-tools
  83. git clone $AOSP_MIRROR/platform/system/tools/mkbootimg -b $BRANCH --depth 1 mkbootimg
  84. - name: Set environment variables
  85. run: |
  86. echo "AVBTOOL=$GITHUB_WORKSPACE/kernel-build-tools/linux-x86/bin/avbtool" >> $GITHUB_ENV
  87. echo "MKBOOTIMG=$GITHUB_WORKSPACE/mkbootimg/mkbootimg.py" >> $GITHUB_ENV
  88. echo "UNPACK_BOOTIMG=$GITHUB_WORKSPACE/mkbootimg/unpack_bootimg.py" >> $GITHUB_ENV
  89. - name: Set boot sign key
  90. env:
  91. BOOT_SIGN_KEY: ${{ secrets.BOOT_SIGN_KEY }}
  92. run: |
  93. if [ ! -z "$BOOT_SIGN_KEY" ]; then
  94. echo "$BOOT_SIGN_KEY" > ./kernel-build-tools/linux-x86/share/avb/testkey_rsa2048.pem
  95. echo "BOOT_SIGN_KEY_PATH=$GITHUB_WORKSPACE/kernel-build-tools/linux-x86/share/avb/testkey_rsa2048.pem" >> $GITHUB_ENV
  96. else
  97. echo "BOOT_SIGN_KEY is not set. Exiting..."
  98. exit 1
  99. fi
  100. - name: Install Repo
  101. run: |
  102. # Install dependencies
  103. mkdir -p ./git-repo
  104. curl https://storage.googleapis.com/git-repo-downloads/repo > ./git-repo/repo
  105. chmod a+rx ./git-repo/repo
  106. echo "REPO=$GITHUB_WORKSPACE/./git-repo/repo" >> $GITHUB_ENV
  107. - name: Clone AnyKernel3 and Other Dependencies
  108. run: |
  109. echo "Cloning AnyKernel3 and other dependencies..."
  110. # Define the branch names using the inputs values
  111. SUSFS_BRANCH="gki-${{ inputs.android_version }}-${{ inputs.kernel_version }}"
  112. # Debug print the branches
  113. echo "Using branch for SUSFS: $SUSFS_BRANCH"
  114. # Clone repositories using the branch names
  115. git clone https://github.com/WildPlusKernel/AnyKernel3.git -b "gki-2.0"
  116. git clone https://gitlab.com/simonpunk/susfs4ksu.git -b "$SUSFS_BRANCH"
  117. git clone https://github.com/WildPlusKernel/kernel_patches.git
  118. - name: Set CONFIG Environment Variable
  119. run: |
  120. # Set CONFIG dynamically based on inputs values
  121. CONFIG="${{ inputs.android_version }}-${{ inputs.kernel_version }}-${{ inputs.sub_level }}"
  122. # Set CONFIG as an environment variable for future steps
  123. echo "CONFIG=$CONFIG" >> $GITHUB_ENV
  124. echo "CONFIG set to: $CONFIG"
  125. - name: Initialize and Sync Kernel Source
  126. run: |
  127. echo "Creating folder for configuration: $CONFIG..."
  128. mkdir -p "$CONFIG"
  129. cd "$CONFIG"
  130. # Initialize and sync kernel source
  131. echo "Initializing and syncing kernel source..."
  132. FORMATTED_BRANCH="${{ inputs.android_version }}-${{ inputs.kernel_version }}-${{ inputs.os_patch_level }}"
  133. $REPO init --depth=1 --u https://android.googlesource.com/kernel/manifest -b common-${FORMATTED_BRANCH} --repo-rev=v2.16
  134. REMOTE_BRANCH=$(git ls-remote https://android.googlesource.com/kernel/common ${FORMATTED_BRANCH})
  135. DEFAULT_MANIFEST_PATH=.repo/manifests/default.xml
  136. # Check if branch is deprecated
  137. if grep -q deprecated <<< $REMOTE_BRANCH; then
  138. echo "Found deprecated branch: $FORMATTED_BRANCH"
  139. sed -i "s/\"${FORMATTED_BRANCH}\"/\"deprecated\/${FORMATTED_BRANCH}\"/g" $DEFAULT_MANIFEST_PATH
  140. fi
  141. # Sync repo and apply patches
  142. $REPO --version
  143. $REPO --trace sync -c -j$(nproc --all) --no-tags --fail-fast
  144. - name: Determine the branch for KernelSU
  145. run: |
  146. if [[ "${{ inputs.kernelsu_branch }}" == "Stable" ]]; then
  147. echo "BRANCH=-" >> $GITHUB_ENV
  148. elif [[ "${{ inputs.kernelsu_branch }}" == "Dev" && ( "${{ inputs.kernelsu_variant }}" == "Official" || "${{ inputs.kernelsu_variant }}" == "MKSU" ) ]]; then
  149. echo "BRANCH=-s main" >> $GITHUB_ENV
  150. elif [[ "${{ inputs.kernelsu_branch }}" == "Dev" && "${{ inputs.kernelsu_variant }}" == "Next" ]]; then
  151. echo "BRANCH=-s next" >> $GITHUB_ENV
  152. elif [[ "${{ inputs.kernelsu_branch }}" == "Other" && -n "${{ inputs.kernelsu_branch_other }}" ]]; then
  153. echo "BRANCH=-s ${{ inputs.kernelsu_branch_other }}" >> $GITHUB_ENV
  154. else
  155. echo "Error: Custom branch not provided for 'Other'" >&2
  156. exit 1
  157. fi
  158. - name: Add KernelSU
  159. run: |
  160. echo "Changing to configuration directory: $CONFIG..."
  161. cd "$CONFIG"
  162. if [ "${{ inputs.kernelsu_variant }}" == "Official" ]; then
  163. echo "Adding KernelSU Official..."
  164. curl -LSs "https://raw.githubusercontent.com/tiann/KernelSU/main/kernel/setup.sh" | bash $BRANCH
  165. elif [ "${{ inputs.kernelsu_variant }}" == "Next" ]; then
  166. echo "Adding KernelSU Next..."
  167. curl -LSs "https://raw.githubusercontent.com/KernelSU-Next/KernelSU-Next/next/kernel/setup.sh" | bash $BRANCH
  168. #curl -LSs "https://raw.githubusercontent.com/KernelSU-Next/KernelSU-Next/next-susfs/kernel/setup.sh" | bash -s next-susfs
  169. elif [ "${{ inputs.kernelsu_variant }}" == "MKSU" ]; then
  170. echo "Adding KernelSU MKSU..."
  171. curl -LSs "https://raw.githubusercontent.com/5ec1cff/KernelSU/main/kernel/setup.sh" | bash $BRANCH
  172. fi
  173. - name: Apply SUSFS Patches for KernelSU Variants
  174. run: |
  175. echo "Changing to configuration directory: $CONFIG..."
  176. cd "$CONFIG"
  177. echo "Applying SUSFS patches..."
  178. # Copy SUSFS patches
  179. cp ../susfs4ksu/kernel_patches/50_add_susfs_in_gki-${{ inputs.android_version }}-${{ inputs.kernel_version }}.patch ./common/
  180. cp ../susfs4ksu/kernel_patches/fs/* ./common/fs/
  181. cp ../susfs4ksu/kernel_patches/include/linux/* ./common/include/linux/
  182. if [ "${{ inputs.kernelsu_variant }}" == "Official" ]; then
  183. echo "Applying SUSFS patches for Official KernelSU..."
  184. cp ../susfs4ksu/kernel_patches/KernelSU/10_enable_susfs_for_ksu.patch ./KernelSU/
  185. cd ./KernelSU
  186. patch -p1 --forward < 10_enable_susfs_for_ksu.patch
  187. elif [ "${{ inputs.kernelsu_variant }}" == "Next" ]; then
  188. echo "Applying SUSFS patches for KernelSU-Next..."
  189. cd ./KernelSU-Next
  190. cp ../../kernel_patches/0001-kernel-patch-susfs-v1.5.5-to-KernelSU-Next-v1.0.5.patch ./
  191. patch -p1 --forward < 0001-kernel-patch-susfs-v1.5.5-to-KernelSU-Next-v1.0.5.patch || true
  192. elif [ "${{ inputs.kernelsu_variant }}" == "MKSU" ]; then
  193. echo "Applying SUSFS patches for MKSU..."
  194. cp ../susfs4ksu/kernel_patches/KernelSU/10_enable_susfs_for_ksu.patch ./KernelSU/
  195. cd ./KernelSU
  196. patch -p1 --forward < 10_enable_susfs_for_ksu.patch || true
  197. echo "Applying MKSU specific SUSFS patch..."
  198. cp ../../kernel_patches/mksu_susfs.patch ../KernelSU/
  199. patch -p1 < mksu_susfs.patch
  200. cp ../../kernel_patches/fix.patch ./KernelSU/
  201. patch -p1 < fix.patch
  202. else
  203. echo "Invalid KernelSU variant selected!"
  204. exit 1
  205. fi
  206. # Change to common directory and apply common SUSFS patch
  207. cd ../common
  208. patch -p1 < 50_add_susfs_in_gki-${{ inputs.android_version }}-${{ inputs.kernel_version }}.patch || true
  209. - name: Apply Hide Stuff Patches
  210. run: |
  211. echo "Changing to configuration directory: $CONFIG..."
  212. cd "$CONFIG/common"
  213. # Apply additional patch
  214. cp ../../kernel_patches/new_hooks.patch ./
  215. patch -p1 -F 3 < new_hooks.patch
  216. # - name: Apply Hide Stuff Patches
  217. # run: |
  218. # echo "Changing to configuration directory: $CONFIG..."
  219. # cd "$CONFIG/common"
  220. # # Apply additional patch
  221. # cp ../../kernel_patches/69_hide_stuff.patch ./
  222. # patch -p1 -F 3 < 69_hide_stuff.patch
  223. - name: Add SUSFS Configuration Settings
  224. run: |
  225. echo "Changing to configuration directory: $CONFIG..."
  226. cd "$CONFIG"
  227. echo "Adding configuration settings to gki_defconfig..."
  228. # Add KSU configuration settings
  229. echo "CONFIG_KSU=y" >> ./common/arch/arm64/configs/gki_defconfig
  230. echo "CONFIG_KSU_WITH_KPROBES=n" >> ./common/arch/arm64/configs/gki_defconfig
  231. # Add SUSFS configuration settings
  232. echo "CONFIG_KSU_SUSFS=y" >> ./common/arch/arm64/configs/gki_defconfig
  233. echo "CONFIG_KSU_SUSFS_HAS_MAGIC_MOUNT=y" >> ./common/arch/arm64/configs/gki_defconfig
  234. echo "CONFIG_KSU_SUSFS_SUS_PATH=y" >> ./common/arch/arm64/configs/gki_defconfig
  235. echo "CONFIG_KSU_SUSFS_SUS_MOUNT=y" >> ./common/arch/arm64/configs/gki_defconfig
  236. echo "CONFIG_KSU_SUSFS_AUTO_ADD_SUS_KSU_DEFAULT_MOUNT=y" >> ./common/arch/arm64/configs/gki_defconfig
  237. echo "CONFIG_KSU_SUSFS_AUTO_ADD_SUS_BIND_MOUNT=y" >> ./common/arch/arm64/configs/gki_defconfig
  238. echo "CONFIG_KSU_SUSFS_SUS_KSTAT=y" >> ./common/arch/arm64/configs/gki_defconfig
  239. echo "CONFIG_KSU_SUSFS_SUS_OVERLAYFS=n" >> ./common/arch/arm64/configs/gki_defconfig
  240. echo "CONFIG_KSU_SUSFS_TRY_UMOUNT=y" >> ./common/arch/arm64/configs/gki_defconfig
  241. echo "CONFIG_KSU_SUSFS_AUTO_ADD_TRY_UMOUNT_FOR_BIND_MOUNT=y" >> ./common/arch/arm64/configs/gki_defconfig
  242. echo "CONFIG_KSU_SUSFS_SPOOF_UNAME=y" >> ./common/arch/arm64/configs/gki_defconfig
  243. echo "CONFIG_KSU_SUSFS_ENABLE_LOG=y" >> ./common/arch/arm64/configs/gki_defconfig
  244. echo "CONFIG_KSU_SUSFS_HIDE_KSU_SUSFS_SYMBOLS=y" >> ./common/arch/arm64/configs/gki_defconfig
  245. echo "CONFIG_KSU_SUSFS_SPOOF_CMDLINE_OR_BOOTCONFIG=y" >> ./common/arch/arm64/configs/gki_defconfig
  246. echo "CONFIG_KSU_SUSFS_OPEN_REDIRECT=y" >> ./common/arch/arm64/configs/gki_defconfig
  247. echo "CONFIG_KSU_SUSFS_SUS_SU=n" >> ./common/arch/arm64/configs/gki_defconfig
  248. # Add additional tmpfs config setting
  249. echo "CONFIG_TMPFS_XATTR=y" >> ./common/arch/arm64/configs/gki_defconfig
  250. echo "CONFIG_TMPFS_POSIX_ACL=y" >> ./common/arch/arm64/configs/gki_defconfig
  251. # Add additional tmpfs config setting
  252. echo "CONFIG_IP_NF_TARGET_TTL=y" >> ./common/arch/arm64/configs/gki_defconfig
  253. echo "CONFIG_IP6_NF_TARGET_HL=y" >> ./common/arch/arm64/configs/gki_defconfig
  254. echo "CONFIG_IP6_NF_MATCH_HL=y" >> ./common/arch/arm64/configs/gki_defconfig
  255. # Remove check_defconfig
  256. sed -i 's/check_defconfig//' ./common/build.config.gki
  257. - name: Config Kernel Name
  258. run: |
  259. echo "Changing to configuration directory: $CONFIG..."
  260. cd "$CONFIG"
  261. sed -i '$s|echo "\$res"|echo "\$res-Wild+"|' ./common/scripts/setlocalversion
  262. # Run perl command to modify UTS_VERSION
  263. perl -pi -e 's{UTS_VERSION="\$\(echo \$UTS_VERSION \$CONFIG_FLAGS \$TIMESTAMP \| cut -b -\$UTS_LEN\)"}{UTS_VERSION="#1 SMP PREEMPT Sat Apr 20 04:20:00 UTC 2024"}' ./common/scripts/mkcompile_h
  264. echo "Building the kernel..."
  265. if [ -f "build/build.sh" ]; then
  266. sed -i 's/-dirty//' ./common/scripts/setlocalversion
  267. #LTO=${{ inputs.lto_type }} BUILD_CONFIG=common/build.config.gki.aarch64 build/build.sh CC="/usr/bin/ccache clang"
  268. else
  269. rm -rf ./common/android/abi_gki_protected_exports_*
  270. sed -i "/stable_scmversion_cmd/s/-maybe-dirty//g" ./build/kernel/kleaf/impl/stamp.bzl
  271. sed -E -i '/^CONFIG_LOCALVERSION=/ s/(.*)"$/\1-Wild+"/' ./common/arch/arm64/configs/gki_defconfig
  272. #tools/bazel build --config=fast --lto=${{ inputs.lto_type }} //common:kernel_aarch64_dist
  273. fi
  274. - name: Build the Kernel
  275. uses: nick-fields/retry@v3
  276. with:
  277. timeout_minutes: 60
  278. max_attempts: 3
  279. command: |
  280. cd "$CONFIG"
  281. echo "Building the kernel..."
  282. if [ -f "build/build.sh" ]; then
  283. LTO=${{ inputs.lto_type }} BUILD_CONFIG=common/build.config.gki.aarch64 build/build.sh CC="/usr/bin/ccache clang"
  284. else
  285. tools/bazel build --disk_cache=/home/runner/.cache/bazel --config=fast --lto=${{ inputs.lto_type }} //common:kernel_aarch64_dist
  286. fi
  287. - name: Create Bootimgs Folder and Copy Images
  288. if: ${{ inputs.android_version == 'android12' || inputs.android_version == 'android13' }}
  289. run: |
  290. echo "Changing to configuration directory: $CONFIG..."
  291. mkdir bootimgs
  292. echo "Creating bootimgs folder and copying images..."
  293. cp ./$CONFIG/out/${{ inputs.android_version }}-${{ inputs.kernel_version }}/dist/Image ./bootimgs
  294. cp ./$CONFIG/out/${{ inputs.android_version }}-${{ inputs.kernel_version }}/dist/Image.lz4 ./bootimgs
  295. cp ./$CONFIG/out/${{ inputs.android_version }}-${{ inputs.kernel_version }}/dist/Image ./
  296. cp ./$CONFIG/out/${{ inputs.android_version }}-${{ inputs.kernel_version }}/dist/Image.lz4 ./
  297. # Create gzip of the Image file
  298. gzip -n -k -f -9 ./Image > ./Image.gz
  299. - name: Create Bootimgs Folder and Copy Images
  300. if: ${{ inputs.android_version == 'android14' || inputs.android_version == 'android15' }}
  301. run: |
  302. echo "Changing to configuration directory: $CONFIG..."
  303. mkdir bootimgs
  304. echo "Creating bootimgs folder and copying images..."
  305. cp ./$CONFIG/bazel-bin/common/kernel_aarch64/Image ./bootimgs
  306. cp ./$CONFIG/bazel-bin/common/kernel_aarch64/Image.lz4 ./bootimgs
  307. cp ./$CONFIG/bazel-bin/common/kernel_aarch64/Image ./
  308. cp ./$CONFIG/bazel-bin/common/kernel_aarch64/Image.lz4 ./
  309. # Create gzip of the Image file
  310. gzip -n -k -f -9 ./Image > ./Image.gz
  311. - name: Create ZIP Files for Different Formats
  312. run: |
  313. echo "Creating zip files for all formats..."
  314. cd ./AnyKernel3
  315. # Create and upload zip for each format
  316. ZIP_NAME="${{ inputs.android_version }}-${{ inputs.kernel_version }}.${{ inputs.sub_level }}-${{ inputs.os_patch_level }}-AnyKernel3.zip"
  317. echo "Creating zip file: $ZIP_NAME..."
  318. mv ../Image ./Image
  319. zip -r "../$ZIP_NAME" ./*
  320. rm ./Image
  321. ZIP_NAME="${{ inputs.android_version }}-${{ inputs.kernel_version }}.${{ inputs.sub_level }}-${{ inputs.os_patch_level }}-AnyKernel3-lz4.zip"
  322. echo "Creating zip file: $ZIP_NAME..."
  323. mv ../Image.lz4 ./Image.lz4
  324. zip -r "../$ZIP_NAME" ./*
  325. rm ./Image.lz4
  326. ZIP_NAME="${{ inputs.android_version }}-${{ inputs.kernel_version }}.${{ inputs.sub_level }}-${{ inputs.os_patch_level }}-AnyKernel3-gz.zip"
  327. echo "Creating zip file: $ZIP_NAME..."
  328. mv ../Image.gz ./Image.gz
  329. zip -r "../$ZIP_NAME" ./*
  330. rm ./Image.gz
  331. - name: Run Boot Image ${{ inputs.android_version }} Build Script
  332. if: ${{ inputs.android_version == 'android12' }}
  333. run: |
  334. echo "Changing to configuration directory: $CONFIG..."
  335. cd bootimgs
  336. GKI_URL=https://dl.google.com/android/gki/gki-certified-boot-android12-5.10-"${{ inputs.os_patch_level }}"_"${{ inputs.revision }}".zip
  337. FALLBACK_URL=https://dl.google.com/android/gki/gki-certified-boot-android12-5.10-2023-01_r1.zip
  338. # Check if the GKI URL is available
  339. echo "Checking if GKI kernel URL is reachable: $GKI_URL"
  340. status=$(curl -sL -w "%{http_code}" "$GKI_URL" -o /dev/null)
  341. if [ "$status" = "200" ]; then
  342. echo "[+] Downloading from GKI_URL"
  343. curl -Lo gki-kernel.zip "$GKI_URL"
  344. else
  345. echo "[+] $GKI_URL not found, using $FALLBACK_URL"
  346. curl -Lo gki-kernel.zip "$FALLBACK_URL"
  347. fi
  348. # Unzip the downloaded kernel and remove the zip
  349. echo "Unzipping the downloaded kernel..."
  350. unzip gki-kernel.zip && rm gki-kernel.zip
  351. echo "Unpacking boot.img..."
  352. FULL_PATH=$(pwd)/boot-5.10.img
  353. echo "Unpacking using: $FULL_PATH"
  354. echo "Running unpack_bootimg.py..."
  355. $UNPACK_BOOTIMG --boot_img="$FULL_PATH"
  356. echo "Building Image.gz"
  357. gzip -n -k -f -9 ./Image > ./Image.gz
  358. echo "Building boot.img"
  359. $MKBOOTIMG --header_version 4 --kernel Image --output boot.img --ramdisk out/ramdisk --os_version 12.0.0 --os_patch_level "${{ inputs.os_patch_level }}"
  360. $AVBTOOL add_hash_footer --partition_name boot --partition_size $((64 * 1024 * 1024)) --image boot.img --algorithm SHA256_RSA2048 --key $BOOT_SIGN_KEY_PATH
  361. cp ./boot.img ../${{ inputs.android_version }}-${{ inputs.kernel_version }}.${{ inputs.sub_level }}-${{ inputs.os_patch_level }}-boot.img
  362. echo "Building boot-gz.img"
  363. $MKBOOTIMG --header_version 4 --kernel Image.gz --output boot-gz.img --ramdisk out/ramdisk --os_version 12.0.0 --os_patch_level "${{ inputs.os_patch_level }}"
  364. $AVBTOOL add_hash_footer --partition_name boot --partition_size $((64 * 1024 * 1024)) --image boot-gz.img --algorithm SHA256_RSA2048 --key $BOOT_SIGN_KEY_PATH
  365. cp ./boot-gz.img ../${{ inputs.android_version }}-${{ inputs.kernel_version }}.${{ inputs.sub_level }}-${{ inputs.os_patch_level }}-boot-gz.img
  366. echo "Building boot-lz4.img"
  367. $MKBOOTIMG --header_version 4 --kernel Image.lz4 --output boot-lz4.img --ramdisk out/ramdisk --os_version 12.0.0 --os_patch_level "${{ inputs.os_patch_level }}"
  368. $AVBTOOL add_hash_footer --partition_name boot --partition_size $((64 * 1024 * 1024)) --image boot-lz4.img --algorithm SHA256_RSA2048 --key $BOOT_SIGN_KEY_PATH
  369. cp ./boot-lz4.img ../${{ inputs.android_version }}-${{ inputs.kernel_version }}.${{ inputs.sub_level }}-${{ inputs.os_patch_level }}-boot-lz4.img
  370. - name: Run Boot Image ${{ inputs.android_version }} Build Script
  371. if: ${{ inputs.android_version == 'android13' || inputs.android_version == 'android14' || inputs.android_version == 'android15' }}
  372. run: |
  373. cd bootimgs
  374. echo "Building Image.gz"
  375. gzip -n -k -f -9 ./Image > ./Image.gz
  376. echo "Building boot.img"
  377. $MKBOOTIMG --header_version 4 --kernel Image --output boot.img
  378. $AVBTOOL add_hash_footer --partition_name boot --partition_size $((64 * 1024 * 1024)) --image boot.img --algorithm SHA256_RSA2048 --key $BOOT_SIGN_KEY_PATH
  379. cp ./boot.img ../${{ inputs.android_version }}-${{ inputs.kernel_version }}.${{ inputs.sub_level }}-${{ inputs.os_patch_level }}-boot.img
  380. echo "Building boot-gz.img"
  381. $MKBOOTIMG --header_version 4 --kernel Image.gz --output boot-gz.img
  382. $AVBTOOL add_hash_footer --partition_name boot --partition_size $((64 * 1024 * 1024)) --image boot-gz.img --algorithm SHA256_RSA2048 --key $BOOT_SIGN_KEY_PATH
  383. cp ./boot-gz.img ../${{ inputs.android_version }}-${{ inputs.kernel_version }}.${{ inputs.sub_level }}-${{ inputs.os_patch_level }}-boot-gz.img
  384. echo "Building boot-lz4.img"
  385. $MKBOOTIMG --header_version 4 --kernel Image.lz4 --output boot-lz4.img
  386. $AVBTOOL add_hash_footer --partition_name boot --partition_size $((64 * 1024 * 1024)) --image boot-lz4.img --algorithm SHA256_RSA2048 --key $BOOT_SIGN_KEY_PATH
  387. cp ./boot-lz4.img ../${{ inputs.android_version }}-${{ inputs.kernel_version }}.${{ inputs.sub_level }}-${{ inputs.os_patch_level }}-boot-lz4.img
  388. - name: Upload Build Artifacts
  389. uses: actions/upload-artifact@v4
  390. with:
  391. name: kernel-${{ env.CONFIG }}
  392. path: |
  393. *.zip
  394. *.img