-
Notifications
You must be signed in to change notification settings - Fork 431
266 lines (243 loc) · 9.66 KB
/
main.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
263
264
265
266
#
# Copyright (C) 2024 Antonino Scordino
# Copyright (C) 2024 Souhrud Reddy
#
# SPDX-License-Identifier: Apache-2.0
#
name: Start job for building through Crave.
on:
workflow_dispatch:
# Various inputs to simplify usage of workflow.
inputs:
BASE_PROJECT:
description: 'Choose a base project:'
required: true
default: 'LineageOS 20.0'
type: choice
options:
- 'LineageOS 20.0'
- 'LineageOS 21.0'
- 'ArrowOS 13.1'
- 'DerpFest 13.0'
BUILD_DIFFERENT_ROM:
description: "Command to initialize a different 'repo' project:"
required: false
default: "echo 'Build Starting!'"
REMOVALS:
description: "Folders to be removed before syncing:"
required: false
LOCAL_MANIFEST:
description: "Personal local manifest [repository or raw]:"
required: true
default: 'https://github.com/sounddrill31/local_manifests'
LOCAL_MANIFEST_BRANCH:
description: "Personal local manifest's branch:"
required: false
default: 'lineage-oxygen'
DEVICE_NAME:
description: "Device's codename:"
required: true
default: "oxygen"
PRODUCT_NAME:
description: "Product to build:"
required: true
default: "lineage_oxygen"
BUILD_COMMAND:
description: 'Command to be used for compiling:'
required: true
default: 'mka bacon'
BUILD_TYPE:
description: 'Type of build:'
required: true
default: 'userdebug'
type: choice
options:
- 'eng'
- 'userdebug'
- 'user'
CLEAN_BUILD:
description: 'Build with a clean workspace?'
required: true
default: 'no'
type: choice
options:
- 'yes'
- 'no'
jobs:
run-devspace-and-tmux:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up environment
run: |
sudo apt-get update
sudo apt-get install -y tmux
# Download and configure 'crave'.
- name: Configure the 'crave' environment
run: |
if [ "${DCDEVSPACE}" == "1" ]; then
echo 'No need to set up crave, we are already running in devspace!'
else
mkdir ${HOME}/bin/
curl -s https://raw.githubusercontent.com/accupara/crave/master/get_crave.sh | bash -s --
mv ${PWD}/crave ${HOME}/bin/
sudo ln -sf /home/${USER}/bin/crave /usr/bin/crave
envsubst < ${PWD}/crave.conf.sample >> ${PWD}/crave.conf
rm -rf ${PWD}/crave.conf.sample
fi
env:
CRAVE_USERNAME: ${{ secrets.CRAVE_USERNAME }}
CRAVE_TOKEN: ${{ secrets.CRAVE_TOKEN }}
- name: Run crave devspace
run: |
crave devspace -- "cd actions-runner;
if tmux has-session -t ghactions 2>/dev/null; then
echo "tmux session 'ghactions' already exists"
else
tmux new-session -d -s ghactions
tmux send-keys -t ghactions './run.sh' Enter
fi "
test:
name: Build using foss.crave.io
needs: run-devspace-and-tmux
runs-on: self-hosted
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
steps:
# Clean the workflow before initialization.
- name: Cleanup
run: rm -rf ${PWD}/*
# Check-out in order to access the repository's files.
- name: Check-out to repository
uses: actions/checkout@v4
# Set-up a spearate directory for the device.
- name: Set-up workspace environment
run: |
mkdir ${{ github.event.inputs.DEVICE_NAME }}
cd ${{ github.event.inputs.DEVICE_NAME }}
continue-on-error: true
# Download and configure 'repo'.
- name: Configure the 'repo' environment
run: |
mkdir "${HOME}/bin"
curl https://storage.googleapis.com/git-repo-downloads/repo >> "${HOME}/bin/repo"
chmod a+x "${HOME}/bin/repo"
sudo ln -sf "/home/${USER}/bin/repo" "/usr/bin/repo"
continue-on-error: true
# Generate 'git' credential in base of the workflow's author.
- name: Set-up 'git' credential(s)
run: |
git config --global user.name "${{ github.actor }}"
git config --global user.email "${{ github.actor_id }}+${{ github.actor }}@users.noreply.github.com"
# Test Your Personal 'Local Manifests' against The ROM
- name: Test Local Manifests
run: |
if [ "${{ github.event.inputs.BUILD_DIFFERENT_ROM }}" == "echo 'Build Starting!'" ]; then
case "${{ github.event.inputs.BASE_PROJECT }}" in
"ArrowOS 13.1")
repo init -u https://github.com/ArrowOS/android_manifest.git -b arrow-13.1 --depth=1
;;
"DerpFest 13.0")
repo init -u https://github.com/DerpFest-AOSP/manifest.git -b 13 --depth=1
;;
"LineageOS 21.0")
repo init -u https://github.com/LineageOS/android.git -b lineage-21.0 --git-lfs --depth=1
;;
"LineageOS 20.0")
repo init -u https://github.com/LineageOS/android.git -b lineage-20.0 --git-lfs --depth=1
;;
esac
else
${{ github.event.inputs.BUILD_DIFFERENT_ROM }}
fi
git clone ${{ github.event.inputs.LOCAL_MANIFEST }} --depth 1 -b ${{ github.event.inputs.LOCAL_MANIFEST_BRANCH }} .repo/local_manifests && \
timeout 1m repo sync --force-sync || { exit_code=$?; [ $exit_code -eq 124 ] || (echo "Error: Process failed with exit code $exit_code"; exit $exit_code); }
rm -rf .repo
timeout-minutes: 10
# Download and configure 'crave'.
- name: Configure the 'crave' environment
run: |
if [ "${DCDEVSPACE}" == "1" ]; then
echo 'No need to set up crave, we are already running in devspace!'
else
curl -s https://raw.githubusercontent.com/accupara/crave/master/get_crave.sh | bash -s --
mv ${PWD}/crave ${HOME}/bin/
sudo ln -sf /home/${USER}/bin/crave /usr/bin/crave
envsubst < ${PWD}/crave.conf.sample >> ${PWD}/crave.conf
rm -rf ${PWD}/crave.conf.sample
fi
env:
CRAVE_USERNAME: ${{ secrets.CRAVE_USERNAME }}
CRAVE_TOKEN: ${{ secrets.CRAVE_TOKEN }}
# Initialize the previously choosen 'repo' project.
- name: Set the 'crave' project
run: |
case "${{ github.event.inputs.BASE_PROJECT }}" in
"ArrowOS 13.1")
repo init -u https://github.com/ArrowOS/android_manifest.git -b arrow-13.1 --depth=1
crave set --projectID 73
;;
"DerpFest 13.0")
repo init -u https://github.com/DerpFest-AOSP/manifest.git -b 13 --depth=1
crave set --projectID 64
;;
"LineageOS 21.0")
repo init -u https://github.com/LineageOS/android.git -b lineage-21.0 --git-lfs --depth=1
crave set --projectID 72
;;
"LineageOS 20.0")
repo init -u https://github.com/LineageOS/android.git -b lineage-20.0 --git-lfs --depth=1
crave set --projectID 36
;;
esac
id: pwd
# Create a 'crave' job for building.
- name: Start compilation through 'crave'
run: |
if [ "${{ github.event.inputs.CLEAN_BUILD }}" == "yes" ]; then
export CLEAN="clean"
fi
crave run --no-patch --${CLEAN} "rm -rf ${PWD}/.repo/local_manifests/ ${{ github.event.inputs.REMOVALS }} && \
# Clone local_manifests repository
${{ github.event.inputs.BUILD_DIFFERENT_ROM }} ; \
git clone ${{ github.event.inputs.LOCAL_MANIFEST }} --depth 1 -b ${{ github.event.inputs.LOCAL_MANIFEST_BRANCH }} .repo/local_manifests && \
if [ ! $? == 0 ]; then \
curl -o .repo/local_manifests ${{ github.event.inputs.LOCAL_MANIFEST }}; \
fi \
# Sync the repositories
repo sync -c -j$(nproc --all) --no-clone-bundle --no-tags --optimized-fetch --prune --force-sync && \
# Set up build environment
export BUILD_USERNAME=${{ github.actor }} ; \
export BUILD_HOSTNAME=crave ; \
source build/envsetup.sh && \
# Build the ROM
lunch ${{ github.event.inputs.PRODUCT_NAME }}-${{ github.event.inputs.BUILD_TYPE }} && \
make installclean && \
${{ github.event.inputs.BUILD_COMMAND }}"
# Only reach this wheter the user killed the workflow.
- name: Execute if the job is cancelled
if: ${{ cancelled() }}
run: crave stop --all
# Pull '.zip's and '.img's from 'crave'.
- name: Retrive build artifact(s)
run: |
crave pull out/target/product/*/*.zip
crave pull out/target/product/*/*.img
# Directly upload to releases.
- name: Upload to repository's releases page
uses: softprops/action-gh-release@v1
with:
files: |
${{ github.event.inputs.DEVICE_NAME }}/recovery.img
${{ github.event.inputs.DEVICE_NAME }}/boot.img
${{ github.event.inputs.DEVICE_NAME }}/vendor_boot.img
${{ github.event.inputs.DEVICE_NAME }}/vendor.img
${{ github.event.inputs.DEVICE_NAME }}/system.img
${{ github.event.inputs.DEVICE_NAME }}/*.zip
name: ${{ github.event.inputs.PRODUCT_NAME }}-${{ github.run_id }}
tag_name: ${{ github.run_id }}
body: |
Target: ${{ github.event.inputs.PRODUCT_NAME }}-${{ github.event.inputs.BUILD_TYPE }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}