forked from azwhikaru/Action-TWRP-Builder
-
Notifications
You must be signed in to change notification settings - Fork 140
140 lines (131 loc) · 5.65 KB
/
Recovery Build.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
name: Recovery Build
on:
workflow_dispatch:
inputs:
MANIFEST_BRANCH:
type: choice
description: Manifest Branch
options:
- 12.1
- 11
required: true
default: 12.1
DEVICE_TREE_URL:
description: Device Tree URL
required: true
default: https://gitlab.com/OrangeFox/device/lavender
DEVICE_TREE_BRANCH:
description: Device Tree Branch
required: true
default: fox_12.1
DEVICE_PATH:
description: Path the device tree should be synced to, relative to source root
required: true
default: device/xiaomi/lavender
DEVICE_NAME:
description: Device Name from tree (should match name on twrp_<DEVICE_NAME>.mk)
required: true
default: lavender
BUILD_TARGET:
type: choice
description: Partition containing recovery ramdisk
options:
- boot
- recovery
- vendor_boot
required: true
default: recovery
OPTIONAL_FLAGS:
description: (Optional) Additional "FOX_" flags for build can be added here
required: false
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: ${{ inputs.MANIFEST_BRANCH }}"
echo "Device Tree URL: ${{ inputs.DEVICE_TREE_URL }}"
echo "Device Tree Branch: ${{ inputs.DEVICE_TREE_BRANCH }}"
echo "Device Path: ${{ inputs.DEVICE_PATH }}"
echo "Device Name: ${{ inputs.DEVICE_NAME }}"
echo "Build Target: ${{ inputs.BUILD_TARGET }}.img"
echo "::endgroup::"
# You might want to Checkout your repo first, but not mandatory
- name: Check Out
uses: actions/checkout@v4
# 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: Set Swap Space
uses: pierotofy/set-swap-space@master
with:
swap-size-gb: 24
- name: Prepare the build environment
run: |
sudo apt install git aria2 -y
git clone https://gitlab.com/OrangeFox/misc/scripts
cd scripts
sudo bash setup/android_build_env.sh
- name: Sync OrangeFox sources and minimal manifest
run: |
mkdir OrangeFox_sync
cd OrangeFox_sync
git clone https://gitlab.com/OrangeFox/sync.git
cd sync
./orangefox_sync.sh --branch ${{ inputs.MANIFEST_BRANCH }} --path ${{ github.workspace }}/fox_${{ inputs.MANIFEST_BRANCH }}
sed -i "s/TeamWin/OrangeFox/g" ${{ github.workspace }}/fox_${{ inputs.MANIFEST_BRANCH }}/vendor/twrp/build/tools/roomservice.py
- name: Place device trees and kernel
run: |
mkdir -p .repo/local_manifests
cp -f ${GITHUB_WORKSPACE}/templates/roomservice.xml .repo/local_manifests/
REMOTE_NAME=$(grep -oP '(?<=://).*(?=\.)' <<< ${{ inputs.DEVICE_TREE_URL }})
sed -i "s%\!--project name=\"{DEVICE_TREE_URL_REPO}%project name=\"$(grep -oP "(?<=${REMOTE_NAME}.com/).*" <<< ${{ inputs.DEVICE_TREE_URL }})%g" .repo/local_manifests/roomservice.xml
sed -i "s%{DEVICE_PATH}%${{ inputs.DEVICE_PATH }}%g" .repo/local_manifests/roomservice.xml
sed -i "s%{DEVICE_REMOTE_NAME}%${REMOTE_NAME}%g" .repo/local_manifests/roomservice.xml
sed -i "s%{DEVICE_TREE_BRANCH}\"/-->%${{ inputs.DEVICE_TREE_BRANCH }}\"/>%g" .repo/local_manifests/roomservice.xml
repo sync ${{ inputs.DEVICE_PATH }} -j$(nproc --all)
DT_NAME=$(awk -F/ '{print $NF}' <<< ${{ inputs.DEVICE_TREE_URL }})
if [ "$DT_NAME" != ${{ inputs.DEVICE_NAME }} ]; then
if [ -z "$(ls ${{ inputs.DEVICE_PATH }}/${{ inputs.DEVICE_NAME }}/BoardConfig.mk)" ]; then
mkdir ${{ inputs.DEVICE_PATH }}/${{ inputs.DEVICE_NAME }}
DT_BoardConfig=$(ls ${{ inputs.DEVICE_PATH }}/BoardConfig* | head -1)
echo -e "-include ${DT_BoardConfig}">${{ inputs.DEVICE_PATH }}/${{ inputs.DEVICE_NAME }}/BoardConfig.mk
fi
fi
working-directory: fox_${{ inputs.MANIFEST_BRANCH }}
- name: Build it
run: |
set +e
source build/envsetup.sh
set -e
export ALLOW_MISSING_DEPENDENCIES=true
export FOX_BUILD_DEVICE=${{ inputs.DEVICE_NAME }}
export LC_ALL="C"
if [ -n "${{ inputs.OPTIONAL_FLAGS}}" ]; then
${{ inputs.OPTIONAL_FLAGS }}
echo -e "Additional Command(s): ${{ inputs.OPTIONAL_FLAGS }}"
else
echo "No additional commands specified."
fi
lunch twrp_${{ inputs.DEVICE_NAME }}-eng && mka $(tr -d _ <<< ${{ inputs.BUILD_TARGET }})image
working-directory: fox_${{ inputs.MANIFEST_BRANCH }}
- name: Upload to Release
uses: softprops/action-gh-release@4634c16e79c963813287e889244c50009e7f0981
with:
files: |
fox_${{ inputs.MANIFEST_BRANCH }}/out/target/product/${{ inputs.DEVICE_NAME }}/*${{ inputs.DEVICE_NAME }}*
fox_${{ inputs.MANIFEST_BRANCH }}/out/target/product/${{ inputs.DEVICE_NAME }}/obj/PACKAGING/vendor_ramdisk_fragments_intermediates/recovery.*
fox_${{ inputs.MANIFEST_BRANCH }}/out/target/product/${{ inputs.DEVICE_NAME }}/ramdisk-recovery.*
name: |
${{ inputs.DEVICE_NAME }} (OrangeFox)
tag_name: ${{ github.run_id }}
body: |
Manifest: ${{ inputs.MANIFEST_BRANCH }}
Target: ${{ inputs.BUILD_TARGET }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}