build.yml 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519
  1. name: Build Script
  2. permissions:
  3. contents: write
  4. actions: write
  5. on:
  6. workflow_call:
  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. kernelsu_variant:
  21. required: true
  22. type: string
  23. kernelsu_branch:
  24. required: true
  25. type: string
  26. kernelsu_branch_other:
  27. required: false
  28. type: string
  29. revision:
  30. required: false
  31. type: string
  32. jobs:
  33. build-gki:
  34. runs-on: ubuntu-latest
  35. timeout-minutes: 120
  36. env:
  37. CCACHE_COMPILERCHECK: "%compiler% -dumpmachine; %compiler% -dumpversion"
  38. CCACHE_NOHASHDIR: "true"
  39. CCACHE_HARDLINK: "true"
  40. steps:
  41. - name: Set CONFIG Environment Variable
  42. run: |
  43. # Set CONFIG dynamically based on inputs values
  44. CONFIG="${{ inputs.android_version }}-${{ inputs.kernel_version }}-${{ inputs.sub_level }}"
  45. # Set CONFIG as an environment variable for future steps
  46. echo "CONFIG=$CONFIG" >> $GITHUB_ENV
  47. echo "CONFIG set to: $CONFIG"
  48. - name: Install ccache
  49. run: sudo apt update && sudo apt install -y ccache
  50. - name: Set up ccache
  51. run: |
  52. mkdir -p ~/.cache/bazel
  53. ccache --version
  54. ccache --max-size=2G
  55. ccache --set-config=compression=true
  56. echo "CCACHE_DIR=$HOME/.ccache" >> $GITHUB_ENV
  57. - name: Restore ccache from cache
  58. uses: actions/cache@v4
  59. with:
  60. path: ~/.ccache
  61. key: ${{ inputs.android_version }}-${{ inputs.kernel_version }}-${{ inputs.sub_level }}-ccache-${{ github.sha }}
  62. restore-keys: |
  63. ${{ inputs.android_version }}-${{ inputs.kernel_version }}-${{ inputs.sub_level }}-ccache-
  64. - name: Cache toolchain
  65. id: cache-toolchain
  66. uses: actions/cache@v4
  67. with:
  68. path: |
  69. kernel-build-tools
  70. mkbootimg
  71. key: toolchain-${{ runner.os }}-v1
  72. - name: Download toolchain (if cache not found)
  73. if: steps.cache-toolchain.outputs.cache-hit != 'true'
  74. run: |
  75. AOSP_MIRROR=https://android.googlesource.com
  76. BRANCH=main-kernel-build-2024
  77. git clone $AOSP_MIRROR/kernel/prebuilts/build-tools -b $BRANCH --depth 1 kernel-build-tools
  78. git clone $AOSP_MIRROR/platform/system/tools/mkbootimg -b $BRANCH --depth 1 mkbootimg
  79. - name: Set environment variables
  80. run: |
  81. echo "AVBTOOL=$GITHUB_WORKSPACE/kernel-build-tools/linux-x86/bin/avbtool" >> $GITHUB_ENV
  82. echo "MKBOOTIMG=$GITHUB_WORKSPACE/mkbootimg/mkbootimg.py" >> $GITHUB_ENV
  83. echo "UNPACK_BOOTIMG=$GITHUB_WORKSPACE/mkbootimg/unpack_bootimg.py" >> $GITHUB_ENV
  84. - name: Set boot sign key
  85. env:
  86. BOOT_SIGN_KEY: ${{ secrets.BOOT_SIGN_KEY }}
  87. run: |
  88. if [ ! -z "$BOOT_SIGN_KEY" ]; then
  89. echo "$BOOT_SIGN_KEY" > ./kernel-build-tools/linux-x86/share/avb/testkey_rsa2048.pem
  90. echo "BOOT_SIGN_KEY_PATH=$GITHUB_WORKSPACE/kernel-build-tools/linux-x86/share/avb/testkey_rsa2048.pem" >> $GITHUB_ENV
  91. else
  92. echo "BOOT_SIGN_KEY is not set. Using AOSP sign key..."
  93. echo "BOOT_SIGN_KEY_PATH=$GITHUB_WORKSPACE/kernel-build-tools/linux-x86/share/avb/testkey_rsa2048.pem" >> $GITHUB_ENV
  94. fi
  95. - name: Install Repo
  96. run: |
  97. mkdir -p ./git-repo
  98. echo "Downloading repo tool..."
  99. curl https://storage.googleapis.com/git-repo-downloads/repo > ./git-repo/repo
  100. chmod a+rx ./git-repo/repo
  101. echo "REPO=$GITHUB_WORKSPACE/./git-repo/repo" >> $GITHUB_ENV
  102. - name: Clone AnyKernel3 and Other Dependencies
  103. run: |
  104. echo "Cloning AnyKernel3 and other dependencies..."
  105. ANYKERNEL_BRANCH="gki-2.0"
  106. SUSFS_BRANCH="gki-${{ inputs.android_version }}-${{ inputs.kernel_version }}"
  107. echo "Using branch for AnyKernel3: $ANYKERNEL_BRANCH"
  108. echo "Using branch for SUSFS: $SUSFS_BRANCH"
  109. git clone https://github.com/WildPlusKernel/AnyKernel3.git -b "$ANYKERNEL_BRANCH"
  110. git clone https://gitlab.com/simonpunk/susfs4ksu.git -b "$SUSFS_BRANCH"
  111. git clone https://github.com/WildPlusKernel/kernel_patches.git
  112. - name: Check Disk Space Before Sync
  113. run: |
  114. echo "Disk space before kernel source sync:"
  115. df -h
  116. - name: Initialize and Sync Kernel Source
  117. run: |
  118. echo "Creating folder for configuration: $CONFIG..."
  119. mkdir -p "$CONFIG"
  120. cd "$CONFIG"
  121. echo "Initializing and syncing kernel source..."
  122. FORMATTED_BRANCH="${{ inputs.android_version }}-${{ inputs.kernel_version }}-${{ inputs.os_patch_level }}"
  123. $REPO init --depth=1 --u https://android.googlesource.com/kernel/manifest -b common-${FORMATTED_BRANCH} --repo-rev=v2.16
  124. REMOTE_BRANCH=$(git ls-remote https://android.googlesource.com/kernel/common ${FORMATTED_BRANCH})
  125. DEFAULT_MANIFEST_PATH=.repo/manifests/default.xml
  126. if grep -q deprecated <<< $REMOTE_BRANCH; then
  127. echo "Found deprecated branch: $FORMATTED_BRANCH"
  128. sed -i "s/\"${FORMATTED_BRANCH}\"/\"deprecated\/${FORMATTED_BRANCH}\"/g" $DEFAULT_MANIFEST_PATH
  129. fi
  130. $REPO --version
  131. $REPO --trace sync -c -j$(nproc --all) --no-tags --fail-fast
  132. - name: Determine the branch for KernelSU
  133. run: |
  134. case "${{ inputs.kernelsu_branch }}" in
  135. "Stable")
  136. echo "BRANCH=-" >> $GITHUB_ENV
  137. ;;
  138. "Dev")
  139. if [[ "${{ inputs.kernelsu_variant }}" =~ ^(KSU|MKSU)$ ]]; then
  140. echo "BRANCH=-s main" >> $GITHUB_ENV
  141. elif [[ "${{ inputs.kernelsu_variant }}" == "NEXT" ]]; then
  142. echo "BRANCH=-s next" >> $GITHUB_ENV
  143. elif [[ "${{ inputs.kernelsu_variant }}" == "WILD" ]]; then
  144. echo "BRANCH=-s wild" >> $GITHUB_ENV
  145. fi
  146. ;;
  147. "Other")
  148. if [[ -n "${{ inputs.kernelsu_branch_other }}" ]]; then
  149. echo "BRANCH=-s ${{ inputs.kernelsu_branch_other }}" >> $GITHUB_ENV
  150. else
  151. echo "Error: Custom branch not provided for 'Other'" >&2
  152. exit 1
  153. fi
  154. ;;
  155. esac
  156. - name: Add KernelSU
  157. run: |
  158. echo "Changing to configuration directory: $CONFIG..."
  159. cd "$CONFIG"
  160. case "${{ inputs.kernelsu_variant }}" in
  161. "WILD")
  162. echo "Adding Wild KSU..."
  163. curl -LSs "https://raw.githubusercontent.com/WildKernels/Wild_KSU/refs/heads/wild/kernel/setup.sh" | bash ${{ env.BRANCH }}
  164. ;;
  165. "KSU")
  166. echo "Adding KernelSU Official..."
  167. curl -LSs "https://raw.githubusercontent.com/tiann/KernelSU/main/kernel/setup.sh" | bash ${{ env.BRANCH }}
  168. ;;
  169. "NEXT")
  170. echo "Adding KernelSU Next..."
  171. curl -LSs "https://raw.githubusercontent.com/KernelSU-Next/KernelSU-Next/next/kernel/setup.sh" | bash ${{ env.BRANCH }}
  172. ;;
  173. "MKSU")
  174. echo "Adding KernelSU MKSU..."
  175. curl -LSs "https://raw.githubusercontent.com/5ec1cff/KernelSU/main/kernel/setup.sh" | bash ${{ env.BRANCH }}
  176. ;;
  177. esac
  178. - name: Apply SUSFS Patches for KernelSU Variants
  179. run: |
  180. echo "Changing to configuration directory: $CONFIG..."
  181. cd "$CONFIG"
  182. echo "Applying SUSFS patches..."
  183. # Copy SUSFS patches
  184. cp ../susfs4ksu/kernel_patches/50_add_susfs_in_gki-${{ inputs.android_version }}-${{ inputs.kernel_version }}.patch ./common/
  185. cp ../susfs4ksu/kernel_patches/fs/* ./common/fs/
  186. cp ../susfs4ksu/kernel_patches/include/linux/* ./common/include/linux/
  187. case "${{ inputs.kernelsu_variant }}" in
  188. "WILD")
  189. echo "Applying SUSFS patches for Official KernelSU..."
  190. cd ./KernelSU
  191. cp ../../susfs4ksu/kernel_patches/KernelSU/10_enable_susfs_for_ksu.patch ./
  192. patch -p1 --forward --fuzz=3 < 10_enable_susfs_for_ksu.patch || true
  193. cp ../../kernel_patches/wild/fix.corehook.c.patch ./
  194. patch -p1 --forward --fuzz=3 < fix.corehook.c.patch
  195. cp ../../kernel_patches/wild/fix.selinux.c.patch ./
  196. patch -p1 --forward --fuzz=3 < fix.selinux.c.patch
  197. cp ../../kernel_patches/wild/fix.sucompat.c.patch ./
  198. patch -p1 --forward --fuzz=3 < fix.sucompat.c.patch
  199. sed -i '/bool ksu_devpts_hook = false;/d' ./kernel/sucompat.c
  200. ;;
  201. "KSU")
  202. echo "Applying SUSFS patches for Official KernelSU..."
  203. cd ./KernelSU
  204. cp ../../susfs4ksu/kernel_patches/KernelSU/10_enable_susfs_for_ksu.patch ./
  205. patch -p1 --forward --fuzz=3 < 10_enable_susfs_for_ksu.patch
  206. ;;
  207. "NEXT")
  208. echo "Applying SUSFS patches for KernelSU Next..."
  209. cd ./KernelSU-Next
  210. cp ../../kernel_patches/next/kernel-patch-susfs-v1.5.7-to-KernelSU-Next.patch ./
  211. patch -p1 --forward --fuzz=3 < kernel-patch-susfs-v1.5.7-to-KernelSU-Next.patch
  212. ;;
  213. "MKSU")
  214. echo "Applying SUSFS patches for MKSU..."
  215. cd ./KernelSU
  216. cp ../../kernel_patches/next/kernel-patch-susfs-v1.5.7-to-KernelSU-Next.patch ./
  217. patch -p1 --forward --fuzz=3 < kernel-patch-susfs-v1.5.7-to-KernelSU-Next.patch
  218. ;;
  219. esac
  220. cd ../common
  221. patch -p1 --fuzz=3 < 50_add_susfs_in_gki-${{ inputs.android_version }}-${{ inputs.kernel_version }}.patch || true
  222. - name: Apply Hooks Patches
  223. run: |
  224. echo "Changing to configuration directory: $CONFIG..."
  225. cd "$CONFIG/common"
  226. if [ "${{ inputs.kernelsu_variant }}" == "NEXT" ]; then
  227. echo "Applying hooks for KernelSU-Next..."
  228. cp ../../kernel_patches/next/syscall_hooks.patch ./
  229. patch -p1 -F 3 < syscall_hooks.patch
  230. elif [ "${{ inputs.kernelsu_variant }}" == "WILD" ]; then
  231. echo "Applying hooks for Wild KSU..."
  232. cp ../../kernel_patches/wild/syscall_hooks.patch ./
  233. patch -p1 -F 3 < syscall_hooks.patch
  234. fi
  235. - name: Apply Hide Stuff Patches
  236. run: |
  237. echo "Changing to configuration directory: $CONFIG..."
  238. cd "$CONFIG/common"
  239. cp ../../kernel_patches/69_hide_stuff.patch ./
  240. patch -p1 -F 3 < 69_hide_stuff.patch
  241. - name: Add All Managers
  242. run: |
  243. cd "$CONFIG"
  244. case "${{ inputs.kernelsu_variant }}" in
  245. "KSU" | "WILD")
  246. echo "Applying Manager patch for Official KernelSU..."
  247. cd KernelSU
  248. cp ../../kernel_patches/wild/manager.patch ./
  249. ;;
  250. "NEXT")
  251. echo "Applying Manager patch for KernelSU Next..."
  252. cd KernelSU-Next
  253. cp ../../kernel_patches/next/manager.patch ./
  254. ;;
  255. "MKSU")
  256. echo "Applying Manager patch for MKSU..."
  257. #cp ../kernel_patches/mksu/manager.patch .//
  258. ;;
  259. esac
  260. patch -p1 --fuzz=3 < manager.patch || echo "No Manager Patch"
  261. - name: Add Configuration Settings
  262. run: |
  263. echo "Changing to configuration directory: $CONFIG..."
  264. cd "$CONFIG"
  265. echo "Adding configuration settings to gki_defconfig..."
  266. # Add KSU configuration settings
  267. echo "CONFIG_KSU=y" >> ./common/arch/arm64/configs/gki_defconfig
  268. if [ "${{ inputs.kernelsu_variant }}" == "NEXT" || "${{ inputs.kernelsu_variant }}" == "WILD" ]; then
  269. echo "CONFIG_KSU_WITH_KPROBES=n" >> ./common/arch/arm64/configs/gki_defconfig
  270. fi
  271. # Add additional tmpfs config setting
  272. echo "CONFIG_TMPFS_XATTR=y" >> ./common/arch/arm64/configs/gki_defconfig
  273. echo "CONFIG_TMPFS_POSIX_ACL=y" >> ./common/arch/arm64/configs/gki_defconfig
  274. # Add additional config setting
  275. echo "CONFIG_IP_NF_TARGET_TTL=y" >> ./common/arch/arm64/configs/gki_defconfig
  276. echo "CONFIG_IP6_NF_TARGET_HL=y" >> ./common/arch/arm64/configs/gki_defconfig
  277. echo "CONFIG_IP6_NF_MATCH_HL=y" >> ./common/arch/arm64/configs/gki_defconfig
  278. # Add BBR Config
  279. echo "CONFIG_TCP_CONG_ADVANCED=y" >> ./common/arch/arm64/configs/gki_defconfig
  280. echo "CONFIG_TCP_CONG_BBR=y" >> ./common/arch/arm64/configs/gki_defconfig
  281. echo "CONFIG_NET_SCH_FQ=y" >> ./common/arch/arm64/configs/gki_defconfig
  282. echo "CONFIG_TCP_CONG_BIC=n" >> ./common/arch/arm64/configs/gki_defconfig
  283. echo "CONFIG_TCP_CONG_WESTWOOD=n" >> ./common/arch/arm64/configs/gki_defconfig
  284. echo "CONFIG_TCP_CONG_HTCP=n" >> ./common/arch/arm64/configs/gki_defconfig
  285. # Remove check_defconfig
  286. sed -i 's/check_defconfig//' ./common/build.config.gki
  287. - name: Add SUSFS Configuration Settings
  288. run: |
  289. echo "Changing to configuration directory: $CONFIG..."
  290. cd "$CONFIG"
  291. # Add SUSFS configuration settings
  292. echo "CONFIG_KSU_SUSFS=y" >> ./common/arch/arm64/configs/gki_defconfig
  293. echo "CONFIG_KSU_SUSFS_HAS_MAGIC_MOUNT=y" >> ./common/arch/arm64/configs/gki_defconfig
  294. echo "CONFIG_KSU_SUSFS_SUS_PATH=y" >> ./common/arch/arm64/configs/gki_defconfig
  295. echo "CONFIG_KSU_SUSFS_SUS_MOUNT=y" >> ./common/arch/arm64/configs/gki_defconfig
  296. echo "CONFIG_KSU_SUSFS_AUTO_ADD_SUS_KSU_DEFAULT_MOUNT=y" >> ./common/arch/arm64/configs/gki_defconfig
  297. echo "CONFIG_KSU_SUSFS_AUTO_ADD_SUS_BIND_MOUNT=y" >> ./common/arch/arm64/configs/gki_defconfig
  298. echo "CONFIG_KSU_SUSFS_SUS_KSTAT=y" >> ./common/arch/arm64/configs/gki_defconfig
  299. echo "CONFIG_KSU_SUSFS_SUS_OVERLAYFS=n" >> ./common/arch/arm64/configs/gki_defconfig
  300. echo "CONFIG_KSU_SUSFS_TRY_UMOUNT=y" >> ./common/arch/arm64/configs/gki_defconfig
  301. echo "CONFIG_KSU_SUSFS_AUTO_ADD_TRY_UMOUNT_FOR_BIND_MOUNT=y" >> ./common/arch/arm64/configs/gki_defconfig
  302. echo "CONFIG_KSU_SUSFS_SPOOF_UNAME=y" >> ./common/arch/arm64/configs/gki_defconfig
  303. echo "CONFIG_KSU_SUSFS_ENABLE_LOG=y" >> ./common/arch/arm64/configs/gki_defconfig
  304. echo "CONFIG_KSU_SUSFS_HIDE_KSU_SUSFS_SYMBOLS=y" >> ./common/arch/arm64/configs/gki_defconfig
  305. echo "CONFIG_KSU_SUSFS_SPOOF_CMDLINE_OR_BOOTCONFIG=y" >> ./common/arch/arm64/configs/gki_defconfig
  306. echo "CONFIG_KSU_SUSFS_OPEN_REDIRECT=y" >> ./common/arch/arm64/configs/gki_defconfig
  307. if [ "${{ inputs.kernelsu_variant }}" == "NEXT" || "${{ inputs.kernelsu_variant }}" == "WILD" ]; then
  308. echo "CONFIG_KSU_SUSFS_SUS_SU=n" >> ./common/arch/arm64/configs/gki_defconfig
  309. else
  310. echo "CONFIG_KSU_SUSFS_SUS_SU=y" >> ./common/arch/arm64/configs/gki_defconfig
  311. fi
  312. - name: Change Kernel Name
  313. run: |
  314. cd "$CONFIG"
  315. # modify UTS_VERSION
  316. 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
  317. sed -i '$s|echo "\$res"|echo "\$res-Wild"|' ./common/scripts/setlocalversion
  318. if [ -f "build/build.sh" ]; then
  319. sed -i 's/-dirty//' ./common/scripts/setlocalversion
  320. else
  321. sed -i '/^[[:space:]]*"protected_exports_list"[[:space:]]*:[[:space:]]*"android\/abi_gki_protected_exports_aarch64",$/d' ./common/BUILD.bazel
  322. rm -rf ./common/android/abi_gki_protected_exports_*
  323. sed -i "/stable_scmversion_cmd/s/-maybe-dirty//g" ./build/kernel/kleaf/impl/stamp.bzl
  324. sed -E -i '/^CONFIG_LOCALVERSION=/ s/(.*)"$/\1-Wild"/' ./common/arch/arm64/configs/gki_defconfig
  325. fi
  326. - name: Build
  327. run : |
  328. set -e
  329. set -x
  330. cd "$CONFIG"
  331. echo "Building the kernel..."
  332. if [ -f "build/build.sh" ]; then
  333. LTO=thin BUILD_CONFIG=common/build.config.gki.aarch64 build/build.sh CC="/usr/bin/ccache clang" || exit 1
  334. else
  335. tools/bazel build --disk_cache=/home/runner/.cache/bazel --config=fast --lto=thin //common:kernel_aarch64_dist || exit 1
  336. fi
  337. ccache --show-stats
  338. - name: Create Bootimgs Folder and Copy Images for Android 12/13
  339. if: ${{ inputs.android_version == 'android12' || inputs.android_version == 'android13' }}
  340. run: |
  341. mkdir bootimgs
  342. echo "Creating bootimgs folder and copying images..."
  343. cp ./$CONFIG/out/${{ inputs.android_version }}-${{ inputs.kernel_version }}/dist/Image ./bootimgs
  344. cp ./$CONFIG/out/${{ inputs.android_version }}-${{ inputs.kernel_version }}/dist/Image.lz4 ./bootimgs
  345. cp ./$CONFIG/out/${{ inputs.android_version }}-${{ inputs.kernel_version }}/dist/Image ./
  346. cp ./$CONFIG/out/${{ inputs.android_version }}-${{ inputs.kernel_version }}/dist/Image.lz4 ./
  347. # Create gzip of the Image file
  348. gzip -n -k -f -9 ./Image > ./Image.gz
  349. - name: Create Bootimgs Folder and Copy Images for Android 14/15
  350. if: ${{ inputs.android_version == 'android14' || inputs.android_version == 'android15' }}
  351. run: |
  352. mkdir bootimgs
  353. echo "Creating bootimgs folder and copying images..."
  354. cp ./$CONFIG/bazel-bin/common/kernel_aarch64/Image ./bootimgs
  355. cp ./$CONFIG/bazel-bin/common/kernel_aarch64/Image.lz4 ./bootimgs
  356. cp ./$CONFIG/bazel-bin/common/kernel_aarch64/Image ./
  357. cp ./$CONFIG/bazel-bin/common/kernel_aarch64/Image.lz4 ./
  358. # Create gzip of the Image file
  359. gzip -n -k -f -9 ./Image > ./Image.gz
  360. - name: Create ZIP Files for Different Formats
  361. run: |
  362. echo "Creating zip files for all formats..."
  363. cd ./AnyKernel3
  364. # Create and upload zip for each format
  365. ZIP_NAME="${{ inputs.kernelsu_variant }}-${{ inputs.android_version }}-${{ inputs.kernel_version }}.${{ inputs.sub_level }}-${{ inputs.os_patch_level }}-AnyKernel3.zip"
  366. echo "Creating zip file: $ZIP_NAME..."
  367. mv ../Image ./Image
  368. zip -r "../$ZIP_NAME" ./*
  369. rm ./Image
  370. ZIP_NAME="${{ inputs.kernelsu_variant }}-${{ inputs.android_version }}-${{ inputs.kernel_version }}.${{ inputs.sub_level }}-${{ inputs.os_patch_level }}-AnyKernel3-lz4.zip"
  371. echo "Creating zip file: $ZIP_NAME..."
  372. mv ../Image.lz4 ./Image.lz4
  373. zip -r "../$ZIP_NAME" ./*
  374. rm ./Image.lz4
  375. ZIP_NAME="${{ inputs.kernelsu_variant }}-${{ inputs.android_version }}-${{ inputs.kernel_version }}.${{ inputs.sub_level }}-${{ inputs.os_patch_level }}-AnyKernel3-gz.zip"
  376. echo "Creating zip file: $ZIP_NAME..."
  377. mv ../Image.gz ./Image.gz
  378. zip -r "../$ZIP_NAME" ./*
  379. rm ./Image.gz
  380. - name: Android 12 boot image build script
  381. if: ${{ inputs.android_version == 'android12' }}
  382. run: |
  383. echo "Changing to configuration directory: $CONFIG..."
  384. cd bootimgs
  385. GKI_URL=https://dl.google.com/android/gki/gki-certified-boot-android12-5.10-"${{ inputs.os_patch_level }}"_"${{ inputs.revision }}".zip
  386. FALLBACK_URL=https://dl.google.com/android/gki/gki-certified-boot-android12-5.10-2023-01_r1.zip
  387. # Check if the GKI URL is available
  388. echo "Checking if GKI kernel URL is reachable: $GKI_URL"
  389. status=$(curl -sL -w "%{http_code}" "$GKI_URL" -o /dev/null)
  390. if [ "$status" = "200" ]; then
  391. echo "[+] Downloading from GKI_URL"
  392. curl -Lo gki-kernel.zip "$GKI_URL"
  393. else
  394. echo "[+] $GKI_URL not found, using $FALLBACK_URL"
  395. curl -Lo gki-kernel.zip "$FALLBACK_URL"
  396. fi
  397. # Unzip the downloaded kernel and remove the zip
  398. echo "Unzipping the downloaded kernel..."
  399. unzip gki-kernel.zip && rm gki-kernel.zip
  400. echo "Unpacking boot.img..."
  401. FULL_PATH=$(pwd)/boot-5.10.img
  402. echo "Unpacking using: $FULL_PATH"
  403. echo "Running unpack_bootimg.py..."
  404. $UNPACK_BOOTIMG --boot_img="$FULL_PATH"
  405. # Create gzip of the Image file
  406. gzip -n -k -f -9 ./Image > ./Image.gz
  407. echo "Building boot.img"
  408. $MKBOOTIMG --header_version 4 --kernel Image --output boot.img --ramdisk out/ramdisk --os_version 12.0.0 --os_patch_level "${{ inputs.os_patch_level }}"
  409. $AVBTOOL add_hash_footer --partition_name boot --partition_size $((64 * 1024 * 1024)) --image boot.img --algorithm SHA256_RSA2048 --key $BOOT_SIGN_KEY_PATH
  410. cp ./boot.img ../${{ inputs.kernelsu_variant }}-${{ inputs.android_version }}-${{ inputs.kernel_version }}.${{ inputs.sub_level }}-${{ inputs.os_patch_level }}-boot.img
  411. echo "Building boot-gz.img"
  412. $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 }}"
  413. $AVBTOOL add_hash_footer --partition_name boot --partition_size $((64 * 1024 * 1024)) --image boot-gz.img --algorithm SHA256_RSA2048 --key $BOOT_SIGN_KEY_PATH
  414. cp ./boot-gz.img ../${{ inputs.kernelsu_variant }}-${{ inputs.android_version }}-${{ inputs.kernel_version }}.${{ inputs.sub_level }}-${{ inputs.os_patch_level }}-boot-gz.img
  415. echo "Building boot-lz4.img"
  416. $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 }}"
  417. $AVBTOOL add_hash_footer --partition_name boot --partition_size $((64 * 1024 * 1024)) --image boot-lz4.img --algorithm SHA256_RSA2048 --key $BOOT_SIGN_KEY_PATH
  418. cp ./boot-lz4.img ../${{ inputs.kernelsu_variant }}-${{ inputs.android_version }}-${{ inputs.kernel_version }}.${{ inputs.sub_level }}-${{ inputs.os_patch_level }}-boot-lz4.img
  419. - name: Android 13/14/15 boot image build script
  420. if: ${{ inputs.android_version == 'android13' || inputs.android_version == 'android14' || inputs.android_version == 'android15' }}
  421. run: |
  422. cd bootimgs
  423. # Create gzip of the Image file
  424. gzip -n -k -f -9 ./Image > ./Image.gz
  425. echo "Building boot.img"
  426. $MKBOOTIMG --header_version 4 --kernel Image --output boot.img
  427. $AVBTOOL add_hash_footer --partition_name boot --partition_size $((64 * 1024 * 1024)) --image boot.img --algorithm SHA256_RSA2048 --key $BOOT_SIGN_KEY_PATH
  428. cp ./boot.img ../${{ inputs.kernelsu_variant }}-${{ inputs.android_version }}-${{ inputs.kernel_version }}.${{ inputs.sub_level }}-${{ inputs.os_patch_level }}-boot.img
  429. echo "Building boot-gz.img"
  430. $MKBOOTIMG --header_version 4 --kernel Image.gz --output boot-gz.img
  431. $AVBTOOL add_hash_footer --partition_name boot --partition_size $((64 * 1024 * 1024)) --image boot-gz.img --algorithm SHA256_RSA2048 --key $BOOT_SIGN_KEY_PATH
  432. cp ./boot-gz.img ../${{ inputs.kernelsu_variant }}-${{ inputs.android_version }}-${{ inputs.kernel_version }}.${{ inputs.sub_level }}-${{ inputs.os_patch_level }}-boot-gz.img
  433. echo "Building boot-lz4.img"
  434. $MKBOOTIMG --header_version 4 --kernel Image.lz4 --output boot-lz4.img
  435. $AVBTOOL add_hash_footer --partition_name boot --partition_size $((64 * 1024 * 1024)) --image boot-lz4.img --algorithm SHA256_RSA2048 --key $BOOT_SIGN_KEY_PATH
  436. cp ./boot-lz4.img ../${{ inputs.kernelsu_variant }}-${{ inputs.android_version }}-${{ inputs.kernel_version }}.${{ inputs.sub_level }}-${{ inputs.os_patch_level }}-boot-lz4.img
  437. - name: Compress all img files with gzip
  438. run: |
  439. for image in *.img; do
  440. gzip -vnf9 "$image"
  441. done
  442. - name: Upload Build Artifacts
  443. uses: actions/upload-artifact@v4
  444. with:
  445. name: ${{ inputs.kernelsu_variant }}-kernel-${{ env.CONFIG }}
  446. path: |
  447. *.zip
  448. *.img.gz
  449. *Image*