Kernel Build (alioth) - KSUNEXT ONLY clang-r547379 #13
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 Build (alioth) - KSUNEXT ONLY clang-r547379 | |
on: | |
pull_request: | |
workflow_dispatch: | |
inputs: | |
BUILD_TITLE: | |
description: 'Custom Build Title' | |
required: false | |
KERNEL_TREE: | |
description: 'Kernel Tree' | |
default: 'https://github.com/AlirezaParsi/pocof3' | |
required: true | |
KERNEL_TREE_BRANCH: | |
description: 'Kernel Tree Branch' | |
required: true | |
default: 'base' | |
CODENAME: | |
description: 'Phone Codename' | |
default: 'alioth' | |
required: true | |
ANYKERNEL_URL: | |
description: 'AnyKernel Url (leave blank if you dont want AnyKernel)' | |
default: 'https://github.com/AlirezaParsi/F3aosp' | |
required: false | |
ANYKERNEL_BRANCH: | |
description: 'AnyKernel Branch (defaults to codename)' | |
default: 'main' | |
required: false | |
SECOND_ANYKERNEL_URL: | |
description: 'secound AnyKernel Url (leave blank if you dont want AnyKernel)' | |
default: 'https://github.com/AlirezaParsi/hyperf3' | |
required: false | |
SECOND_ANYKERNEL_BRANCH: | |
description: 'Second AnyKernel Branch (defaults to codename)' | |
default: 'main' | |
required: false | |
UPLOAD_TO_RELEASE: | |
description: 'Upload to release' | |
type: boolean | |
default: false | |
jobs: | |
build: | |
if: github.event.repository.owner.id == github.event.sender.id | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
steps: | |
- name: Display User Inputs | |
run: | | |
echo "::group::User Environment Variables" | |
echo "Custom Build Title: ${{ github.event.inputs.BUILD_TITLE }}" | |
echo "Kernel Tree: ${{ github.event.inputs.KERNEL_TREE }}/tree/${{ github.event.inputs.KERNEL_TREE_BRANCH }}" | |
echo "Codename: ${{ github.event.inputs.CODENAME }}" | |
echo "AnyKernel Url: ${{ github.event.inputs.ANYKERNEL_URL }}/tree/${{ github.event.inputs.ANYKERNEL_BRANCH }}" | |
echo "Second AnyKernel Url: ${{ github.event.inputs.SECOND_ANYKERNEL_URL }}/tree/${{ github.event.inputs.SECOND_ANYKERNEL_BRANCH }}" | |
echo "::endgroup::" | |
- name: Initialize workspace | |
run: | | |
mkdir workspace | |
cd workspace | |
echo "workspace-folder=$(pwd)" >> $GITHUB_OUTPUT | |
echo "start_time=$(date +%s)" >> $GITHUB_OUTPUT | |
echo "build_title=${{ github.event.inputs.BUILD_TITLE || github.event.inputs.CODENAME }}" >> $GITHUB_OUTPUT | |
id: workspace | |
- name: Prepare the build environment | |
run: | | |
sudo apt install flex && sudo apt install libncurses6 | |
wget https://android.googlesource.com/platform/prebuilts/clang/host/linux-x86/+archive/refs/heads/main/clang-r547379.tar.gz -O clang.tar.gz | |
mkdir clang | |
tar -xf clang.tar.gz -C clang | |
echo "tools-folder=$(pwd)" >> $GITHUB_OUTPUT | |
working-directory: ${{ steps.workspace.outputs.workspace-folder }} | |
id: tools | |
- name: Clone kernel source | |
run: | | |
git clone --depth=1 ${{ github.event.inputs.KERNEL_TREE }} -b ${{ github.event.inputs.KERNEL_TREE_BRANCH }} kernel_tree | |
echo "kernel-folder=$(pwd)/kernel_tree" >> $GITHUB_OUTPUT | |
working-directory: ${{ steps.workspace.outputs.workspace-folder }} | |
id: kernel | |
- name: Building kernel | |
run: | | |
rm -rf KernelSU-Next | |
curl -LSs "https://raw.githubusercontent.com/rifsxd/KernelSU-Next/next/kernel/setup.sh" | bash -s next | |
export ARCH=arm64 | |
export SUBARCH=ARM64 | |
export KBUILD_BUILD_USER="aliza" | |
export KBUILD_BUILD_HOST="Github" | |
make O=out vendor/alioth_defconfig PATH="${{ steps.tools.outputs.tools-folder }}/clang/bin:$PATH" | |
make O=out CC=clang -j$(nproc --all) PATH="${{ steps.tools.outputs.tools-folder }}/clang/bin:$PATH" CROSS_COMPILE=aarch64-linux-gnu- LLVM=1 LLVM_IAS=1 | |
echo "elapsed_time=$(echo "$(date +%s)"-"${{ steps.workspace.outputs.start_time }}" | bc)" >> $GITHUB_OUTPUT | |
working-directory: ${{ steps.kernel.outputs.kernel-folder }} | |
id: build | |
- name: AnyKernel3 | |
if: ${{ success() && github.event.inputs.ANYKERNEL_URL != '' }} | |
run: | | |
if [[ -z "${{ github.event.inputs.ANYKERNEL_BRANCH }}" ]]; then | |
anykernel_branch=${{ github.event.inputs.CODENAME }} | |
else | |
anykernel_branch=${{ github.event.inputs.ANYKERNEL_BRANCH }} | |
fi | |
git clone --recursive --depth=1 ${{ github.event.inputs.ANYKERNEL_URL }} -b $anykernel_branch AnyKernel3 | |
# Check if Image.gz exists, then copy it to AnyKernel3 folder | |
if [ -e "Image.gz" ]; then | |
cp -f Image.gz AnyKernel3 | |
fi | |
# Check if dtb.img exists, then rename and copy it to AnyKernel3 folder | |
if [ -e "dtb.img" ]; then | |
cp -f dtb.img AnyKernel3/dtb | |
fi | |
# Check if dtbo.img exists, then copy it to AnyKernel3 folder | |
if [ -e "dtbo.img" ]; then | |
cp -f dtbo.img AnyKernel3 | |
fi | |
name=N0kernel-AOSP-KSUNEXTONlY-${{ github.event.inputs.CODENAME }}.zip | |
cd AnyKernel3 | |
zip -q -r $name * | |
mv $name ../ | |
echo "zipname=$name" >> $GITHUB_OUTPUT | |
working-directory: ${{ steps.kernel.outputs.kernel-folder }}/out/arch/arm64/boot/ | |
id: anykernel | |
- name: Second AnyKernel3 | |
if: ${{ success() && github.event.inputs.SECOND_ANYKERNEL_URL != '' }} | |
run: | | |
if [[ -z "${{ github.event.inputs.SECOND_ANYKERNEL_BRANCH }}" ]]; then | |
second_anykernel_branch=${{ github.event.inputs.CODENAME }} | |
else | |
second_anykernel_branch=${{ github.event.inputs.SECOND_ANYKERNEL_BRANCH }} | |
fi | |
git clone --recursive --depth=1 ${{ github.event.inputs.SECOND_ANYKERNEL_URL }} -b $second_anykernel_branch SecondAnyKernel | |
# Check if Image.gz exists, then copy it to SecondAnyKernel folder | |
if [ -e "Image.gz" ]; then | |
cp -f Image.gz SecondAnyKernel | |
fi | |
# Check if dtb.img exists, then rename and copy it to SecondAnyKernel folder | |
if [ -e "dtb.img" ]; then | |
cp -f dtb.img SecondAnyKernel/dtb | |
fi | |
second_name=N0kernel-HYPEROS-KSUNEXTONLY-${{ github.event.inputs.CODENAME }}.zip | |
cd SecondAnyKernel | |
zip -q -r $second_name * | |
mv $second_name ../ | |
echo "second_zipname=$second_name" >> $GITHUB_OUTPUT | |
working-directory: ${{ steps.kernel.outputs.kernel-folder }}/out/arch/arm64/boot/ | |
id: second_anykernel | |
- name: Upload to Release | |
if: ${{ github.event.inputs.UPLOAD_TO_RELEASE == 'true' }} | |
uses: softprops/action-gh-release@v2 | |
with: | |
files: | | |
${{ steps.kernel.outputs.kernel-folder }}/out/arch/arm64/boot/${{ steps.anykernel.outputs.zipname }} | |
${{ steps.kernel.outputs.kernel-folder }}/out/arch/arm64/boot/${{ steps.second_anykernel.outputs.second_zipname }} | |
name: ${{ github.event.inputs.CODENAME }}-${{ github.run_id }} | |
tag_name: ${{ github.run_id }} | |
body: | | |
<b>${{ steps.workspace.outputs.build_title }}</b> | |
<b>Kernel successfully built!</b>, took ${{ steps.build.outputs.elapsed_time }} seconds. | |
<b>Kernel tree</b>: ${{ github.event.inputs.KERNEL_TREE }}/tree/${{ github.event.inputs.KERNEL_TREE_BRANCH }} | |
<b>Action</b>: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- uses: actions/upload-artifact@v4 | |
if: ${{ success() && github.event.inputs.UPLOAD_TO_RELEASE != 'true' }} | |
with: | |
name: Image.gz | |
path: ${{ steps.kernel.outputs.kernel-folder }}/out/arch/arm64/boot/Image.gz | |
- uses: actions/upload-artifact@v4 | |
if: ${{ success() && github.event.inputs.UPLOAD_TO_RELEASE != 'true' }} | |
with: | |
name: dtb | |
path: ${{ steps.kernel.outputs.kernel-folder }}/out/arch/arm64/boot/dtb.img | |
- uses: actions/upload-artifact@v4 | |
if: ${{ success() && github.event.inputs.UPLOAD_TO_RELEASE != 'true' }} | |
with: | |
name: dtbo.img | |
path: ${{ steps.kernel.outputs.kernel-folder }}/out/arch/arm64/boot/dtbo.img | |
- uses: actions/upload-artifact@v4 | |
if: ${{ success() && github.event.inputs.ANYKERNEL_URL != '' && github.event.inputs.UPLOAD_TO_RELEASE != 'true' }} | |
with: | |
name: ${{ steps.anykernel.outputs.zipname }} | |
path: | | |
${{ steps.kernel.outputs.kernel-folder }}/out/arch/arm64/boot/AnyKernel3/ | |
!${{ steps.kernel.outputs.kernel-folder }}/out/arch/arm64/boot/AnyKernel3/.git | |
!${{ steps.kernel.outputs.kernel-folder }}/out/arch/arm64/boot/AnyKernel3/.github | |
- uses: actions/upload-artifact@v4 | |
if: ${{ success() && github.event.inputs.SECOND_ANYKERNEL_URL != '' && github.event.inputs.UPLOAD_TO_RELEASE != 'true' }} | |
with: | |
name: ${{ steps.second_anykernel.outputs.second_zipname }} | |
path: | | |
${{ steps.kernel.outputs.kernel-folder }}/out/arch/arm64/boot/SecondAnyKernel/ | |
!${{ steps.kernel.outputs.kernel-folder }}/out/arch/arm64/boot/SecondAnyKernel/.git | |
!${{ steps.kernel.outputs.kernel-folder }}/out/arch/arm64/boot/SecondAnyKernel/.github |