build.yml 25 KB

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