Skip to content

TeamWin [TWRP]

TeamWin [TWRP] #1

Workflow file for this run

name: TeamWin [TWRP]
on:
workflow_dispatch:
inputs:
MANIFEST_BRANCH:
description: 'TWRP Manifest Branch'
required: true
default: ''
type: choice
options:
- twrp-12.1
- twrp-11
- twrp-10.0-deprecated
- twrp-9.0
- twrp-8.1
- twrp-8.1-macOS
- twrp-7.1
- twrp-6.0
- twrp-5.1
- twrp-4.4-deprecated
DEVICE_TREE:
description: 'Custom Recovery Tree' # Your already made Device Tree for TWRP
required: true
default: 'https://github.com/lazycodebuilder/recovery_rmx1851'
DEVICE_TREE_BRANCH:
description: 'Custom Recovery Tree Branch' # Your Device Tree Branch, make sure it's right.
required: true
default: 'android-14'
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: 'Use LDCHECK'
required: false
default: 'false'
type: boolean
LDCHECKPATH:
description: 'Path of blobs to check' # Use it know what kind of dependencies your missing for decryption blobs.
required: true
default: 'system/bin/qseecomd'
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@v4
- name: Display Inputs
run: |
echo "Displaying variables/inputs."
echo "Manifest Branch: ${{ inputs.MANIFEST_BRANCH }}"
echo "Device Tree: ${{ inputs.DEVICE_TREE }}"
echo "Device Branch: ${{ inputs.DEVICE_TREE_BRANCH }}"
echo "Build Target: ${{ 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: Check Manifest Branch
run: |
if [ ${{ inputs.MANIFEST_BRANCH }} == 'twrp-11' ] || [ ${{ inputs.MANIFEST_BRANCH }} == 'twrp-12.1' ]; then
echo "MANIFEST=https://github.com/minimal-manifest-twrp/platform_manifest_twrp_aosp.git" >> $GITHUB_ENV
echo "CHECK_LEGACY_BRANCH=false" >> $GITHUB_ENV
else
echo "MANIFEST=https://github.com/minimal-manifest-twrp/platform_manifest_twrp_omni.git" >> $GITHUB_ENV
echo "CHECK_LEGACY_BRANCH=true" >> $GITHUB_ENV
fi
- 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 libtinfo5 libgflags-dev libncurses5 python3
- 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: Initialize Repo
run: |
mkdir android-recovery
cd android-recovery
git config --global user.name "lazycodebuilder"
git config --global user.email "[email protected]"
repo init --depth=1 -u ${{ env.MANIFEST }} -b ${{ 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 ${{ inputs.DEVICE_TREE }} -b ${{ inputs.DEVICE_TREE_BRANCH }} ./device_tree
cd device_tree
echo "COMMIT_ID=$(git rev-parse HEAD)" >> $GITHUB_ENV
- name: Extracting variables from .mk file
run: |
cd android-recovery/device_tree
# Initialize variables
DEVICE_MAKEFILE=""
DEVICE_DIRECTORY=""
DEVICE_NAME=""
# Loop through each .mk file in the current directory
for file in *.mk; do
# Extract variables using sed
makefile=$(sed -n 's/^[[:space:]]*PRODUCT_NAME[[:space:]]*:=\s*\(.*\)/\1/p' "$file")
brand=$(sed -n 's/^[[:space:]]*PRODUCT_BRAND[[:space:]]*:=\s*\(.*\)/\1/p' "$file")
codename=$(sed -n 's/^[[:space:]]*PRODUCT_DEVICE[[:space:]]*:=\s*\(.*\)/\1/p' "$file")
if [[ -n "$makefile" && -n "$brand" && -n "$codename" ]]; then
DEVICE_MAKEFILE="$makefile"
DEVICE_DIRECTORY="device/$brand"
DEVICE_NAME="$codename"
echo "DEVICE_MAKEFILE=${DEVICE_MAKEFILE}" >> $GITHUB_ENV
echo "DEVICE_NAME=${DEVICE_NAME}" >> $GITHUB_ENV
echo "DEVICE_DIRECTORY=${DEVICE_DIRECTORY}" >> $GITHUB_ENV
break
fi
done
# Navigate to the parent directory
cd ../
# Create the necessary directories
echo "Creating directory: $DEVICE_DIRECTORY"
mkdir -p "$DEVICE_DIRECTORY"
# Move device_tree folder to device_directory and rename it to $DEVICE_NAME
echo "Moving device_tree to $DEVICE_DIRECTORY/$DEVICE_NAME"
mv device_tree "$DEVICE_DIRECTORY"/"$DEVICE_NAME"
- name: Installing python2 for legacy builds
if: env.CHECK_LEGACY_BRANCH == 'true'
run: |
sudo apt-get install python2 python-is-python2
- name: Building Image
run: |
cd android-recovery
source build/envsetup.sh
export ALLOW_MISSING_DEPENDENCIES=true
lunch ${{ env.DEVICE_MAKEFILE }}-eng && make clean && make ${{ inputs.BUILD_TARGET }}image -j$(nproc --all)
echo "Done building your ${{ inputs.BUILD_TARGET }}.img"
- name: Set build target for upload
run: |
if [ ${{ inputs.BUILD_TARGET }} == 'recovery' ]; then
echo "BUILD_TARGET_NAME=recovery" >> $GITHUB_ENV
elif [ ${{ inputs.BUILD_TARGET }} == 'boot' ]; then
echo "BUILD_TARGET_NAME=boot" >> $GITHUB_ENV
else
echo "BUILD_TARGET_NAME=vendor_boot" >> $GITHUB_ENV
fi
- name: Set Build Date # Output will be use in Release
run: |
echo "BUILD_DATE=$(date +%Y%m%d)" >> $GITHUB_ENV
- name: Upload to Release
uses: softprops/action-gh-release@master
with:
files: |
android-recovery/out/target/product/${{ env.DEVICE_NAME }}/${{ env.BUILD_TARGET_NAME }}.img
android-recovery/out/target/product/${{ env.DEVICE_NAME }}/*installer*zip
android-recovery/out/target/product/${{ env.DEVICE_NAME }}/ramdisk-recovery.*
name: Unofficial TWRP for ${{ env.DEVICE_NAME }} // ${{ env.BUILD_DATE }}
tag_name: ${{ github.run_id }}
body: |
Build: ${{ inputs.MANIFEST_BRANCH }}
Device: [Device Tree/Branch](${{ inputs.DEVICE_TREE }}/tree/${{ inputs.DEVICE_TREE_BRANCH }})
Commit: Most recent [commit](${{ inputs.DEVICE_TREE }}/commit/${{ env.COMMIT_ID }}) during building.
- name: Run LDCheck
if: inputs.LDCHECK == 'true'
run: |
cd tools
mv -n libneeds ${GITHUB_WORKSPACE}/android-recovery/out/target/product/${{ env.DEVICE_NAME }}/recovery/root/
mv -n ldcheck ${GITHUB_WORKSPACE}/android-recovery/out/target/product/${{ env.DEVICE_NAME }}/recovery/root/
cd ../android-recovery/out/target/product/${{ env.DEVICE_NAME }}/recovery/root
python3 ldcheck -p system/lib64:vendor/lib64:system/lib:vendor/lib -d ${{ inputs.LDCHECKPATH }}
echo "Done checking missing dependencies. Review, and reconfigure your tree."
continue-on-error: true