Skip to content

Check and Build

Check and Build #498

Workflow file for this run

name: check and build
on:
workflow_dispatch:
inputs:
pseudo_make:
description: "Pseudo Make"
type: boolean
default: false
schedule:
- cron: "50 9,21 * * *"
env:
kernel_repository: PixelExperience-Devices/kernel_xiaomi_polaris
kernel_branch: thirteen
device: dipper
defconfig: dipper_defconfig
use_aosp_clang: false
clang_version: 15
jobs:
check_kernelsu_update:
name: check kernelsu update
runs-on: ubuntu-latest
steps:
- name: install common package
run: |
sudo apt update
sudo apt install -y curl jq
- name: check kernelsu release
id: check_kernelsu_release
run: |
kernelsu_release=`curl https://api.github.com/repos/tiann/KernelSU/releases/latest | jq -r .tag_name`
local_release=`curl --header 'authorization: Bearer ${{ github.token }}' https://api.github.com/repos/${{ github.repository }}/releases/latest | jq -r .tag_name`
echo $kernelsu_release
echo $local_release
echo kernelsu_release=$kernelsu_release >> $GITHUB_OUTPUT
echo local_release=$local_release >> $GITHUB_OUTPUT
outputs:
kernelsu_release: ${{ steps.check_kernelsu_release.outputs.kernelsu_release }}
local_release: ${{ steps.check_kernelsu_release.outputs.local_release }}
build:
needs: check_kernelsu_update
if: needs.check_kernelsu_update.outputs.kernelsu_release != needs.check_kernelsu_update.outputs.local_release
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: install common package
run: |
sudo apt update
sudo apt install -y curl zip unzip git make bc binutils-arm-linux-gnueabi binutils-aarch64-linux-gnu
- name: checkout kernel
uses: actions/checkout@v3
with:
repository: ${{ env.kernel_repository }}
ref: ${{ env.kernel_branch }}
- name: get latest kernel commit id
run: |
kernel_commit_id=$(git rev-parse HEAD)
echo kernel_commit_id=$kernel_commit_id >> $GITHUB_ENV
- name: "aosp-clang: get aosp clang version"
if: ${{ env.use_aosp_clang == 'true' }}
run: |
aosp_clang_version=$(curl https://android.googlesource.com/kernel/common/+/refs/heads/android-mainline/build.config.constants | sed -E -n 's .*(r[0-9]{6}[a-z]?[0-9]?).* \1 p')
echo aosp_clang_version=$aosp_clang_version >> $GITHUB_ENV
- name: "aosp-clang: compiler restore"
id: compiler_restore
if: ${{ env.use_aosp_clang == 'true' }}
uses: actions/cache/restore@v3
with:
path: compiler
key: compiler-${{ env.aosp_clang_version }}
- name: "aosp-clang: compiler download"
id: compiler_download
if: ${{ env.use_aosp_clang == 'true' && steps.compiler_restore.outputs.cache-hit != 'true' }}
run: |
curl -o aosp-clang.tar.gz https://android.googlesource.com/platform/prebuilts/clang/host/linux-x86/+archive/refs/heads/master/clang-$aosp_clang_version.tar.gz
mkdir -p compiler/aosp-clang
tar -xf aosp-clang.tar.gz -C compiler/aosp-clang
rm -rf aosp-clang.tar.gz
- name: "aosp-clang: compiler save"
id: compiler_save
if: ${{ env.use_aosp_clang == 'true' && steps.compiler_download.outcome == 'success' }}
uses: actions/cache/save@v3
with:
path: compiler
key: ${{ steps.compiler_restore.outputs.cache-primary-key }}
- name: "aosp-clang: setup"
if: ${{ env.use_aosp_clang == 'true' }}
run: |
PATH=$(pwd)/compiler/aosp-clang/bin:$PATH
echo PATH=$PATH >> $GITHUB_ENV
- name: "vanilla-clang: setup"
if: ${{ env.use_aosp_clang == 'false' }}
run: |
sudo apt install -y clang-$clang_version lld-$clang_version
PATH=/usr/lib/llvm-$clang_version/bin:$PATH
echo PATH=$PATH >> $GITHUB_ENV
- name: setup kernelsu
run: |
curl -LSs "https://raw.githubusercontent.com/tiann/KernelSU/main/kernel/setup.sh" | bash -
echo 'CONFIG_KPROBES=y' >> arch/arm64/configs/${{ env.defconfig }}
cd KernelSU
# git checkout main
git checkout ${{ needs.check_kernelsu_update.outputs.kernelsu_release }}
- name: export flags
run: |
flags="O=out ARCH=arm64 LLVM=1 LLVM_IAS=1 CROSS_COMPILE=aarch64-linux-gnu- CROSS_COMPILE_ARM32=arm-linux-gnueabi-"
echo flags=$flags >> $GITHUB_ENV
- name: make defconfig
run: |
make $flags ${{ env.defconfig }}
- name: make
if: ${{ !inputs.pseudo_make }}
run: |
make $flags -j$(nproc --all)
- name: pseudo make
if: ${{ inputs.pseudo_make }}
run: |
mkdir -p out/arch/arm64/boot/
echo 123 > out/arch/arm64/boot/Image
echo 123 > out/arch/arm64/boot/Image.gz
echo 123 > out/arch/arm64/boot/Image.gz-dtb
- name: anykernel
run: |
curl -Lo AnyKernel3.zip https://github.com/osm0sis/AnyKernel3/archive/refs/heads/master.zip
unzip AnyKernel3.zip
cd AnyKernel3-master
cat > anykernel.sh <<EOF
properties() { '
do.devicecheck=1
do.cleanup=1
device.name1=${{ env.device }}
'; }
block=auto
is_slot_device=0
. tools/ak3-core.sh
split_boot
flash_boot
EOF
cp ../out/arch/arm64/boot/Image.gz-dtb .
zip -r boot.zip * -x .git README.md *placeholder
- name: release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ needs.check_kernelsu_update.outputs.kernelsu_release }}
body: |
Device:
${{ env.device }}
Kernel:
https://github.com/${{ env.kernel_repository }}/tree/${{ env.kernel_commit_id }}
KernelSU:
https://github.com/tiann/KernelSU/releases/tag/${{ needs.check_kernelsu_update.outputs.kernelsu_release }}
files: |
out/arch/arm64/boot/Image*
AnyKernel3-master/boot.zip