README.md

April 3, 2026 · View on GitHub

Android Kernel Build Action

Powered By GitHub Actions

A workflow to automatically build an Android kernel

Security Policy

See Security.md for more details.

How to use?

  • First, you need to determine the kernel source code and configuration files.
  • Find your kernel source repository and configure the workflow file according to the following example and README.md:
name: CI

on:
  workflow_dispatch:

permissions:
  contents: write

jobs:
  build-kernel:
    name: Build Kernel
    runs-on: ubuntu-22.04
    steps:
      - name: Build
        uses: dabao1955/kernel_build_action@main
        with:
          kernel-url: https://github.com/AcmeUI-Devices/android_kernel_xiaomi_cas
          kernel-branch: taffy
          config: cas_defconfig
          arch: arm64
          aosp-gcc: true
          aosp-clang: true
          android-version: 12
          aosp-clang-version: r383902
          anykernel3: true
          release: true
          access-token: ${{ secrets.GITHUB_TOKEN }}

Using Local Kernel Source

You can also use a local or relative path for the kernel source instead of cloning from a remote URL. This is useful when the kernel source is already checked out in the workflow.

name: CI

on:
  workflow_dispatch:

permissions:
  contents: write

jobs:
  build-kernel:
    name: Build Kernel
    runs-on: ubuntu-22.04
    steps:
      - name: Checkout kernel source
        uses: actions/checkout@v4
        with:
          repository: username/kernel_repo
          ref: main
          path: kernel/source

      - name: Build
        uses: dabao1955/kernel_build_action@main
        with:
          kernel-url: ./kernel/source/
          config: defconfig
          arch: arm64
          aosp-clang: true
          anykernel3: true

Note

  • Local paths must end with / (except . for current directory)
  • Supported formats: ., ./, ./kernel/, ../kernel/, kernel/source/
  • The directory must be a valid kernel source containing: Makefile (with VERSION), Kconfig, and arch/ directory
  • When using local path, kernel-branch, depth, and kernel-dir options are ignored

Or use the preset workflow file to modify it.

Note

You do not need to fork this repository.

If you just want to compile the kernel, please do not submit PR after modification!

  • Finally, run the workflow you just wrote.

Inputs

inputrequireddescriptionexample value
kernel-urltrueURL of the Android kernel source code, or local/relative path. Local paths must end with / (except .). Supports: ., ./, ./kernel/, ../kernel/, kernel/source/https://github.com/username/project
kernel-dirfalseDirectory name for kernel source. Useful for OnePlus kernel sourceskernel
depthfalseUse git clone depth to save time and storage space1
vendorfalseEnable vendor kernel source codefalse
vendor-urlfalseURL of vendor kernel source code (used on OnePlus kernel)https://github.com/username/project
vendor-dirfalseDirectory name for vendor kernel sourcevendor
kernel-branchfalseBranch name of kernel source code (default = main)main
vendor-branchfalseBranch name of vendor kernel source code (default = main)main
configtrueSpecific kernel config file to compile (default = defconfig)defconfig
archtrueCPU architecture (default = arm64)arm64
android-versiontrueAndroid version for AOSP toolchain (Ignore if you want to use latest AOSP clang or use other clang)12
ksufalseIntegrate KernelSU on kernel buildtrue
ksu-versionfalseKernelSU version (default = v0.9.5)v0.9.5
ksu-lkmfalseBuild KernelSU as kernel module (may fail on non-GKI devices)true
ksu-otherfalseUse third-party KernelSU forkfalse
ksu-urlfalseURL of third-party KernelSU fork (if you enable ksu-other flag)https://github.com/username/KernelSU/
rekernelfalseEnable Re-Kernel supporttrue
disable-ltofalseDisable Link Time Optimization supportfalse
lxcfalseEnable LXC/Docker supportfalse
lxc-patchfalseApply patch to avoid boot issues with LXCfalse
nethunterfalseEnable Kali NetHunter supportfalse
nethunter-patchfalseApply patch for Kali NetHunter supportfalse
kvmfalseEnable KVM (Kernel Virtual Machine) supportfalse
bbgfalseEnable BaseBandGuard supportfalse
ccachefalseEnable ccache (clang only) to speed up kernel compilationfalse
aosp-gccfalseUse AOSP GCC toolchain to compile the kernel (Enable when using AOSP clang toolchain)false
other-gcc32-urlfalseURL of custom GCC arm32 toolchain (Supports .tar.gz, .tar.xz, .tar.bz2, .gz, .xz, .bz2, .zip and .git formats)https://github.com/username/gcc
other-gcc32-branchfalseBranch name of GCC arm32 toolchainmain
other-gcc64-urlfalseURL of custom GCC arm64 toolchain (Supports .tar.gz, .tar.xz, .tar.bz2, .gz, .xz, .bz2, .zip and .git formats)https://github.com/username/gcc
other-gcc64-branchfalseBranch name of GCC arm64 toolchainmain
aosp-clangfalseUse AOSP clang toolchain to compile the kernelfalse
aosp-clang-versionfalseAOSP clang version. See all AOSP clang versions. (default = r383902)r383902
other-clang-urlfalseURL of custom clang toolchain (Supports .tar.gz, .tar.xz, .tar.bz2, .gz, .xz, .bz2, .zip and .git formats)https://github.com/username/clang
other-clang-branchfalseBranch name of clang toolchainmain
anykernel3falseUse AnyKernel3 to package the compiled kernel. (if false, must provide bootimg-url)false
anykernel3-urlfalseURL for third-party AnyKernel3https://github.com/username/AnyKernel3
releasefalseAuto-publish kernel release after buildtrue
access-tokenfalseGitHub access token (needed for auto release)ghp_xxxxxx
bootimg-urlfalseURL to download local boot.img (required if anykernel3 = false)https://127.0.0.1/boot.img
extra-make-argsfalseExtra arguments for make, as a JSON array of strings support spaces and special characters["LOCALVERSION= (CI)", "AS=llvm-as"]

FAQ

Caution

Please Read this first if you have some questions!

How to use 3rd clang?

You should disable aosp-clang and android-ndk options to use it.

Why KernelSU version built with this action is still v0.9.5?

See KernelSU 's release note for more details.

How to submit issue about features requests?

In principle, it only accepts Bug Reports and does not accept external Feature Requests; if you want new features, you are welcome to submit a Pull Request. We will still develop new features that we think are useful.

Why the workflow exits with a code with an error value of some number?

  • If you get an error while downloading the toolchain or pulling the source code, please check whether your option or source code address is legitimate.
  • If you encounter problems during compilation, consider replacing the source code or replacing the compiler.
  • If the action has a typo problem, PR welcome!

Build failed while using third-party GCC ?

Try add LLVM=1 option with clang.

Credits