Skip to content

Recovery Builder - TWRP #215

Recovery Builder - TWRP

Recovery Builder - TWRP #215

name: Recovery Builder - TWRP
on:
workflow_dispatch:
inputs:
MANIFEST_BRANCH:
description: 'TWRP Minimal-Manifest Branch'
required: true
default: ''
type: choice
options:
- twrp-12.1
- twrp-11
- twrp-9.0
DEVICE_TREE:
description: 'Custom Recovery Tree' # Your already made Device Tree for TWRP
required: true
default: 'https://github.com/cd-Crypton/custom_recovery_tree_realme_macedonia'
DEVICE_TREE_BRANCH:
description: 'Custom Recovery Tree Branch' # Your Device Tree Branch, make sure it's right.
required: true
default: 'twrp-12.1'
DEVICE_PATH:
description: 'Specify your Device Path' # As is, just like your DEVICE_PATH in your BoardConfig.mk
required: true
default: 'device/realme/macedonia'
DEVICE_NAME:
description: 'Specify your Device Codename' # As is, just like your PRODUCT_DEVICE in your device tree.
required: true
default: 'macedonia'
BUILD_TARGET:
description: 'Specify your Build Target' # Pick among boot, recovery and vendor_boot
required: true
default: 'recovery'
type: choice
options:
- boot
- recovery
- vendorboot
LDCHECK:
description: 'Check or Ignore' # Use it know what kind of dependencies your missing for decryption blobs.
required: true
default: 'ignore'
type: choice
options:
- check
- ignore
jobs:
build:
name: Build TWRP by ${{ github.actor }}
runs-on: ubuntu-20.04
if: github.event.repository.owner.id == github.event.sender.id
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
permissions:
contents: write
steps:
- name: Check Out
uses: actions/checkout@v3
- name: Display Inputs
run: |
echo "Displaying variables/inputs."
echo "Manifest Branch: ${{ github.event.inputs.MANIFEST_BRANCH }}"
echo "Device Tree: ${{ github.event.inputs.DEVICE_TREE }}"
echo "Device Branch: ${{ github.event.inputs.DEVICE_TREE_BRANCH }}"
echo "Device Path: ${{ github.event.inputs.DEVICE_PATH }}"
echo "Device Name: ${{ github.event.inputs.DEVICE_NAME }}"
echo "Build Target: ${{ github.event.inputs.BUILD_TARGET }}image"
- name: Cleanup
uses: rokibhasansagar/slimhub_actions@main
- name: Set Swap Space
uses: pierotofy/set-swap-space@master
with:
swap-size-gb: 12
- name: Prepare the environment
run: |
sudo apt-get update
sudo apt-get -y upgrade
sudo apt-get -y install gperf gcc-multilib gcc-10-multilib g++-multilib g++-10-multilib libc6-dev lib32ncurses5-dev x11proto-core-dev libx11-dev tree lib32z-dev libgl1-mesa-dev libxml2-utils xsltproc bc ccache lib32readline-dev lib32z1-dev liblz4-tool libncurses5-dev libncurses5 libtinfo5 libsdl1.2-dev libwxgtk3.0-gtk3-dev libxml2 lzop pngcrush schedtool squashfs-tools imagemagick libbz2-dev lzma ncftp qemu-user-static libstdc++-10-dev python
- name: Install OpenJDK
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: '8'
- name: Install Git-Repo
run: |
mkdir ~/bin
curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
chmod a+x ~/bin/repo
sudo ln -sf ~/bin/repo /usr/bin/repo
- name: Check Manifest Branch
uses: haya14busa/action-cond@v1
id: manifest
with:
cond: ${{ github.event.inputs.MANIFEST_BRANCH == 'twrp-11' || github.event.inputs.MANIFEST_BRANCH == 'twrp-12.1' }}
if_true: https://github.com/minimal-manifest-twrp/platform_manifest_twrp_aosp.git
if_false: https://github.com/minimal-manifest-twrp/platform_manifest_twrp_omni.git
- name: Initialize Repo
run: |
mkdir android-recovery
cd android-recovery
git config --global user.name "Carlo Dandan"
git config --global user.email "[email protected]"
repo init --depth=1 -u ${{ steps.manifest.outputs.value }} -b ${{ github.event.inputs.MANIFEST_BRANCH }}
- name: Repo Sync
run: |
cd android-recovery
repo sync -j$(nproc --all) --force-sync
- name: Clone Device Tree
run: |
cd android-recovery
git clone ${{ github.event.inputs.DEVICE_TREE }} -b ${{ github.event.inputs.DEVICE_TREE_BRANCH }} ./${{ github.event.inputs.DEVICE_PATH }}
- name: Check Build Makefile
run: |
cd android-recovery
if [ -f ${{ github.event.inputs.DEVICE_PATH }}/twrp_${{ github.event.inputs.DEVICE_NAME}}.mk ]; then
echo "DEVICE_MAKEFILE=twrp_${{ github.event.inputs.DEVICE_NAME }}" >> $GITHUB_ENV
elif [ -f ${{ github.event.inputs.DEVICE_PATH }}/omni_${{ github.event.inputs.DEVICE_NAME}}.mk ]; then
echo "DEVICE_MAKEFILE=omni_${{ github.event.inputs.DEVICE_NAME }}" >> $GITHUB_ENV
else
echo "No recovery makefile file found!"
exit 1
fi
continue-on-error: true
- name: Check Dependencies
run: |
cd android-recovery
if [ -f ${{ github.event.inputs.DEVICE_PATH }}/twrp.dependencies ]; then
echo "DEPENDENCIES=twrp.dependencies" >> $GITHUB_ENV
elif [ -f ${{ github.event.inputs.DEVICE_PATH }}/omni.dependencies ]; then
echo "DEPENDENCIES=omni.dependencies" >> $GITHUB_ENV
else
echo "No dependencies file found!"
exit 1
fi
continue-on-error: true
- name: Sync Dependencies
run: |
bash ${GITHUB_WORKSPACE}/scripts/convert.sh ${{ github.event.inputs.DEVICE_PATH }}/${{ env.DEPENDENCIES }}
repo sync -j$(nproc --all)
continue-on-error: true
- name: Building Image
run: |
cd android-recovery
source build/envsetup.sh
export ALLOW_MISSING_DEPENDENCIES=true
lunch ${{ env.DEVICE_MAKEFILE }}-eng && make clean && make ${{ github.event.inputs.BUILD_TARGET }}image -j$(nproc --all)
echo "Done building your ${{ github.event.inputs.BUILD_TARGET }}.img"
- name: Set Build Date # Output will be use in Release
run: |
echo "BUILD_DATE=$(date +%Y%m%d)" >> $GITHUB_ENV
- name: Upload to Release (boot and becovery)
if: github.event.inputs.BUILD_TARGET == 'boot' || github.event.inputs.BUILD_TARGET == 'recovery'
uses: softprops/action-gh-release@v1
with:
files: |
android-recovery/out/target/product/${{ github.event.inputs.DEVICE_NAME }}/${{ github.event.inputs.BUILD_TARGET }}.img
name: Unofficial TWRP for ${{ github.event.inputs.DEVICE_NAME }} // ${{ env.BUILD_DATE }}
tag_name: ${{ github.run_id }}
body: |
Build: ${{ github.event.inputs.MANIFEST_BRANCH }}
Device: ${{ github.event.inputs.DEVICE_TREE }}/tree/${{ github.event.inputs.DEVICE_TREE_BRANCH }}
- name: Upload to Release (if vendor_boot)
if: github.event.inputs.BUILD_TARGET == 'vendorboot'
uses: softprops/action-gh-release@v1
with:
files: |
android-recovery/out/target/product/${{ github.event.inputs.DEVICE_NAME }}/vendor_boot.img
name: Unofficial TWRP for ${{ github.event.inputs.DEVICE_NAME }} // ${{ env.BUILD_DATE }}
tag_name: ${{ github.run_id }}
body: |
Build: ${{ github.event.inputs.MANIFEST_BRANCH }}
Device: ${{ github.event.inputs.DEVICE_TREE }}/tree/${{ github.event.inputs.DEVICE_TREE_BRANCH }}
- name: Detect File (Only if LDCHECK was set to check.)
if: github.event.inputs.LDCHECK == 'check'
run: |
cd android-recovery
if [ -f ${{ github.event.inputs.DEVICE_PATH }}/recovery/root/system/bin/qseecomd ]; then
echo "FILE_TO_CHECK=system/bin/qseecomd" >> $GITHUB_ENV
elif [ -f ${{ github.event.inputs.DEVICE_PATH }}/recovery/root/vendor/bin/qseecomd ]; then
echo "FILE_TO_CHECK=vendor/bin/qseecomd" >> $GITHUB_ENV
else
echo "No qseecomd file found!"
exit 1
fi
if [ -f ${{ github.event.inputs.DEVICE_PATH }}/recovery/root/system/bin/mcDriverDaemon ]; then
echo "FILE_TO_CHECK=system/bin/mcDriverDaemon" >> $GITHUB_ENV
elif [ -f ${{ github.event.inputs.DEVICE_PATH }}/recovery/root/vendor/bin/mcDriverDaemon ]; then
echo "FILE_TO_CHECK=vendor/bin/mcDriverDaemon" >> $GITHUB_ENV
else
echo "No mcDriverDaemon file found!"
exit 1
fi
if [ -f ${{ github.event.inputs.DEVICE_PATH }}/recovery/root/system/bin/teei_daemon ]; then
echo "FILE_TO_CHECK=system/bin/teei_daemon" >> $GITHUB_ENV
elif [ -f ${{ github.event.inputs.DEVICE_PATH }}/recovery/root/vendor/bin/teei_daemon ]; then
echo "FILE_TO_CHECK=vendor/bin/teei_daemon" >> $GITHUB_ENV
else
echo "No teei_daemon file found!"
exit 1
fi
continue-on-error: true
- name: Run LDCheck (Only if LDCHECK was set to check.)
if: github.event.inputs.LDCHECK == 'check'
run: |
cd tools
mv -n libneeds ${GITHUB_WORKSPACE}/android-recovery/out/target/product/${{ github.event.inputs.DEVICE_NAME }}/recovery/root/
mv -n ldcheck ${GITHUB_WORKSPACE}/android-recovery/out/target/product/${{ github.event.inputs.DEVICE_NAME }}/recovery/root/
cd ../android-recovery/out/target/product/${{ github.event.inputs.DEVICE_NAME }}/recovery/root
python3 ldcheck -p system/lib64:vendor/lib64:system/lib:vendor/lib -d ${{ env.FILE_TO_CHECK }}
echo "Done checking missing dependencies. Review, and reconfigure your tree."
continue-on-error: true