Build Kernel #2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build Kernel | |
on: | |
workflow_dispatch: | |
inputs: | |
PROTON_RELEASE: | |
description: 'Release tag' | |
required: true | |
default: 'master' | |
KERNEL_TREE: | |
description: 'Kernel tree URL' | |
required: true | |
default: 'https://github.com/cd-Crypton/android_kernel_realme_sm6225' | |
KERNEL_BRANCH: | |
description: 'Kernel tree Branch' | |
required: true | |
default: 'android13-staging' | |
KERNEL_DEFCONFIG: | |
description: 'Kernel defconfig' | |
required: true | |
default: 'vendor/bengal-perf_defconfig' | |
KERNEL_IMAGE_NAME: | |
description: 'Kernel image name' | |
required: true | |
default: 'Image.gz' | |
jobs: | |
build: | |
name: Build Kernel by ${{ github.actor }} | |
runs-on: ubuntu-latest | |
if: github.event.repository.owner.id == github.event.sender.id | |
permissions: | |
contents: write | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Packages | |
run: | | |
sudo apt-get update | |
sudo apt-get install git ccache automake flex lzop bison gperf build-essential zip curl zlib1g-dev g++-multilib libxml2-utils bzip2 libbz2-dev libbz2-1.0 libghc-bzlib-dev squashfs-tools pngcrush schedtool dpkg-dev liblz4-tool make optipng maven libssl-dev pwgen libswitch-perl policycoreutils minicom libxml-sax-base-perl libxml-simple-perl bc libc6-dev-i386 lib32ncurses5-dev libx11-dev lib32z-dev libgl1-mesa-dev xsltproc unzip device-tree-compiler python2 python3 device-tree-compiler | |
- name: Setup Proton | |
run: | | |
mkdir -p android && cd android | |
git config --global advice.detachedHead false | |
git clone --depth=1 https://github.com/kdrag0n/proton-clang -b ${{ github.event.inputs.PROTON_RELEASE }} ./toolchains/proton-clang | |
- name: Clone Kernel Tree | |
run: | | |
cd android | |
git clone --depth=1 ${{ github.event.inputs.KERNEL_TREE }} -b ${{ github.event.inputs.KERNEL_BRANCH }} ./kernel | |
- name: Set Properties | |
run: | | |
echo "MAKE=$(cat make.txt)" >> $GITHUB_ENV | |
echo "BUILD_DATE=$(TZ=Asia/Manila date +%Y%m%d)" >> $GITHUB_ENV | |
- name: Build Kernel | |
run: | | |
PATH="${GITHUB_WORKSPACE}/android/toolchains/proton-clang/bin:/bin:$PATH" | |
cd android/kernel | |
${{ env.MAKE }} ${{ github.event.inputs.KERNEL_DEFCONFIG }} | |
${{ env.MAKE }} -j"$(nproc --all)" | |
- name: Check Kernel | |
run: | | |
cd android | |
if [ -f kernel/out/arch/arm64/boot/${{ github.event.inputs.KERNEL_IMAGE_NAME }} ]; then | |
echo "KERNEL_IS_OK=true" >> $GITHUB_ENV | |
echo "KERNEL_VERSION=$(cat kernel/out/include/config/kernel.release)" >> $GITHUB_ENV | |
else | |
echo "Kernel out directory is empty. Maybe(?) your name input did not exist at all. Try other kernel name." | |
exit 1 | |
fi | |
- name: Compress Kernel | |
if: env.KERNEL_IS_OK == 'true' | |
run: | | |
cd android | |
git clone --depth=1 https://github.com/cd-Crypton/AnyKernel3.git -b FOR-ALL | |
cd kernel/out/arch/arm64/boot && cp -r ${{ github.event.inputs.KERNEL_IMAGE_NAME }} ${GITHUB_WORKSPACE}/android/AnyKernel3 | |
cd ${GITHUB_WORKSPACE}/android/AnyKernel3 | |
zip -r9 UPDATE-AnyKernel3-${{ env.BUILD_DATE }}.zip * -x .git README.md *placeholder | |
- name: Upload to Release | |
if: env.KERNEL_IS_OK == 'true' | |
uses: softprops/action-gh-release@v1 | |
with: | |
files: | | |
android/kernel/out/arch/arm64/boot/${{ github.event.inputs.KERNEL_IMAGE_NAME }} | |
android/AnyKernel3/UPDATE-AnyKernel3-${{ env.BUILD_DATE }}.zip | |
name: Proton Kernel Build | ${{ env.KERNEL_VERSION }} | ${{ env.BUILD_DATE }} | |
tag_name: ${{ github.run_id }} | |
body: | | |
### Notes | |
* Kernel were built/compiled using proton-clang. | |
* Test at your own risk. | |
* Use kernel flasher or any custom recoveries to flash the compressed kernel zip file. |