Kernel Builder #43
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: Kernel Builder | |
on: | |
workflow_dispatch: | |
inputs: | |
MANIFEST_URL: | |
description: 'Kernel Manifest' | |
required: true | |
default: 'https://github.com/cd-Crypton/android_kernel-manifest' | |
MANIFEST_BRANCH: | |
description: 'Kernel Manifest Branch' | |
required: true | |
default: 'realme/sm6225' | |
BUILD_CONFIG: | |
description: 'Customized build.config file' | |
required: true | |
default: 'sm6225/build.config.sm6225' | |
KERNEL_IMAGE_NAME: | |
description: 'Image, Image.gz, Image.gz-dtb, etc.' | |
required: true | |
default: 'Image.gz' | |
ANYKERNEL3: | |
description: 'Make flashable AnyKernel3 zip' | |
type: boolean | |
required: true | |
default: false | |
jobs: | |
build: | |
name: Build Kernel by ${{ github.actor }} | |
runs-on: ubuntu-20.04 | |
if: github.event.repository.owner.id == github.event.sender.id | |
permissions: | |
contents: write | |
steps: | |
# This action checks-out your repository under $GITHUB_WORKSPACE, so your workflow can access it. | |
- name: Checkout | |
uses: actions/checkout@v4 | |
# Install necessary packages for building android kernel | |
- name: Build Environment | |
run: | | |
sudo apt update -y | |
sudo apt install bison flex rsync bison device-tree-compiler bc -y | |
# Install repo tool in case it was not yet installed | |
- name: Install Repo Tool | |
run: | | |
git config --global color.ui false | |
if ! command -v repo &> /dev/null; then | |
echo "'repo' command not found. Installing..." | |
mkdir -p ~/bin # Create bin directory if it doesn't exist | |
curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo | |
chmod a+x ~/bin/repo | |
sudo ln -sf ~/bin/repo /usr/bin/repo | |
echo "'repo' command installed successfully." | |
else | |
echo "'repo' command already exists." | |
fi | |
# Initial the kernel manifest then sync after | |
- name: Initialize Manifest and Sync | |
run: | | |
mkdir -p android | |
cd android | |
git config --global user.name "${{ github.actor }}" | |
git config --global user.email "${{ github.actor_id }}+${{ github.actor }}@users.noreply.github.com" | |
repo init --depth=1 -u ${{ inputs.MANIFEST_URL }} -b ${{ inputs.MANIFEST_BRANCH }} | |
repo sync | |
# Starts the compiling process of android kernel | |
- name: Build Kernel | |
run: | | |
cd android | |
BUILD_CONFIG="${{ inputs.BUILD_CONFIG }}" build/build.sh 2>&1 | tee build.log | |
# Check if the out directory consist of target kernel image | |
- name: Setup kernel and modules | |
continue-on-error: true | |
run: | | |
mkdir -p android/kernelbuild | |
mkdir -p android/modulebuild | |
cp -nf $(find android/out -name '${{ inputs.KERNEL_IMAGE_NAME }}') android/kernelbuild/ 2>/dev/null | |
cp -nf $(find android/out -name '*.ko') android/modulebuild/ 2>/dev/null | |
cd android/kernelbuild && ls && cd ../.. | |
cd android/modulebuild && ls && cd ../.. | |
# If true, create a flashable zip | |
- name: Make a flashable zip file | |
if: inputs.ANYKERNEL3 == true | |
run: | | |
cd android && rm -rf AnyKernel3 | |
git clone https://github.com/osm0sis/AnyKernel3 -b master | |
cd AnyKernel3 && rm -rf anykernel.sh && cd ../.. | |
mv script/anykernel.sh android/AnyKernel3/ 2>/dev/null | |
cp -rf android/kernelbuild/${{ inputs.KERNEL_IMAGE_NAME }} android/AnyKernel3/ | |
cp -rf android/modulebuild/* android/AnyKernel3/modules/system/lib/modules/ | |
cd android/AnyKernel3 | |
zip -r9 UPDATE-AnyKernel3.zip * -x .git README.md *placeholder | |
# Upload the release, if build is successful | |
- name: Upload to Release | |
uses: softprops/action-gh-release@v1 | |
with: | |
files: | | |
android/kernelbuild/${{ inputs.KERNEL_IMAGE_NAME }} | |
android/AnyKernel3/UPDATE-AnyKernel3.zip | |
name: Android Kernel Release | ${{ github.run_id }} | |
tag_name: ${{ github.run_id }} | |
body: | | |
## Build Information | |
Manifest: ${{ inputs.MANIFEST_URL }}/tree/${{ inputs.MANIFEST_BRANCH }} |