English | 中文
This Github Action helps you build kernels. It reads multiple kernel sources from a configuration file and builds them using different toolchains. Additionally, it supports patching the kernel with KernelSU and uploading the built kernel image.
Configure
Quick Start
Local testing
This action contains two jobs: Set-repos
and Build-Kernel
.
The Set-repos
job reads the kernel sources from the configuration file and outputs them to the Build-Kernel
job. The Build-Kernel
job uses the outputted kernel sources to build the kernels and upload the built kernel images.
Event name | Description |
---|---|
workflow_dispatch | Manually run |
Step | Description |
---|---|
Install prerequisites | Install the necessary dependencies for building the kernel |
Setup Anykernel3 | Clone the Anykernel3 repository to prepare for packaging the kernel |
Clone kernel source | Clone the kernel source code repository for the Android device |
Get toolchains | Obtain the required cross-compilation toolchains for building the kernel |
Set args | Set the necessary build parameters for the kernel |
Update KernelSU | Update the KernelSU tool to ensure compatibility with the new kernel |
Make defconfig | Generate the kernel configuration file |
Build kernel | Compile the kernel source code to create the kernel image |
Upload Image | Upload the kernel image file to a designated location |
Upload Image.gz | Upload the compressed kernel image file to a designated location |
Upload dtb | Upload the device tree blob file to a designated location |
Upload dtbo.img | Upload the device tree overlay image file to a designated location |
Pack AnyKernel3.zip | Package the kernel image and device tree files into an Anykernel3 zip file |
Upload AnyKernel3 image | Upload the Anykernel3 zip file to a designated location |
Create GitHub Release | Create a new release on GitHub to share the kernel with the community |
Example configuration file
[
{
"kernelSource": {
"name": "DogDay-KernelSU-Proton-release",
"repo": "https://codeberg.org/DogDayAndroid/android_kernel_xiaomi_thyme",
"branch": "lineage-20.0",
"device": "thyme",
"defconfig": "thyme_defconfig"
},
"withKernelSU": true,
"toolchains": [
{
"repo": "https://github.com/kdrag0n/proton-clang",
"branch": "master",
"name": "proton-clang",
"binPath": ["bin"]
}
],
"ccache":false,
"params": {
"ARCH": "arm64",
"CC": "proton-clang/bin/clang",
"externalCommand": {
"CROSS_COMPILE": "proton-clang/bin/aarch64-linux-gnu-",
"CROSS_COMPILE_ARM32": "proton-clang/bin/arm-linux-gnueabi-",
"LD": "proton-clang/bin/ld.lld",
"AR": "proton-clang/bin/llvm-ar",
"NM": "proton-clang/bin/llvm-nm",
"OBJCOPY": "proton-clang/bin/llvm-objcopy",
"OBJDUMP": "proton-clang/bin/llvm-objdump",
"READELF": "proton-clang/bin/llvm-readelf",
"OBJSIZE": "proton-clang/bin/llvm-size",
"STRIP": "proton-clang/bin/llvm-strip",
"LDGOLD": "proton-clang/bin/aarch64-linux-gnu-ld.gold",
"LLVM_AR": "proton-clang/bin/llvm-ar",
"LLVM_DIS": "proton-clang/bin/llvm-dis"
}
},
"AnyKernel3": {
"use": true,
"release": true,
"repo": "https://github.com/easterNday/AnyKernel3/",
"branch": "thyme"
}
},
{
"kernelSource": {
"name": "DogDay-KernelSU-Proton-noanykernel-release",
"repo": "https://codeberg.org/DogDayAndroid/android_kernel_xiaomi_thyme",
"branch": "lineage-20.0",
"device": "thyme",
"defconfig": "thyme_defconfig"
},
"withKernelSU": true,
"toolchains": [
{
"repo": "https://github.com/kdrag0n/proton-clang",
"branch": "master",
"name": "proton-clang",
"binPath": ["bin"]
}
],
"ccache":true,
"params": {
"ARCH": "arm64",
"CC": "proton-clang/bin/clang",
"externalCommand": {
"CROSS_COMPILE": "proton-clang/bin/aarch64-linux-gnu-",
"CROSS_COMPILE_ARM32": "proton-clang/bin/arm-linux-gnueabi-",
"LD": "proton-clang/bin/ld.lld",
"AR": "proton-clang/bin/llvm-ar",
"NM": "proton-clang/bin/llvm-nm",
"OBJCOPY": "proton-clang/bin/llvm-objcopy",
"OBJDUMP": "proton-clang/bin/llvm-objdump",
"READELF": "proton-clang/bin/llvm-readelf",
"OBJSIZE": "proton-clang/bin/llvm-size",
"STRIP": "proton-clang/bin/llvm-strip",
"LDGOLD": "proton-clang/bin/aarch64-linux-gnu-ld.gold",
"LLVM_AR": "proton-clang/bin/llvm-ar",
"LLVM_DIS": "proton-clang/bin/llvm-dis"
}
},
"AnyKernel3": {
"use": false,
"release": true,
"repo": "https://github.com/easterNday/AnyKernel3/",
"branch": "thyme"
}
},
{
"kernelSource": {
"name": "DogDay-KernelSU-Proton-anykernel-norelease",
"repo": "https://codeberg.org/DogDayAndroid/android_kernel_xiaomi_thyme",
"branch": "lineage-20.0",
"device": "thyme",
"defconfig": "thyme_defconfig"
},
"withKernelSU": false,
"toolchains": [
{
"repo": "https://github.com/kdrag0n/proton-clang",
"branch": "master",
"name": "proton-clang",
"binPath": ["bin"]
}
],
"ccache":true,
"params": {
"ARCH": "arm64",
"CC": "proton-clang/bin/clang",
"externalCommand": {
"CROSS_COMPILE": "proton-clang/bin/aarch64-linux-gnu-",
"CROSS_COMPILE_ARM32": "proton-clang/bin/arm-linux-gnueabi-",
"LD": "proton-clang/bin/ld.lld",
"AR": "proton-clang/bin/llvm-ar",
"NM": "proton-clang/bin/llvm-nm",
"OBJCOPY": "proton-clang/bin/llvm-objcopy",
"OBJDUMP": "proton-clang/bin/llvm-objdump",
"READELF": "proton-clang/bin/llvm-readelf",
"OBJSIZE": "proton-clang/bin/llvm-size",
"STRIP": "proton-clang/bin/llvm-strip",
"LDGOLD": "proton-clang/bin/aarch64-linux-gnu-ld.gold",
"LLVM_AR": "proton-clang/bin/llvm-ar",
"LLVM_DIS": "proton-clang/bin/llvm-dis"
}
},
"AnyKernel3": {
"use": true,
"release": false,
"repo": "https://github.com/easterNday/AnyKernel3/",
"branch": "thyme"
}
}
]
Individual Configuration Template
{
"kernelSource": {
"name": "",
"repo": "",
"branch": "",
"device": "",
"defconfig": ""
},
"withKernelSU": false,
"toolchains": [
{
"repo": "",
"branch": "",
"name": "",
"binPath": []
}
],
"ccache":false,
"params": {
"ARCH": "",
"CC": "",
"externalCommand": {}
},
"AnyKernel3": {
"use": false,
"release": false,
"repo": "",
"branch": ""
}
}
In general, there are the following fields:
Field Name | Description |
---|---|
kernelSource | Information about the kernel source code, including name, repository address, branch, and device type. |
withKernelSU | A boolean value indicating whether the KernelSU was used. |
toolchains | An array containing information about the toolchains needed, including repository address, branch, and name. |
ccache | A boolean value indicating whether the ccache tool was used to speed up compile. |
params | An object containing information about the build parameters, including architecture type, cross-compiler, compiler, etc. |
AnyKernel3 | An object containing information about building the kernel flash package, including the AnyKernel3 repository address, branch, etc. |
Kernel Source Parameter | Type | Description | Explanation |
---|---|---|---|
name |
String | Kernel Name | Customized, will be used in the release. |
repo |
String | Kernel Source Repository Address | The git repository address of the kernel source code. |
branch |
String | Kernel Source Branch | The specified branch of the repository. |
device |
String | Device Code | The device code or name to be compiled, will be used in the release. |
defconfig |
String | Kernel Configuration File Name | The prefix of the corresponding defconfig file to be compiled, for example, if the defconfig file is thyme_defconfig , fill in thyme . |
This is an array that contains many repository objects of cross-compilation toolchains, and the parameter description of each configuration object is as follows:
Toolchain Parameter | Type | Description | Explanation |
---|---|---|---|
repo |
String | Toolchain Repository Address | The git repository address of the toolchain. |
branch |
String | Toolchain Branch | The specified branch of the repository. |
url |
String | Toolchain Download Url | The download url of the toolchain. |
name |
String | Toolchain Name | The name of the folder cloned locally, customized. |
binPath |
Array | Toolchain Binary File Path | The path of the bin file used during compilation (relative to the path of the cloned folder). It will be converted to an absolute path during parameter setting when compiling. |
Therefore, you can use the following forms to obtain the compilation toolchain:
"toolchains": [
{
"repo": "https://github.com/kdrag0n/proton-clang",
"branch": "master",
"name": "proton-clang",
"binPath": ["./bin"]
}
]
In this way, you can get the compiled toolchain compressed package in .zip
| .tar
| .tar.gz
| .rar
format.
"toolchains": [
{
"url": "https://android.googlesource.com/platform/prebuilts/clang/host/linux-x86/+archive/refs/heads/master-kernel-build-2022/clang-r450784d.tar.gz",
"name": "clang",
"binPath": ["./bin"]
},
{
"url": "https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9/+archive/refs/tags/android-12.1.0_r27.tar.gz",
"name": "gcc",
"binPath": ["bin"]
}
]
"toolchains": [,
{
"repo": "https://gitlab.com/ThankYouMario/android_prebuilts_clang-standalone/",
"branch": "11",
"name": "clang",
"binPath": ["bin"]
},
{
"url": "https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9/+archive/refs/tags/android-12.1.0_r27.tar.gz",
"name": "gcc",
"binPath": ["bin"]
}
]
Compilation Parameter | Type | Description | Explanation |
---|---|---|---|
ARCH |
String | Architecture | The architecture of the device, which can be queried using uname -m . |
CC |
String | C Compiler Path | The compiler used, usually clang or gcc . |
externalCommand |
Object | External Command Path | Additional parameter settings required for compilation. |
For the externalCommand
part, here is an example of the command that may be used during compilation:
make -j$(nproc --all) \
O=out \
ARCH=arm64 \
CC=clang \
CLANG_TRIPLE=aarch64-linux-gnu- \
CROSS_COMPILE=aarch64-linux-gnu- \
CROSS_COMPILE_ARM32=arm-linux-gnueabi-
The -j
and O=out
parts will be automatically configured by the compilation script, and the ARCH
and CC
parts correspond to the above configuration. The other parts correspond to the externalCommand
part, so the corresponding configuration for the toolchains part should be:
"params": {
"ARCH": "arm64",
"CC": "clang",
"externalCommand": {
"CLANG_TRIPLE": "aarch64-linux-gnu-",
"CROSS_COMPILE": "proton-clang/bin/aarch64-linux-gnu-",
"CROSS_COMPILE_ARM32": "proton-clang/bin/arm-linux-gnueabi-"
}
}
AnyKernel3 Parameter | Type | Description | Explanation |
---|---|---|---|
use |
Boolean | Whether to use AnyKernel3 | If set to false , the corresponding kernel flashing package will not be packaged |
release |
Boolean | Whether it is a release version | Only effective when use is set to true . If set to false , the corresponding kernel flashing package will not be released |
repo |
String | AnyKernel3 repository address | The repository address of the Anykernel3 used |
branch |
String | AnyKernel3 branch | The specified branch of the corresponding repository |
This project's basic usage is as follows:
-
Fork this project on GitHub.
-
Modify the
repos/repos*.json
file through the Github website or pull it to your local machine and commit the changes. -
Go to the
Action
page on Github and findBuild kernels
, thenRun workflow
. -
Wait for the compilation to finish, then download the compiled product from the corresponding page.
-
Use your preferred packaging software to package the kernel (AnyKernel3, Android-Image-Kitchen, MagiskBoot, etc.)
If you don't want to run the action on Github
, you can use nektos/act to test this workflow locally and output the files.
This is the recommended local testing process. Simply install nektos/act and run the following command:
# Collect artifacts to /tmp/artifacts folder:
act --artifact-server-path /tmp/artifacts
If you want to store the artifacts in a different location, change /tmp/artifacts
to your preferred directory.
If there are errors, use the -v
flag to generate an error report and submit an issue. Here's the command:
# Collect artifacts to /tmp/artifacts folder:
act --artifact-server-path /tmp/artifacts -v
If you need to perform a completely local build, consider building as follows:
-
Set up a local
Gitea
orGitlab
Git service and modify the configuration file address to point to the local service address. -
Use
git daemon
to create a secondary image locally.
This is just a suggestion, and we do not provide a specific guide.
- Use
MagiskBoot
to generateboot.img
- Web page for configuring profiles
- weishu : Developer of KernelSU
- AKR Android Developer Community : Provides build tutorials
- DogDayAndroid/KSU_Thyme_BuildBot : Predecessor of this project
- xiaoleGun/KernelSU_Action : Drawing on some Github Actions
- UtsavBalar1231/Drone-scripts : Drawing on some Github Actions
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.