TWRP Build patches #6
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: TWRP Build patches | |
on: | |
workflow_dispatch: | |
inputs: | |
MANIFEST_BRANCH: | |
description: 'MANIFEST_BRANCH' | |
required: true | |
default: 'twrp-12.1' | |
type: choice | |
options: | |
- twrp-12.1 | |
- twrp-11 | |
- twrp-9.0 | |
DEVICE_TREE_URL: | |
description: 'DEVICE_TREE_URL' | |
required: true | |
default: 'https://github.com/brigudav/android_device_xiaomi_surya_twrp' | |
DEVICE_TREE_BRANCH: | |
description: 'DEVICE_TREE_BRANCH' | |
required: true | |
default: 'android-12.1' | |
DEVICE_PATH: | |
description: 'DEVICE_PATH' | |
required: true | |
default: 'device/xiaomi/surya' | |
DEVICE_NAME: | |
description: 'DEVICE_NAME' | |
required: true | |
default: 'surya' | |
BUILD_TARGET: | |
description: 'BUILD_TARGET' | |
required: true | |
default: 'recovery' | |
type: choice | |
options: | |
- recovery | |
- boot | |
- vendorboot | |
APPLYPATCH: | |
description: 'Apply diff.patch (true or false)' | |
required: true | |
default: 'yes' | |
type: choice | |
options: | |
- yes | |
- no | |
UPLOAD: | |
description: 'Upload to Telegram Bot (true or false)' | |
required: true | |
default: 'yes' | |
type: choice | |
options: | |
- yes | |
- no | |
PUBLISH: | |
description: 'Publish to GitHub (true or false)' | |
required: true | |
default: 'yes' | |
type: choice | |
options: | |
- yes | |
- no | |
jobs: | |
build: | |
name: Build TWRP by ${{ github.actor }} | |
if: github.event.repository.owner.id == github.event.sender.id | |
runs-on: ubuntu-20.04 | |
permissions: | |
contents: write | |
steps: | |
- name: Check Out | |
uses: actions/checkout@v4 | |
- name: Cleanup | |
uses: rokibhasansagar/slimhub_actions@main | |
- name: Prepare the environment | |
run: | | |
sudo apt update | |
sudo apt -y upgrade | |
sudo apt -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 libsdl1.2-dev libwxgtk3.0-gtk3-dev libxml2 lzop pngcrush schedtool \ | |
squashfs-tools imagemagick libbz2-dev lzma ncftp qemu-user-static libstdc++-10-dev libncurses5 python | |
- name: Install OpenJDK | |
uses: actions/setup-java@v3 | |
with: | |
distribution: 'zulu' | |
java-version: '8' | |
- name: Install Python 2 | |
if: github.event.inputs.MANIFEST_BRANCH != 'twrp-11' && github.event.inputs.MANIFEST_BRANCH != 'twrp-12.1' | |
run: | | |
sudo apt -y install python2 | |
cd /usr/bin | |
sudo ln -sf python2 python | |
- name: Switch to Python3 | |
if: github.event.inputs.MANIFEST_BRANCH == 'twrp-11' || github.event.inputs.MANIFEST_BRANCH == 'twrp-12.1' | |
run: | | |
sudo rm -rf /usr/bin/python | |
sudo ln -s /usr/bin/python3 /usr/bin/python | |
continue-on-error: true | |
- 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: Install 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: Initialize repo | |
run: | | |
mkdir twrp | |
cd twrp | |
echo "wsdir=$(pwd)" >> $GITHUB_OUTPUT | |
git config --global user.name "brigudav" | |
git config --global user.email "[email protected]" | |
repo init --depth=1 -u ${{ steps.manifest.outputs.value }} -b ${{ github.event.inputs.MANIFEST_BRANCH }} | |
id: pwd | |
- name: Repo Sync | |
run: | | |
repo sync -j$(nproc --all) --force-sync | |
working-directory: ${{ steps.pwd.outputs.wsdir }} | |
- name: Clone device tree | |
run: | | |
git clone ${{ github.event.inputs.DEVICE_TREE_URL }} -b ${{ github.event.inputs.DEVICE_TREE_BRANCH }} ./${{ github.event.inputs.DEVICE_PATH }} | |
working-directory: ${{ steps.pwd.outputs.wsdir }} | |
- name: Apply custom diff.patch | |
if: github.event.inputs.APPLYPATCH == 'true' | |
run: | | |
if [ -d "${{ github.event.inputs.DEVICE_PATH }}/patches" ]; then | |
. ${{ github.event.inputs.DEVICE_PATH }}/patches/apply-patches.sh | |
else | |
echo "Folder /patches not found" | |
fi | |
working-directory: ${{ steps.pwd.outputs.wsdir }} | |
continue-on-error: true | |
- name: Check Build Tree | |
uses: haya14busa/action-cond@v1 | |
id: buildtree | |
with: | |
cond: ${{ github.event.inputs.MANIFEST_BRANCH == 'twrp-11' || github.event.inputs.MANIFEST_BRANCH == 'twrp-12.1' }} | |
if_true: twrp | |
if_false: omni | |
- name: Set Swap Space | |
uses: pierotofy/set-swap-space@master | |
with: | |
swap-size-gb: 12 | |
- name: Building recovery | |
run: | | |
source build/envsetup.sh | |
export ALLOW_MISSING_DEPENDENCIES=true | |
repopick 7203 | |
lunch ${{ steps.buildtree.outputs.value }}_${{ github.event.inputs.DEVICE_NAME }}-eng && make clean && make ${{ github.event.inputs.BUILD_TARGET }}image -j$(nproc --all) | |
working-directory: ${{ steps.pwd.outputs.wsdir }} | |
- name: Set Variables | |
run: | | |
echo "date=$(TZ=Australia/Sydney date +%Y%m%d-%H%M)" >> $GITHUB_OUTPUT | |
echo "Outdir=${GITHUB_WORKSPACE}/twrp/out/target/product/${{ github.event.inputs.DEVICE_NAME }}" >> $GITHUB_OUTPUT | |
id: var | |
- name: Add Img to Zip | |
run: | | |
cd ${{ steps.var.outputs.Outdir }} | |
zip -9 twrp-${{ github.event.inputs.DEVICE_NAME }}-${{ steps.var.outputs.date }}.zip ${{ github.event.inputs.BUILD_TARGET }}.img | |
echo "name=$(find * -name *.zip -type f)" >> $GITHUB_OUTPUT | |
id: zipname | |
- name: Upload to Telegram Bot | |
if: github.event.inputs.UPLOAD == 'true' | |
env: | |
CHAT_ID: ${{ secrets.TELEGRAM_TO }} | |
BOT_TOKEN: ${{ secrets.TELEGRAM_TOKEN }} | |
run: | | |
curl https://api.telegram.org/bot$BOT_TOKEN/sendDocument \ | |
-F chat_id=$CHAT_ID \ | |
-F disable_notification=true \ | |
-F parse_mode=HTML \ | |
-F caption=" <b>- Build for <i>${{ github.event.inputs.DEVICE_NAME }}</i> completed.</b> " \ | |
-F document=@${{ steps.var.outputs.Outdir }}/${{ steps.zipname.outputs.name }} | |
- name: Publish to GitHub | |
if: github.event.inputs.PUBLISH == 'true' | |
uses: softprops/action-gh-release@v1 | |
with: | |
files: ${{ steps.var.outputs.Outdir }}/${{ steps.zipname.outputs.name }} | |
name: Unofficial TWRP for ${{ github.event.inputs.DEVICE_NAME }} - Build ${{ steps.var.outputs.date }} | |
tag_name: ${{ github.run_id }} | |
body: | | |
Manifest: ${{ github.event.inputs.MANIFEST_BRANCH }} | |
Device: ${{ github.event.inputs.DEVICE_NAME }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.TEST }} |