|
| 1 | +name: Build Android Kernel then ship it in an AnyKernel3 flashable zip |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - b1c1 |
| 7 | + pull_request: |
| 8 | + branches: |
| 9 | + - b1c1 |
| 10 | + workflow_dispatch: |
| 11 | + |
| 12 | +jobs: |
| 13 | + build: |
| 14 | + runs-on: ubuntu-22.04 |
| 15 | + |
| 16 | + steps: |
| 17 | + - name: ⚡ Checkout kernel's sourcecode and clone submodules |
| 18 | + uses: actions/checkout@v4 |
| 19 | + with: |
| 20 | + submodules: recursive |
| 21 | + |
| 22 | + - name: 🔄 Update submodules |
| 23 | + run: | |
| 24 | + git submodule sync --recursive |
| 25 | + git submodule update --init --recursive |
| 26 | +
|
| 27 | + - name: 📥 Clone AnyKernel3 |
| 28 | + run: | |
| 29 | + git clone https://github.com/osm0sis/AnyKernel3.git anykernel |
| 30 | + rm -rf anykernel/.git |
| 31 | + |
| 32 | + - name: 📤 Restore cache - ccache |
| 33 | + uses: actions/cache@v4 |
| 34 | + with: |
| 35 | + path: .ccache |
| 36 | + key: kernel-auto-builder-ccache |
| 37 | + |
| 38 | + - name: 📦 Install dépendencies |
| 39 | + run: | |
| 40 | + sudo apt-get update -y -qq |
| 41 | + sudo apt-get install -y --no-install-recommends \ |
| 42 | + python3-pip \ |
| 43 | + git \ |
| 44 | + zip \ |
| 45 | + unzip \ |
| 46 | + gcc \ |
| 47 | + g++ \ |
| 48 | + make \ |
| 49 | + ninja-build \ |
| 50 | + file \ |
| 51 | + bc \ |
| 52 | + bison \ |
| 53 | + flex \ |
| 54 | + libfl-dev \ |
| 55 | + libssl-dev \ |
| 56 | + libelf-dev \ |
| 57 | + wget \ |
| 58 | + build-essential \ |
| 59 | + python3-dev \ |
| 60 | + python3-setuptools \ |
| 61 | + rsync \ |
| 62 | + ccache \ |
| 63 | + llvm-dev |
| 64 | + sudo apt install flex libncurses6 libncurses5 binutils-aarch64-linux-gnu device-tree-compiler \ |
| 65 | + android-sdk-libsparse-utils |
| 66 | +
|
| 67 | + - name: 🔧 Install Clang from a Github action |
| 68 | + uses: KyleMayes/install-llvm-action@v2 |
| 69 | + with: |
| 70 | + version: "18.1.8" |
| 71 | + directory: ${{ runner.temp }}/llvm |
| 72 | + |
| 73 | + - name: 🔧 Add Clang to the PATH |
| 74 | + run: | |
| 75 | + echo "${{ runner.temp }}/llvm/bin" >> $GITHUB_PATH |
| 76 | + |
| 77 | + - name: 🛠 Use repo's mkdtimg |
| 78 | + run: | |
| 79 | + chmod +x tools/mkdtimg |
| 80 | + sudo mv tools/mkdtimg /usr/local/bin/mkdtimg |
| 81 | +
|
| 82 | + |
| 83 | + - name: 🛠 ARM32 compiler for compatibility |
| 84 | + run: | |
| 85 | + sudo apt install -y gcc-arm-linux-gnueabi |
| 86 | + echo "CROSS_COMPILE_ARM32=arm-linux-gnueabi-" >> $GITHUB_ENV |
| 87 | +
|
| 88 | + - name: 🔍 Device's codename and kernel's version |
| 89 | + run: | |
| 90 | + DEVICE_CODENAME=blueline-crosshatch |
| 91 | + KERNEL_VERSION=$(make kernelversion) |
| 92 | +
|
| 93 | + echo "Device Codename: $DEVICE_CODENAME" |
| 94 | + echo "Kernel Version: $KERNEL_VERSION" |
| 95 | +
|
| 96 | + echo "DEVICE_CODENAME=$DEVICE_CODENAME" >> $GITHUB_ENV |
| 97 | + echo "KERNEL_VERSION=$KERNEL_VERSION" >> $GITHUB_ENV |
| 98 | +
|
| 99 | + - name: 🚀 Enable ccache to speed the build up |
| 100 | + uses: hendrikmuhs/ccache-action@v1.2 |
| 101 | + with: |
| 102 | + max-size: 7G |
| 103 | + |
| 104 | + - name: 🛠️ Build the kramel |
| 105 | + run: | |
| 106 | + export ARCH=arm64 |
| 107 | + export SUBARCH=arm64 |
| 108 | + export KBUILD_COMPILER_STRING=$(clang --version | head -n 1) |
| 109 | + export CCACHE_EXEC=$(which ccache) |
| 110 | + export KBUILD_BUILD_HOST="Github-actions-Onelots" |
| 111 | +
|
| 112 | + make O=out ARCH=arm64 b1c1_defconfig V=1 |
| 113 | + make O=out ARCH=arm64 olddefconfig |
| 114 | + make -j$(nproc --all) O=out -j"$(nproc --all)" \ |
| 115 | + ARCH=arm64 \ |
| 116 | + CC="ccache clang" \ |
| 117 | + LLVM=1 \ |
| 118 | + LLVM_IAS=1 \ |
| 119 | + CLANG_TRIPLE=aarch64-linux-gnu- \ |
| 120 | + CROSS_COMPILE=aarch64-linux-android- \ |
| 121 | + CROSS_COMPILE_ARM32=arm-linux-androideabi- |
| 122 | +
|
| 123 | + - name: ✍️ generate the anykernel.sh flashable zip |
| 124 | + run: | |
| 125 | + cat <<EOF > anykernel/anykernel.sh |
| 126 | + #!/bin/sh |
| 127 | + # AnyKernel3 Ramdisk Mod Script |
| 128 | + # osm0sis @ xda-developers |
| 129 | +
|
| 130 | + properties() { |
| 131 | + kernel.string="Kernel version ${KERNEL_VERSION} for ${DEVICE_CODENAME} by Onelots" |
| 132 | + do.devicecheck=1 |
| 133 | + do.initd=1 |
| 134 | + do.modules=1 |
| 135 | + do.cleanup=1 |
| 136 | + do.cleanuponabort=0 |
| 137 | + device.name1="blueline" |
| 138 | + device.name2="crosshatch" |
| 139 | + } |
| 140 | + kernel_install() { |
| 141 | + ui_print "Patching boot image..." |
| 142 | + replace_kernel |
| 143 | + } |
| 144 | + EOF |
| 145 | + |
| 146 | + chmod +x anykernel/anykernel.sh |
| 147 | +
|
| 148 | + - name: 🚀 Copy the compiled kernel to AnyKernel3 then create the zip |
| 149 | + run: | |
| 150 | + ZIP_NAME="Kernel-${DEVICE_CODENAME}-${KERNEL_VERSION}-$(date +%d%m%Y).zip" |
| 151 | +
|
| 152 | + cp out/arch/arm64/boot/Image.lz4 anykernel/ |
| 153 | +
|
| 154 | + cd anykernel && zip -r9 $ZIP_NAME ./* |
| 155 | + mv $ZIP_NAME ../ |
| 156 | +
|
| 157 | + echo "ZIP_NAME=$ZIP_NAME" >> $GITHUB_ENV |
| 158 | +
|
| 159 | + - name: 📤 Save the flashable zip |
| 160 | + uses: actions/upload-artifact@v4 |
| 161 | + with: |
| 162 | + name: ${{ env.ZIP_NAME }} |
| 163 | + path: ${{ env.ZIP_NAME }} |
0 commit comments