Recovery Build #98
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: Recovery Build | |
on: | |
workflow_dispatch: | |
inputs: | |
MANIFEST_BRANCH: | |
type: choice | |
description: 'Manifest Branch' | |
options: | |
- 12.1 | |
- 11 | |
- 9.0 | |
- 8.1 | |
- 7.1 | |
- 6.0 | |
required: true | |
default: '12.1' | |
DEVICE_TREE_URL: | |
description: 'Device Tree URL' | |
required: true | |
default: 'https://github.com/TeamWin/android_device_asus_I003D' | |
DEVICE_TREE_BRANCH: | |
description: 'Device Tree Branch' | |
required: true | |
default: 'android-12.1' | |
DEVICE_PATH: | |
description: 'Path the device tree should be synced to, relative to source root' | |
required: true | |
default: 'device/asus/I003D' | |
DEVICE_NAME: | |
description: 'Device Name from tree (should match name on vendor_device.mk)' | |
required: true | |
default: 'I003D' | |
REPOPICK_PATCHES: | |
description: 'Gerrit commit numbers separated by a space to be included in the build' | |
type: string | |
required: false | |
BUILD_TARGET: | |
type: choice | |
description: 'Partition containing recovery ramdisk' | |
options: | |
- boot | |
- recovery | |
- vendor_boot | |
required: true | |
default: 'recovery' | |
jobs: | |
build: | |
if: github.event.repository.owner.id == github.event.sender.id | |
runs-on: ubuntu-20.04 | |
# You can use either of the ubuntu-20.04 or ubuntu-22.04 runner | |
steps: | |
- name: Display Run Parameters | |
run: | | |
echo "::group::User Environment Variables" | |
echo "Manifest Branch: ${{ github.event.inputs.MANIFEST_BRANCH }}" | |
echo "Device Tree URL: ${{ github.event.inputs.DEVICE_TREE_URL }}" | |
echo "Device Tree 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 }}.img" | |
echo "::endgroup::" | |
# You might want to Checkout your repo first, but not mandatory | |
- name: Check Out | |
uses: actions/checkout@v3 | |
# Cleanup The Actions Workspace Using Custom Composite Run Actions | |
- name: Cleanup | |
uses: rokibhasansagar/slimhub_actions@main | |
# That's it! Now use your normal steps | |
- 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 | |
sudo add-apt-repository universe | |
sudo apt -y install libncurses5 | |
- name: Install OpenJDK | |
uses: actions/setup-java@v3 | |
with: | |
distribution: 'zulu' | |
java-version: '8' | |
- name: Check Build Tree | |
uses: haya14busa/action-cond@v1 | |
id: buildtree | |
with: | |
cond: ${{ github.event.inputs.MANIFEST_BRANCH == '11' || github.event.inputs.MANIFEST_BRANCH == '12.1' }} | |
if_true: aosp | |
if_false: omni | |
- 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 workspace | |
cd workspace | |
git config --global user.name "Captain Throwback" | |
git config --global user.email "[email protected]" | |
repo init --depth=1 -u https://github.com/minimal-manifest-twrp/platform_manifest_twrp_${{ steps.buildtree.outputs.value }}.git -b twrp-${{ github.event.inputs.MANIFEST_BRANCH }} | |
- name: Repo Sync | |
run: | | |
repo sync -j$(nproc --all) --force-sync | |
working-directory: workspace | |
- name: Create roomservice.xml | |
run: | | |
mkdir -p .repo/local_manifests | |
cp -f ${GITHUB_WORKSPACE}/templates/roomservice.xml .repo/local_manifests/ | |
working-directory: workspace | |
- name: Clone device tree (TeamWin) | |
if: | | |
contains( github.event.inputs.DEVICE_TREE_URL,'/TeamWin/' ) | |
&& steps.buildtree.outputs.value == 'aosp' | |
run: | | |
sed -i "s%\!--project name=\"{DEVICE_TREE_URL_REPO}%project name=\"$(grep -oP '(?<=TeamWin/).*' <<< ${{ github.event.inputs.DEVICE_TREE_URL }})%g" .repo/local_manifests/roomservice.xml | |
sed -i "s%{DEVICE_PATH}%${{ github.event.inputs.DEVICE_PATH }}%g" .repo/local_manifests/roomservice.xml | |
sed -i "s%{DEVICE_REMOTE_NAME}%TeamWin%g" .repo/local_manifests/roomservice.xml | |
sed -i "s%{DEVICE_TREE_BRANCH}\"/-->%${{ github.event.inputs.DEVICE_TREE_BRANCH }}\"/>%g" .repo/local_manifests/roomservice.xml | |
repo sync -j$(nproc --all) | |
working-directory: workspace | |
- name: Clone device tree (Github) | |
if: | | |
!contains( github.event.inputs.DEVICE_TREE_URL,'/TeamWin/' ) | |
&& steps.buildtree.outputs.value == 'aosp' | |
run: | | |
sed -i "s%\!--project name=\"{DEVICE_TREE_URL_REPO}%project name=\"$(grep -oP '(?<=github.com/).*' <<< ${{ github.event.inputs.DEVICE_TREE_URL }})%g" .repo/local_manifests/roomservice.xml | |
sed -i "s%{DEVICE_PATH}%${{ github.event.inputs.DEVICE_PATH }}%g" .repo/local_manifests/roomservice.xml | |
sed -i "s%{DEVICE_REMOTE_NAME}%github%g" .repo/local_manifests/roomservice.xml | |
sed -i "s%{DEVICE_TREE_BRANCH}\"/-->%${{ github.event.inputs.DEVICE_TREE_BRANCH }}\"/>%g" .repo/local_manifests/roomservice.xml | |
repo sync -j$(nproc --all) | |
working-directory: workspace | |
- name: Clone device tree (Omni) | |
if: ${{ steps.buildtree.outputs.value == 'omni' }} | |
run: | | |
git clone ${{ github.event.inputs.DEVICE_TREE_URL }} -b ${{ github.event.inputs.DEVICE_TREE_BRANCH }} ./${{ github.event.inputs.DEVICE_PATH }} | |
working-directory: workspace | |
- name: Sync Device Dependencies (AOSP) | |
if: ${{ steps.buildtree.outputs.value == 'aosp' }} | |
run: | | |
source build/envsetup.sh | |
lunch twrp_${{ github.event.inputs.DEVICE_NAME }}-eng | |
working-directory: workspace | |
id: syncdevicedeps | |
continue-on-error: true | |
- name: Sync Device Dependencies (Omni/subdevices) | |
if: | | |
steps.buildtree.outputs.value == 'omni' | |
|| steps.syncdevicedeps.outcome == 'failure' | |
run: | | |
bash ${GITHUB_WORKSPACE}/scripts/convert.sh ${{ github.event.inputs.DEVICE_PATH }}/${{ steps.buildtree.outputs.value }}.dependencies | |
repo sync -j$(nproc --all) | |
working-directory: workspace | |
continue-on-error: true | |
- name: Set Swap Space | |
uses: pierotofy/set-swap-space@master | |
with: | |
swap-size-gb: 24 | |
- name: Repopick Gerrit patches | |
if: github.event.inputs.REPOPICK_PATCHES != null | |
run: | | |
source build/envsetup.sh | |
repopick ${{ github.event.inputs.REPOPICK_PATCHES }} | |
working-directory: workspace | |
continue-on-error: true | |
- name: Install Python 2 | |
if: ${{ steps.buildtree.outputs.value == 'omni' }} | |
run: | | |
sudo apt -y install python2 | |
cd /usr/bin | |
sudo ln -sf python2 python | |
- name: Building recovery (AOSP) | |
if: ${{ steps.buildtree.outputs.value == 'aosp' }} | |
run: | | |
source build/envsetup.sh | |
export ALLOW_MISSING_DEPENDENCIES=true | |
lunch twrp_${{ github.event.inputs.DEVICE_NAME }}-eng && make $(tr -d _ <<< ${{ github.event.inputs.BUILD_TARGET }})image -j$(nproc --all) | |
working-directory: workspace | |
- name: Building recovery (Omni) | |
if: ${{ steps.buildtree.outputs.value == 'omni' }} | |
run: | | |
source build/envsetup.sh | |
export ALLOW_MISSING_DEPENDENCIES=true | |
lunch ${{ steps.buildtree.outputs.value }}_${{ github.event.inputs.DEVICE_NAME }}-eng && make ${{ github.event.inputs.BUILD_TARGET }}image -j$(nproc --all) | |
working-directory: workspace | |
- name: Upload to Release | |
uses: softprops/action-gh-release@v1 | |
with: | |
files: workspace/out/target/product/${{ github.event.inputs.DEVICE_NAME }}/${{ github.event.inputs.BUILD_TARGET }}.img | |
name: ${{ github.event.inputs.DEVICE_NAME }}-${{ github.run_id }} | |
tag_name: ${{ github.run_id }} | |
body: | | |
Manifest: ${{ github.event.inputs.MANIFEST_BRANCH }} | |
Device: ${{ github.event.inputs.DEVICE_NAME }} | |
Target: ${{ github.event.inputs.BUILD_TARGET }}.img | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |