diff --git a/ci/init_repo.sh b/ci/init_repo.sh index 30b651f..e0d241b 100755 --- a/ci/init_repo.sh +++ b/ci/init_repo.sh @@ -1,131 +1,104 @@ -#!/usr/bin/env bash -# Usage: ci/init_repo.sh [desired_branch] [workdir] [jobs] -# Example: ci/init_repo.sh https://github.com/minimal-manifest-twrp/platform_manifest_twrp_aosp.git android-15.0 ~/twrp 8 - -set -euo pipefail -set -o errtrace - -MANIFEST_URL="${1:-}" -DESIRED="${2:-}" +#!/bin/bash +# +# Copyright (C) 2025 The TWRP Open Source Project +# Copyright (C) 2025 DUptain +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# This script intelligently initializes and syncs the TWRP manifest repository. + +set -e + +# --- Configuration & Arguments --- +MANIFEST_URL="$1" +DESIRED_BRANCH="$2" WORKDIR="${3:-$HOME/twrp}" -JOBS="${4:-8}" -# Allow caller to provide REPO_BIN (full path) or default to $HOME/bin/repo -REPO_BIN="${REPO_BIN:-$HOME/bin/repo}" - -if [[ -z "$MANIFEST_URL" ]]; then - echo "Usage: $0 [desired_branch] [workdir] [jobs]" - exit 2 -fi - -# Expand tilde if present and ensure absolute path for WORKDIR -WORKDIR="${WORKDIR/#\~/$HOME}" -mkdir -p "$WORKDIR" -cd "$WORKDIR" +JOBS="${4:-4}" +REPO_BIN="$HOME/bin/repo" -echo "ci/init_repo.sh: starting in $(pwd)" +echo "ci/init_repo.sh: starting in $WORKDIR" echo "Manifest: $MANIFEST_URL" -echo "Desired branch: ${DESIRED:-}" +echo "Desired branch: $DESIRED_BRANCH" echo "Workdir: $WORKDIR" echo "Jobs: $JOBS" -echo "REPO_BIN: $REPO_BIN" - -# Ensure repo tool present: prefer a usable REPO_BIN if it's executable, otherwise try 'repo' in PATH -repo_cmd="" -if [[ -x "$REPO_BIN" ]]; then - repo_cmd="$REPO_BIN" -elif command -v repo >/dev/null 2>&1; then - repo_cmd="$(command -v repo)" -else - echo "repo tool not found; installing to $REPO_BIN" - mkdir -p "$(dirname "$REPO_BIN")" - curl -fsSL "https://storage.googleapis.com/git-repo-downloads/repo" -o "$REPO_BIN" - chmod +x "$REPO_BIN" - repo_cmd="$REPO_BIN" -fi -if [[ -z "$repo_cmd" ]]; then - echo "ERROR: could not determine repo command; aborting" - exit 4 +# --- Install repo tool if needed --- +if [ ! -f "$REPO_BIN" ]; then + echo "repo tool not found; installing to $REPO_BIN" + mkdir -p "$(dirname "$REPO_BIN")" + curl -o "$REPO_BIN" https://storage.googleapis.com/git-repo-downloads/repo + chmod a+x "$REPO_BIN" fi +echo "Using repo command at: $REPO_BIN" -echo "Using repo command at: $repo_cmd" - -# Make sure git can reach the manifest +# --- Branch Selection Logic --- echo "Querying available branches from manifest repo: $MANIFEST_URL" -mapfile -t branches < <(git ls-remote --heads --refs "$MANIFEST_URL" 2>/dev/null | awk '{print $2}' | sed 's#refs/heads/##' || true) - -if [[ ${#branches[@]} -eq 0 ]]; then - echo "ERROR: Could not list branches from $MANIFEST_URL" - echo "Check network access, manifest URL and that the repository exists. Aborting." - exit 3 +AVAILABLE_BRANCHES=$(git ls-remote --heads "$MANIFEST_URL" | cut -f2 | sed 's#refs/heads/##') +if [ $? -ne 0 ] || [ -z "$AVAILABLE_BRANCHES" ]; then + echo "ERROR: Failed to query branches from manifest repo at $MANIFEST_URL" >&2 + exit 1 fi - echo "Available branches from manifest:" -for b in "${branches[@]}"; do echo " $b"; done +echo "$AVAILABLE_BRANCHES" -pick_branch() { - requested="$1" - # If requested branch exists, use it - if [[ -n "$requested" ]]; then - for b in "${branches[@]}"; do - if [[ "$b" == "$requested" ]]; then - echo "$b" - return - fi - done - fi +FINAL_BRANCH="" - # Prefer exact android-* branches and choose the highest numeric version - android_branches=() - for b in "${branches[@]}"; do - if [[ "$b" =~ ^android-([0-9]+) ]]; then - android_branches+=("$b") +# 1. Check if the exact desired branch exists +if echo "$AVAILABLE_BRANCHES" | grep -q "^${DESIRED_BRANCH}$"; then + FINAL_BRANCH="$DESIRED_BRANCH" + echo "Desired branch '${DESIRED_BRANCH}' found." +# 2. If not, find the highest available twrp-* branch +else + echo "Desired branch '${DESIRED_BRANCH}' not found. Searching for the best fallback." + # Filter for twrp- branches, sort them by version, and get the latest one + BEST_FALLBACK=$(echo "$AVAILABLE_BRANCHES" | grep '^twrp-' || true | sort -V | tail -n 1) + if [ -n "$BEST_FALLBACK" ]; then + FINAL_BRANCH="$BEST_FALLBACK" + echo "Using best fallback branch: ${FINAL_BRANCH}" + else + # 3. As a last resort, try 'main' or 'master' + if echo "$AVAILABLE_BRANCHES" | grep -q "^main$"; then + FINAL_BRANCH="main" + elif echo "$AVAILABLE_BRANCHES" | grep -q "^master$"; then + FINAL_BRANCH="master" + else + echo "ERROR: No suitable branch found in the manifest repository." >&2 + exit 1 + fi + echo "Warning: No twrp-* branch found. Using last resort: ${FINAL_BRANCH}" fi - done - - if [[ ${#android_branches[@]} -gt 0 ]]; then - # sort by numeric portion descending and pick first - printf "%s\n" "${android_branches[@]}" | sort -Vr | head -n1 - return - fi - - # Fallback to main, then master, then first available - for candidate in main master; do - for b in "${branches[@]}"; do - if [[ "$b" == "$candidate" ]]; then - echo "$b" - return - fi - done - done - - # Last resort: return the first available branch - echo "${branches[0]}" -} +fi -BRANCH="$(pick_branch "$DESIRED")" -echo "Using manifest branch: $BRANCH" +echo "Using manifest branch: ${FINAL_BRANCH}" -# Remove existing .repo to avoid partial state (explicit and safe) -if [[ -d .repo ]]; then - echo "Removing existing .repo to avoid partial state" - rm -rf .repo -fi +# --- Initialize and Sync Repo --- +mkdir -p "$WORKDIR" +cd "$WORKDIR" -# Repo init + sync with retry for transient network errors -echo "Running repo init -u $MANIFEST_URL -b $BRANCH" -"$repo_cmd" init --depth=1 -u "$MANIFEST_URL" -b "$BRANCH" || { echo "repo init failed"; exit 4; } +echo "Running repo init -u ${MANIFEST_URL} -b ${FINAL_BRANCH}" +"$REPO_BIN" init -u "${MANIFEST_URL}" -b "${FINAL_BRANCH}" --depth=1 --no-repo-verify -MAX_ATTEMPTS=5 -for attempt in $(seq 1 $MAX_ATTEMPTS); do - echo "repo sync attempt $attempt/$MAX_ATTEMPTS" - if "$repo_cmd" sync -c -j"$JOBS" --force-sync --no-clone-bundle --no-tags --fail-fast; then - echo "repo sync succeeded" - exit 0 - fi - echo "repo sync failed; sleeping $((5 * attempt)) seconds and retrying..." - sleep $((5 * attempt)) +for i in {1..5}; do + echo "repo sync attempt $i/5" + if "$REPO_BIN" sync -c -j"${JOBS}" --no-clone-bundle --no-tags --optimized-fetch --prune; then + echo "Repo sync successful." + exit 0 + fi + if [ $i -lt 5 ]; then + echo "Repo sync failed. Retrying in $((15 * i)) seconds..." + sleep $((15 * i)) + fi done -echo "repo sync failed after $MAX_ATTEMPTS attempts" -exit 5 +echo "ERROR: Repo sync failed after 5 attempts." >&2 +exit 1 diff --git a/motorola/kansas/.project b/motorola/kansas/.project new file mode 100644 index 0000000..57572d9 --- /dev/null +++ b/motorola/kansas/.project @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + diff --git a/motorola/kansas/BoardConfig.mk b/motorola/kansas/BoardConfig.mk index fc21de9..3754b48 100644 --- a/motorola/kansas/BoardConfig.mk +++ b/motorola/kansas/BoardConfig.mk @@ -1,6 +1,7 @@ # # Copyright (C) 2025 The Android Open Source Project # Copyright (C) 2025 The TWRP Open Source Project +# Copyright (C) 2025 DUptain # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,164 +16,76 @@ # limitations under the License. # +# --- Device & Platform --- DEVICE_PATH := device/motorola/kansas -# Architecture +# --- Architecture --- TARGET_ARCH := arm64 -TARGET_ARCH_VARIANT := armv8-2a +TARGET_ARCH_VARIANT := armv8-a TARGET_CPU_ABI := arm64-v8a TARGET_CPU_ABI2 := -TARGET_CPU_VARIANT := cortex-a55 +TARGET_CPU_VARIANT := generic TARGET_2ND_ARCH := arm -TARGET_2ND_ARCH_VARIANT := armv8-2a +TARGET_2ND_ARCH_VARIANT := armv8-a TARGET_2ND_CPU_ABI := armeabi-v7a TARGET_2ND_CPU_ABI2 := armeabi -TARGET_2ND_CPU_VARIANT := cortex-a55 +TARGET_2ND_CPU_VARIANT := generic -# Bootloader -TARGET_BOOTLOADER_BOARD_NAME := mt6835 +# --- Bootloader --- +TARGET_BOOTLOADER_BOARD_NAME := kansas TARGET_NO_BOOTLOADER := true -# Platform -TARGET_BOARD_PLATFORM := mt6835 -TARGET_BOARD_PLATFORM_GPU := mali-g57 - -# Kernel -BOARD_BOOTIMG_HEADER_VERSION := 4 -BOARD_KERNEL_BASE := 0x40000000 -BOARD_KERNEL_CMDLINE := bootopt=64S3,32N2,64N2 -BOARD_KERNEL_CMDLINE += androidboot.init_fatal_reboot_target=recovery -BOARD_KERNEL_PAGESIZE := 4096 -BOARD_RAMDISK_OFFSET := 0x11b00000 -BOARD_KERNEL_TAGS_OFFSET := 0x07c88000 -BOARD_DTB_OFFSET := 0x07c88000 -BOARD_KERNEL_IMAGE_NAME := Image -TARGET_KERNEL_ARCH := arm64 -TARGET_KERNEL_HEADER_ARCH := arm64 -TARGET_KERNEL_SOURCE := kernel/motorola/kansas -TARGET_KERNEL_CONFIG := kansas_defconfig - -# Kernel - prebuilt -TARGET_FORCE_PREBUILT_KERNEL := true -ifeq ($(TARGET_FORCE_PREBUILT_KERNEL),true) -TARGET_PREBUILT_KERNEL := $(DEVICE_PATH)/prebuilt/kernel -TARGET_PREBUILT_DTB := $(DEVICE_PATH)/prebuilt/dtb.img -BOARD_MKBOOTIMG_ARGS += --dtb $(TARGET_PREBUILT_DTB) -BOARD_INCLUDE_DTB_IN_BOOTIMG := +# --- Kernel --- +# Use a prebuilt kernel from a separate repository +TARGET_PREBUILT_KERNEL := $(DEVICE_PATH)/prebuilt/Image.gz +TARGET_PREBUILT_DTB := $(DEVICE_PATH)/prebuilt/dtb BOARD_PREBUILT_DTBOIMAGE := $(DEVICE_PATH)/prebuilt/dtbo.img -BOARD_KERNEL_SEPARATED_DTBO := -endif +BOARD_INCLUDE_RECOVERY_DTBO := true +BOARD_BOOT_HEADER_VERSION := 3 +BOARD_MKBOOTIMG_ARGS += --header_version $(BOARD_BOOT_HEADER_VERSION) -# Partitions -BOARD_FLASH_BLOCK_SIZE := 131072 # (BOARD_KERNEL_PAGESIZE * 32) +# --- Partitions --- +BOARD_FLASH_BLOCK_SIZE := 262144 # (256 * 1024) BOARD_BOOTIMAGE_PARTITION_SIZE := 67108864 -BOARD_INIT_BOOT_IMAGE_PARTITION_SIZE := 8388608 -BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE := 67108864 -BOARD_DTBOIMG_PARTITION_SIZE := 8388608 -BOARD_SUPER_PARTITION_SIZE := 8355053568 -BOARD_SUPER_PARTITION_GROUPS := motorola_dynamic_partitions -BOARD_MOTOROLA_DYNAMIC_PARTITIONS_PARTITION_LIST := system system_ext product vendor vendor_dlkm odm -BOARD_MOTOROLA_DYNAMIC_PARTITIONS_SIZE := 8350859264 - -# File systems +BOARD_RECOVERYIMAGE_PARTITION_SIZE := 104857600 # 100MB BOARD_HAS_LARGE_FILESYSTEM := true BOARD_SYSTEMIMAGE_PARTITION_TYPE := ext4 BOARD_USERDATAIMAGE_FILE_SYSTEM_TYPE := f2fs BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE := ext4 -TARGET_COPY_OUT_VENDOR := vendor -TARGET_USERIMAGES_USE_EXT4 := true -TARGET_USERIMAGES_USE_F2FS := true - -# Workaround for error copying vendor files to recovery ramdisk -BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE := ext4 -TARGET_COPY_OUT_VENDOR := vendor -# Metadata -BOARD_USES_METADATA_PARTITION := true - -# Dynamic Partitions -BOARD_SUPER_PARTITION_GROUPS := motorola_dynamic_partitions -BOARD_MOTOROLA_DYNAMIC_PARTITIONS_SIZE := 8350859264 - -# A/B +# --- System as Root & A/B --- +BOARD_BUILD_SYSTEM_ROOT_IMAGE := false +BOARD_USES_RECOVERY_AS_BOOT := true +BOARD_SUPPRESS_SECURE_ERASE := true AB_OTA_UPDATER := true -AB_OTA_PARTITIONS += \ - boot \ - init_boot \ - dtbo \ - vendor_boot \ - vbmeta \ - vbmeta_system -# Verified Boot -BOARD_AVB_ENABLE := true -BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS += --flags 3 -BOARD_AVB_VBMETA_SYSTEM := system system_ext product -BOARD_AVB_VBMETA_SYSTEM_KEY_PATH := external/avb/test/data/testkey_rsa2048.pem -BOARD_AVB_VBMETA_SYSTEM_ALGORITHM := SHA256_RSA2048 -BOARD_AVB_VBMETA_SYSTEM_ROLLBACK_INDEX := $(PLATFORM_SECURITY_PATCH_TIMESTAMP) -BOARD_AVB_VBMETA_SYSTEM_ROLLBACK_INDEX_LOCATION := 1 - -# Crypto +# --- TWRP Configuration --- +TW_THEME := portrait_hdpi +RECOVERY_SDCARD_ON_DATA := true +TARGET_RECOVERY_PIXEL_FORMAT := "RGBX_8888" +TW_BRIGHTNESS_PATH := "/sys/class/backlight/panel0-backlight/brightness" +TW_MAX_BRIGHTNESS := 2047 +TW_DEFAULT_BRIGHTNESS := 1200 +TW_Y_OFFSET := 80 +TW_H_OFFSET := -80 +TW_NO_REBOOT_BOOTLOADER := true +TW_HAS_DOWNLOAD_MODE := true TW_INCLUDE_CRYPTO := true TW_INCLUDE_CRYPTO_FBE := true TW_INCLUDE_FBE_METADATA_DECRYPT := true -BOARD_USES_METADATA_PARTITION := true - -# Additional binaries & libraries needed for recovery -TARGET_RECOVERY_DEVICE_MODULES += \ - libkeymaster4 \ - libpuresoftkeymasterdevice \ - ashmemd_aidl_interface-cpp \ - libashmemd_client - -TW_RECOVERY_ADDITIONAL_RELINK_LIBRARY_FILES += \ - $(TARGET_OUT_SHARED_LIBRARIES)/libkeymaster4.so \ - $(TARGET_OUT_SHARED_LIBRARIES)/libpuresoftkeymasterdevice.so \ - $(TARGET_OUT_SHARED_LIBRARIES)/ashmemd_aidl_interface-cpp.so \ - $(TARGET_OUT_SHARED_LIBRARIES)/libashmemd_client.so +TW_INCLUDE_FASTBOOTD := true -# Properties -TARGET_SYSTEM_PROP += $(DEVICE_PATH)/system.prop +# --- Vendor --- +# This is crucial for builds. It tells the build system to include the vendor repo. TARGET_VENDOR_PROP += $(DEVICE_PATH)/vendor.prop -# Recovery -TARGET_RECOVERY_PIXEL_FORMAT := RGBX_8888 -TARGET_RECOVERY_FSTAB := $(DEVICE_PATH)/recovery/root/system/etc/recovery.fstab -BOARD_HAS_NO_SELECT_BUTTON := true -BOARD_HAS_LARGE_FILESYSTEM := true - -# TWRP Configuration -TW_THEME := portrait_hdpi -TW_EXTRA_LANGUAGES := true -TW_SCREEN_BLANK_ON_BOOT := true -TW_INPUT_BLACKLIST := "hbtp_vm" -TW_USE_TOOLBOX := true -TW_INCLUDE_REPACKTOOLS := true -TW_INCLUDE_RESETPROP := true -TW_INCLUDE_LIBRESETPROP := true -TW_EXCLUDE_DEFAULT_USB_INIT := true -TW_NO_SCREEN_BLANK := true -TW_DEFAULT_BRIGHTNESS := 150 -TW_MAX_BRIGHTNESS := 255 -TW_BRIGHTNESS_PATH := "/sys/class/leds/lcd-backlight/brightness" -TW_EXCLUDE_APEX := true -TW_SUPPORT_INPUT_AIDL_HAPTICS := true - -# Platform version -PLATFORM_VERSION := 15 -PLATFORM_VERSION_LAST_STABLE := $(PLATFORM_VERSION) -PLATFORM_SECURITY_PATCH := 2025-06-01 - -# API Level -BOARD_API_LEVEL := 35 -BOARD_SHIPPING_API_LEVEL := 35 - -# SELinux -include device/motorola/kansas/sepolicy/sepolicy.mk +# --- Android 15 / API 35 Specifics --- +# This matches the device's original firmware +PRODUCT_SHIPPING_API_LEVEL := 35 +TARGET_BOARD_PLATFORM := mt6835 +TARGET_USES_MKE2FS := true -# VINTF -DEVICE_MANIFEST_FILE += $(DEVICE_PATH)/manifest.xml -DEVICE_MATRIX_FILE += $(DEVICE_PATH)/compatibility_matrix.xml -DEVICE_FRAMEWORK_COMPATIBILITY_MATRIX_FILE += $(DEVICE_PATH)/framework_compatibility_matrix.xml +# --- Metadata --- +BOARD_USES_METADATA_PARTITION := true +BOARD_ROOT_EXTRA_FOLDERS += metadata diff --git a/upload-to-github.sh b/upload-to-github.sh index 0962c40..ea86a75 100755 --- a/upload-to-github.sh +++ b/upload-to-github.sh @@ -1,210 +1,73 @@ #!/bin/bash - -# Upload TWRP Device Tree to GitHub -# This script helps you upload the device tree to your GitHub repository - -set -e - -echo "==========================================" -echo "TWRP Device Tree GitHub Upload Script" -echo "==========================================" -echo "" - -# Check if git is installed -if ! command -v git &> /dev/null; then - echo "Error: git is not installed" - echo "Install with: pkg install git" +# +# Copyright (C) 2025 The TWRP Open Source Project +# Copyright (C) 2025 DUptain +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# Simple script to trigger a GitHub Actions workflow + +# --- Configuration --- +# Your GitHub Username +GITHUB_USER="DUptain1993" +# The name of this repository +GITHUB_REPO="Tree" +# The workflow file to trigger +WORKFLOW_FILE="build-twrp.yml" +# The branch of the TWRP manifest to use for building +# Corrected to use the available 'twrp-14.1' branch format +MANIFEST_BRANCH="twrp-14.1" + +# --- Script Logic --- + +# Function to print messages +print_message() { + echo "========================================" + echo "$1" + echo "========================================" +} + +# 1. Check if gh is installed +if ! command -v gh &> /dev/null; then + print_message "ERROR: 'gh' command not found." + echo "Please install the GitHub CLI to use this script." + echo "Installation instructions: https://cli.github.com/" exit 1 fi -# Get GitHub username -echo "Enter your GitHub username:" -read -r GITHUB_USERNAME - -if [ -z "$GITHUB_USERNAME" ]; then - echo "Error: GitHub username cannot be empty" +# 2. Authenticate with GitHub +print_message "Authenticating with GitHub" +if ! gh auth status &> /dev/null; then + echo "You are not logged into GitHub." + echo "Please run 'gh auth login' to authenticate." exit 1 fi - -# Get repository name -echo "" -echo "Enter repository name (press Enter for default: android_device_motorola_kansas):" -read -r REPO_NAME - -if [ -z "$REPO_NAME" ]; then - REPO_NAME="android_device_motorola_kansas" -fi - -# Confirm details -echo "" -echo "Repository will be created at:" -echo "https://github.com/$GITHUB_USERNAME/$REPO_NAME" -echo "" -echo "Is this correct? (y/n)" -read -r CONFIRM - -if [ "$CONFIRM" != "y" ] && [ "$CONFIRM" != "Y" ]; then - echo "Aborted by user" - exit 0 -fi - -# Initialize git if not already initialized -if [ ! -d .git ]; then - echo "" - echo "Initializing git repository..." - git init - git branch -M main -else - echo "" - echo "Git repository already initialized" -fi - -# Configure git user if not configured -if [ -z "$(git config user.name)" ]; then - echo "" - echo "Enter your name for git commits:" - read -r GIT_NAME - git config user.name "$GIT_NAME" -fi - -if [ -z "$(git config user.email)" ]; then - echo "" - echo "Enter your email for git commits:" - read -r GIT_EMAIL - git config user.email "$GIT_EMAIL" -fi - -# Create .gitignore if it doesn't exist -if [ ! -f .gitignore ]; then - echo "" - echo "Creating .gitignore..." - cat > .gitignore << 'EOF' -# Build outputs -*.o -*.ko -*.so -*.a -out/ -.repo/ - -# IDE files -.vscode/ -.idea/ -*.swp -*.swo -*~ - -# OS files -.DS_Store -Thumbs.db - -# Temporary files -*.log -*.tmp -EOF -fi - -# Add all files -echo "" -echo "Adding files to git..." -git add . - -# Check if there are changes to commit -if git diff --cached --quiet; then - echo "No changes to commit" -else - # Create commit - echo "" - echo "Creating commit..." - git commit -m "Add TWRP device tree for Motorola Moto G - 2025 (kansas) - -Device: Motorola Moto G - 2025 -Codename: kansas -Platform: MediaTek MT6835 -Android: 15 (API 35) - -Features: -- A/B Seamless Updates -- Dynamic Partitions -- File-Based Encryption -- AVB 2.0 Verified Boot -- Trustonic TEE -- TWRP Recovery Support" -fi - -# Add remote if not exists -REMOTE_URL="https://github.com/$GITHUB_USERNAME/$REPO_NAME.git" -if git remote | grep -q '^origin$'; then - echo "" - echo "Updating remote URL..." - git remote set-url origin "$REMOTE_URL" +echo "Successfully authenticated as '$(gh api user --jq .login)'." + +# 3. Trigger the workflow +print_message "Triggering the build workflow" +echo "Repository: $GITHUB_USER/$GITHUB_REPO" +echo "Workflow: $WORKFLOW_FILE" +echo "Branch: $MANIFEST_BRANCH" +echo + +if gh workflow run "$WORKFLOW_FILE" -R "$GITHUB_USER/$GITHUB_REPO" -f manifest_branch="$MANIFEST_BRANCH"; then + echo + print_message "SUCCESS: Workflow triggered!" + echo "Go to your Actions tab to see the progress:" + echo "https://github.com/$GITHUB_USER/$GITHUB_REPO/actions" else - echo "" - echo "Adding remote..." - git remote add origin "$REMOTE_URL" + print_message "ERROR: Failed to trigger workflow." + echo "Please check the repository and workflow name." fi - -# Show instructions -echo "" -echo "==========================================" -echo "NEXT STEPS:" -echo "==========================================" -echo "" -echo "1. Create the repository on GitHub:" -echo " Go to: https://github.com/new" -echo " Repository name: $REPO_NAME" -echo " Make it PUBLIC (required for free GitHub Actions)" -echo " DO NOT initialize with README" -echo "" -echo "2. Get a Personal Access Token:" -echo " Go to: https://github.com/settings/tokens" -echo " Click 'Generate new token (classic)'" -echo " Select scopes: repo, workflow" -echo " Copy the token" -echo "" -echo "3. Push to GitHub:" -echo " Run: git push -u origin main" -echo " Username: $GITHUB_USERNAME" -echo " Password: [paste your token]" -echo "" -echo "4. Enable GitHub Actions:" -echo " Go to: https://github.com/$GITHUB_USERNAME/$REPO_NAME/actions" -echo " Click 'I understand my workflows, go ahead and enable them'" -echo "" -echo "5. Start the build:" -echo " Click 'Actions' tab" -echo " Select 'Build TWRP Recovery'" -echo " Click 'Run workflow'" -echo " Select: android-14.0 branch" -echo " Click 'Run workflow'" -echo "" -echo "==========================================" -echo "" -echo "Ready to push? (y/n)" -read -r PUSH_NOW - -if [ "$PUSH_NOW" = "y" ] || [ "$PUSH_NOW" = "Y" ]; then - echo "" - echo "Pushing to GitHub..." - echo "Enter your Personal Access Token when prompted for password" - git push -u origin main - - if [ $? -eq 0 ]; then - echo "" - echo "Success! Your device tree has been uploaded to:" - echo "https://github.com/$GITHUB_USERNAME/$REPO_NAME" - echo "" - echo "Now go enable GitHub Actions and start your build!" - else - echo "" - echo "Push failed. Please check your credentials and try again with:" - echo "git push -u origin main" - fi -else - echo "" - echo "You can push later with:" - echo "git push -u origin main" -fi - -echo "" -echo "For detailed build instructions, see GITHUB_BUILD_INSTRUCTIONS.md"