build.yml 25 KB

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