Building recovery #86
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: Building recovery | |
on: | |
workflow_dispatch: | |
inputs: | |
ManifestLink: | |
description: 'Link For Minimal Recovery Manifest' | |
required: true | |
default: 'https://github.com/minimal-manifest-twrp/platform_manifest_twrp_aosp' | |
ManifestBranch: | |
description: 'Which Branch Would You Like To Sync' | |
required: true | |
DTLink: | |
description: 'Link For Your Device Tree With Branch Like URL -b BRANCH' | |
required: true | |
Vendor: | |
description: 'Enter Your Device OEM' | |
required: true | |
Device: | |
description: 'Enter Your Device Code Name' | |
required: true | |
LunchCMD: | |
description: 'Enter Lunch Command like lunch omni_$device-eng or lunch twrp_$device-eng' | |
required: true | |
default: 'lunch twrp_$DEVICE-eng' | |
BuildCMD: | |
description: 'Enter Build Command m recoveryimage or m bootimage' | |
required: true | |
default: 'mka recoveryimage' | |
TWVer: | |
description: 'Enter TW_DEVICE_VERSION' | |
required: true | |
default: 'test' | |
ExtraCMD: | |
description: 'Extra Commands To Run Before Build' | |
env: | |
MANIFEST: ${{ github.event.inputs.ManifestLink }} | |
MANIFEST_BRANCH: ${{ github.event.inputs.ManifestBranch }} | |
DT_LINK: ${{ github.event.inputs.DTLink }} | |
VENDOR: ${{ github.event.inputs.Vendor }} | |
DEVICE: ${{ github.event.inputs.Device }} | |
LUNCHCMD: ${{ github.event.inputs.LunchCMD }} | |
BUILDCMD: ${{ github.event.inputs.BuildCMD }} | |
TW_DEVICE_VERSION: ${{ github.event.inputs.TWVer }} | |
EXTRA_CMD: ${{ github.event.inputs.ExtraCMD }} | |
GH_TOKEN: ${{ secrets.GH_TOKEN }} | |
TZ: Asia/Kolkata | |
jobs: | |
build: | |
runs-on: ubuntu-20.04 | |
steps: | |
- name: Cleaning Up Runner | |
uses: rokibhasansagar/slimhub_actions@main | |
- name: Initializing environment | |
run: | | |
sudo -E apt-get -qq update | |
sudo -E apt-get -qq install bc build-essential zip curl libstdc++6 git wget python gcc clang libssl-dev rsync flex curl bison aria2 | |
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: Sync Recovery Source | |
run: | | |
mkdir work | |
cd work | |
repo init -u $MANIFEST -b $MANIFEST_BRANCH --depth=1 --groups=all,-notdefault,-device,-darwin,-x86,-mips | |
repo sync -j$(nproc --all) | |
- name: Clone Device Trees | |
run: | | |
cd work | |
printf "Cloning Device Tree..\n" | |
git clone $DT_LINK --depth=1 --single-branch device/$VENDOR/$DEVICE | |
- name: Extra Command | |
run: | | |
cd work | |
if [[ ! -z "$EXTRA_CMD" ]]; then | |
printf "Executing Extra Commands..\n" | |
eval "${EXTRA_CMD}" || { printf "Failed While Executing Extra Commands.\n"; exit 1; } | |
cd ~/work || exit | |
else | |
printf "No Extra Commands To Execute..\n" | |
fi | |
- name: Set Swap Space | |
uses: pierotofy/set-swap-space@master | |
with: | |
swap-size-gb: 12 | |
- name: Build | |
run: | | |
cd work | |
. build/envsetup.sh && $LUNCHCMD && export ALLOW_MISSING_DEPENDENCIES=true && export TW_DEVICE_VERSION=$(echo "$TW_DEVICE_VERSION") && $BUILDCMD -j$(nproc --all) | |
- name: Github Release | |
run: | | |
cd work | |
printf "Adding latest stable ghr binary...\n" | |
curl -s https://api.github.com/repos/tcnksm/ghr/releases/latest | jq -r '.assets[] | select(.browser_download_url | contains("linux_amd64")) | .browser_download_url' | wget -qi - | |
tar -xzf ghr_*_amd64.tar.gz --wildcards 'ghr*/ghr' --strip-components 1 && rm -rf ghr_*_amd64.tar.gz | |
chmod a+x ./ghr && sudo mv ./ghr /usr/local/bin/ | |
printf "Exporting Vars..\n" | |
export UPLOAD_PATH=$(pwd)/out/target/product/${DEVICE}/upload | |
export BUILD_ZIP=$(find $(pwd)/out/target/product/${DEVICE}/*.zip 2>/dev/null) | |
export BUILD_IMG=$(find $(pwd)/out/target/product/${DEVICE}/*.img 2>/dev/null) | |
export BUILD_FILE_TAR=$(find $WORKDIR/out/target/product/${DEVICE}/*.tar 2>/dev/null) | |
mkdir -p ${UPLOAD_PATH} | |
# Copy Required Files | |
if [[ ! -z ${BUILD_ZIP} ]]; then | |
cp $BUILD_ZIP $UPLOAD_PATH | |
fi | |
cp $BUILD_IMG $UPLOAD_PATH | |
# If Samsung's Odin TAR available, copy it to our upload dir | |
if [[ ! -z ${BUILD_FILE_TAR} ]]; then | |
echo "Samsung's Odin Tar available: $BUILD_FILE_TAR" | |
cp ${BUILD_FILE_TAR} ${UPLOAD_PATH} | |
fi | |
export GH_USER=$(echo "${{ github.repository }}" | cut -d'/' -f1) | |
export GH_REPO=$(echo "${{ github.repository }}" | cut -d'/' -f2) | |
export GH_SHA="${{ github.sha }}" | |
export VERSION=$(echo "$TW_DEVICE_VERSION") | |
printf "Final Release..\n" | |
ghr -t ${GH_TOKEN} -u ${GH_USER} -r ${GH_REPO} -n "Release for $(echo $DEVICE)" -b "$(echo $VERSION)" -c ${GH_SHA} -delete ${VERSION} ${UPLOAD_PATH} |