Skip to content

TWRP Recovery Builder 2024 #1

TWRP Recovery Builder 2024

TWRP Recovery Builder 2024 #1

name: TWRP Recovery Builder 2024
on:
workflow_dispatch:
inputs:
MANIFEST_BRANCH:
description: 'TWRP Minimal-Manifest Branch'
required: true
default: ''
type: choice
options:
- twrp-14
- twrp-12.1
- twrp-11
- twrp-9.0
DEVICE_TREE:
description: 'Custom Recovery Tree'
required: true
default: 'https://github.com/kinguser981/cap_sprout_twrp'
DEVICE_TREE_BRANCH:
description: 'Custom Recovery Tree Branch'
required: true
default: 'android-12.1'
DEVICE_PATH:
description: 'Specify your Device Path'
required: true
default: 'device/nokia/cap_sprout'
DEVICE_NAME:
description: 'Specify your Device Codename'
required: true
default: 'cap_sprout'
BUILD_TARGET:
description: 'Specify your Build Target'
required: true
default: 'recovery'
type: choice
options:
- boot
- recovery
- vendorboot
LDCHECK:
description: 'Path of blobs to check'
required: true
default: 'system/bin/qseecomd'
RECOVERY_TAR:
description: 'Release recovery.tar For Samsung devices'
required: false
default: false
type: boolean
RECOVERY_INSTALLER:
description: 'Include recovery installer zip'
type: boolean
required: true
default: true
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 "::group::User Environment Variables"
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"
echo "Include Recovery Installer: ${{ github.event.inputs.RECOVERY_INSTALLER }}"
echo "Release recovery.tar For Samsung devices: ${{ github.event.inputs.RECOVERY_TAR }}"
echo "::endgroup::"
- name: Cleanup
uses: rokibhasansagar/slimhub_actions@main
- name: Set Swap Space
uses: pierotofy/set-swap-space@master
with:
swap-size-gb: 24
- name: Prepare the environment
run: |
sudo apt update
sudo apt -y upgrade
sudo apt -y install tar zip wget 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 libsdl1.2-dev libwxgtk3.0-gtk3-dev libxml2 lzop pngcrush schedtool squashfs-tools imagemagick libbz2-dev lzma ncftp qemu-user-static libstdc++-10-dev libtinfo5 libgflags-dev
sudo add-apt-repository universe
sudo apt -y install libncurses5
- name: Install OpenJDK
uses: actions/setup-java@v4
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' || github.event.inputs.MANIFEST_BRANCH == 'twrp-14' }}
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 workspace
cd workspace
git config --global user.name "Samuel Kendall"
git config --global user.email "kinguser981@gmail.com"
repo init --depth=1 -u ${{ steps.manifest.outputs.value }} -b ${{ github.event.inputs.MANIFEST_BRANCH }}
- name: Repo Sync
run: |
cd workspace
repo sync -j$(nproc --all) --force-sync
- name: Clone Device Tree
run: |
cd workspace
git clone ${{ github.event.inputs.DEVICE_TREE }} -b ${{ github.event.inputs.DEVICE_TREE_BRANCH }} ./${{ github.event.inputs.DEVICE_PATH }}
cd ${{ github.event.inputs.DEVICE_PATH }}
echo "COMMIT_ID=$(git rev-parse HEAD)" >> $GITHUB_ENV
- name: Check Build Makefile
run: |
cd workspace
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!"
fi
continue-on-error: true
- name: Install Python 2
if: github.event.inputs.MANIFEST_BRANCH != 'twrp-11' && github.event.inputs.MANIFEST_BRANCH != 'twrp-12.1' && github.event.inputs.MANIFEST_BRANCH != 'twrp-14'
run: |
sudo apt -y install python2
cd /usr/bin
sudo ln -sf python2 python
- name: Building Image
run: |
cd workspace
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: Check if Recovery Exist
run: |
cd workspace
if [ -f out/target/product/${{ github.event.inputs.DEVICE_NAME }}/recovery.img ]; then
echo "RECOVERY_TYPE=recovery" >> $GITHUB_ENV
echo "recovery.img file found!"
echo "MD5_IMG=$(md5sum out/target/product/${{ github.event.inputs.DEVICE_NAME }}/${{ github.event.inputs.BUILD_TARGET }}.img | cut -d ' ' -f 1)" >> $GITHUB_ENV
elif [ -f out/target/product/${{ github.event.inputs.DEVICE_NAME }}/boot.img ]; then
echo "RECOVERY_TYPE=boot" >> $GITHUB_ENV
echo "boot.img file found!"
echo "MD5_IMG=$(md5sum out/target/product/${{ github.event.inputs.DEVICE_NAME }}/${{ github.event.inputs.BUILD_TARGET }}.img | cut -d ' ' -f 1)" >> $GITHUB_ENV
elif [ -f out/target/product/${{ github.event.inputs.DEVICE_NAME }}/vendor_boot.img ]; then
echo "RECOVERY_TYPE=vendor_boot" >> $GITHUB_ENV
echo "vendor_boot.img file found!"
echo "MD5_IMG=$(md5sum out/target/product/${{ github.event.inputs.DEVICE_NAME }}/vendor_boot.img | cut -d ' ' -f 1)" >> $GITHUB_ENV
else
echo "No Recovery file found!"
cd Exit
fi
- name: Include Recovery Installer
run: |
if [ ${{ github.event.inputs.RECOVERY_INSTALLER }} = true ]; then
cd workspace/out/target/product/${{ github.event.inputs.DEVICE_NAME }}/
wget https://github.com/kinguser981/recovery-installer/releases/download/zip/recovery-installer.zip
zip -ur recovery-installer.zip ${{ env.RECOVERY_TYPE }}.img
fi
continue-on-error: true
- name: Recovery to tar for Samsung devices
run: |
if [ ${{ github.event.inputs.RECOVERY_TAR }} = true ]; then
cd workspace/out/target/product/${{ github.event.inputs.DEVICE_NAME }}/
tar -cvf ${{ env.RECOVERY_TYPE }}.tar ${{ env.RECOVERY_TYPE }}.img
fi
continue-on-error: true
- name: Upload to Release
uses: softprops/action-gh-release@v1
with:
files: |
workspace/out/target/product/${{ github.event.inputs.DEVICE_NAME }}/${{ env.RECOVERY_TYPE }}.tar
workspace/out/target/product/${{ github.event.inputs.DEVICE_NAME }}/recovery-installer.zip
workspace/out/target/product/${{ github.event.inputs.DEVICE_NAME }}/${{ env.RECOVERY_TYPE }}.img
name: Unofficial TWRP for ${{ github.event.inputs.DEVICE_NAME }} // ${{ env.BUILD_DATE }}
tag_name: ${{ github.run_id }}
body: |
- name: Release ramdisk-recovery
uses: softprops/action-gh-release@4634c16e79c963813287e889244c50009e7f0981
with:
files: |
workspace/out/target/product/${{ github.event.inputs.DEVICE_NAME }}/obj/PACKAGING/vendor_ramdisk_fragments_intermediates/recovery.*
workspace/out/target/product/${{ github.event.inputs.DEVICE_NAME }}/ramdisk-recovery.*
name: Unofficial TWRP for ${{ github.event.inputs.DEVICE_NAME }} // ${{ env.BUILD_DATE }}
tag_name: ${{ github.run_id }}
body: |
Manifest: ${{ github.event.inputs.MANIFEST_BRANCH }}
Target: ${{ github.event.inputs.BUILD_TARGET}}.img
Device: [Device Tree/Branch](${{ github.event.inputs.DEVICE_TREE }}/tree/${{ github.event.inputs.DEVICE_TREE_BRANCH }})
Commit: Most recent [commit](${{ github.event.inputs.DEVICE_TREE }}/commit/${{ env.COMMIT_ID }}) during building.
MD5 (img): ${{ env.MD5_IMG }}
- name: Run LDCheck
run: |
cd tools
mv -n libneeds ${GITHUB_WORKSPACE}/workspace/out/target/product/${{ github.event.inputs.DEVICE_NAME }}/recovery/root/
mv -n ldcheck ${GITHUB_WORKSPACE}/workspace/out/target/product/${{ github.event.inputs.DEVICE_NAME }}/recovery/root/
cd ../workspace/out/target/product/${{ github.event.inputs.DEVICE_NAME }}/recovery/root
python3 ldcheck -p system/lib64:vendor/lib64:system/lib:vendor/lib -d ${{ github.event.inputs.LDCHECK }}
echo "Done checking missing dependencies. Review, and reconfigure your tree."
continue-on-error: true