build.yml 25 KB

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