forked from azwhikaru/Action-TWRP-Builder
-
Notifications
You must be signed in to change notification settings - Fork 144
262 lines (239 loc) · 9.93 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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
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 twrp_<DEVICE_NAME>.mk)
required: true
default: I003D
REPOPICK_PATCHES:
description: (Optional) Gerrit commit numbers separated by a space to be included in the build (leave blank if not using)
type: string
required: false
BUILD_TARGET:
type: choice
description: Partition containing recovery ramdisk
options:
- boot
- recovery
- vendor_boot
required: true
default: recovery
RECOVERY_INSTALLER:
description: Include recovery installer zip
type: boolean
required: true
default: 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 "Include Recovery Installer: ${{ inputs.RECOVERY_INSTALLER }}"
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 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: Check Build Tree
uses: haya14busa/[email protected]
id: buildtree
with:
cond: ${{ inputs.MANIFEST_BRANCH == '11' || inputs.MANIFEST_BRANCH == '12.1' }}
if_true: aosp
if_false: omni
- name: Install OpenJDK
if: steps.buildtree.outputs.value == 'omni'
uses: actions/setup-java@v4
with:
distribution: zulu
java-version: 8
- 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 "${GITHUB_ACTOR}"
git config --global user.email "${GITHUB_ACTOR_ID}+${GITHUB_ACTOR}@users.noreply.github.com"
repo init --depth=1 -u https://github.com/minimal-manifest-twrp/platform_manifest_twrp_${{ steps.buildtree.outputs.value }}.git -b twrp-${{ 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/*.xml .repo/local_manifests/
working-directory: workspace
- name: Clone device tree (TeamWin)
if: |
contains( 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/).*' <<< ${{ 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}%TeamWin%g" .repo/local_manifests/roomservice.xml
sed -i "s%{DEVICE_TREE_BRANCH}\"/-->%${{ 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( 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/).*' <<< ${{ 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}%github%g" .repo/local_manifests/roomservice.xml
sed -i "s%{DEVICE_TREE_BRANCH}\"/-->%${{ 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 ${{ inputs.DEVICE_TREE_URL }} -b ${{ inputs.DEVICE_TREE_BRANCH }} ./${{ inputs.DEVICE_PATH }}
working-directory: workspace
- name: Sync Device Dependencies (AOSP)
if: ${{ steps.buildtree.outputs.value == 'aosp' }}
run: |
source build/envsetup.sh
lunch twrp_${{ 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 ${{ inputs.DEVICE_PATH }}/${{ steps.buildtree.outputs.value }}.dependencies
repo sync -j$(nproc --all)
working-directory: workspace
continue-on-error: true
- name: Repopick Gerrit patches
if: inputs.REPOPICK_PATCHES != null
run: |
source build/envsetup.sh
repopick -g https://gerrit.twrp.me ${{ inputs.REPOPICK_PATCHES }}
working-directory: workspace
continue-on-error: true
- name: Include Recovery Installer
if: inputs.RECOVERY_INSTALLER == true && inputs.MANIFEST_BRANCH != '6.0' && inputs.BUILD_TARGET != 'vendor_boot'
run: |
case ${{ inputs.MANIFEST_BRANCH }} in
7.1)
patchNum=5080
;;
8.1)
patchNum=5079
;;
9.0)
patchNum=5037
;;
11)
patchNum=4964
;;
12.1)
patchNum=5445
;;
esac
source build/envsetup.sh
repopick -g https://gerrit.twrp.me ${patchNum}
working-directory: workspace
id: recoveryinstaller
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
if [ ${{ inputs.RECOVERY_INSTALLER }} = true ] && [ ${{ steps.recoveryinstaller.outcome == 'success' }} ]; then
export USE_RECOVERY_INSTALLER=true
export RECOVERY_INSTALLER_PATH=bootable/recovery/installer
fi
lunch twrp_${{ inputs.DEVICE_NAME }}-eng && make $(tr -d _ <<< ${{ 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
if [ ${{ inputs.RECOVERY_INSTALLER }} = true ] && [ ${{ steps.recoveryinstaller.outcome == 'success' }} ]; then
export USE_RECOVERY_INSTALLER=true
export RECOVERY_INSTALLER_PATH=bootable/recovery/installer
fi
lunch ${{ steps.buildtree.outputs.value }}_${{ inputs.DEVICE_NAME }}-eng && make ${{ inputs.BUILD_TARGET }}image -j$(nproc --all)
working-directory: workspace
- name: Upload to Release
uses: softprops/action-gh-release@4634c16e79c963813287e889244c50009e7f0981
with:
files: |
workspace/out/target/product/${{ inputs.DEVICE_NAME }}/${{ inputs.BUILD_TARGET }}.img
workspace/out/target/product/${{ inputs.DEVICE_NAME }}/*installer*zip
workspace/out/target/product/${{ inputs.DEVICE_NAME }}/obj/PACKAGING/vendor_ramdisk_fragments_intermediates/recovery.*
workspace/out/target/product/${{ inputs.DEVICE_NAME }}/ramdisk-recovery.*
name: ${{ inputs.DEVICE_NAME }} (TWRP)
tag_name: ${{ github.run_id }}
body: |
Manifest: ${{ inputs.MANIFEST_BRANCH }}
Target: ${{ inputs.BUILD_TARGET }}.img
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}