forked from PhamtomK12/Android-Kernel-Builder
-
Notifications
You must be signed in to change notification settings - Fork 53
233 lines (197 loc) · 8.45 KB
/
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
name: "Build kernels"
env:
OUT_DIR: "${{ github.workspace }}/out"
on:
workflow_dispatch:
jobs:
Set-repos:
name: "🐂 Parse repos.json"
runs-on: ubuntu-latest
outputs:
repos: ${{ steps.generate-matrix.outputs.repos }}
builddate: ${{ steps.generate-builddate.outputs.builddate }}
steps:
- name: "😄 Checkout"
uses: actions/checkout@v3
- name: "😆 Generate Matrix"
id: generate-matrix
run: |
echo "repos<<EOF" >> $GITHUB_OUTPUT
jq -s '[.[][]]' repos*.json >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: "⏰ Set builddate"
id: generate-builddate
run: echo "builddate=$(date +'%Y%m%d')" >> $GITHUB_OUTPUT
Build-Kernel:
name: "🐎 Build kernel"
runs-on: ubuntu-22.04
needs:
- Set-repos
strategy:
max-parallel: 4
fail-fast: false
matrix:
repos: ${{ fromJSON(needs.Set-repos.outputs.repos) }}
env:
WORKSPACE: ${{ github.workspace }}
builddate: "${{ needs.Set-repos.outputs.builddate }}"
KERNEL_NAME: ${{ matrix.repos.kernelSource.name }}
KERNEL_REPO: ${{ matrix.repos.kernelSource.repo }}
KERNEL_BRANCH: ${{ matrix.repos.kernelSource.branch }}
KERNEL_DEVICE: ${{ matrix.repos.kernelSource.device }}
DEFCONFIG_NAME: ${{ matrix.repos.kernelSource.defconfig }}
withKernelSU: ${{ matrix.repos.withKernelSU }}
useAnykernel: ${{ matrix.repos.AnyKernel3.use }}
release: ${{ matrix.repos.AnyKernel3.release }}
steps:
- name: "⭐ Install prerequisites"
run: |
sudo apt-get update
sudo apt-get install -y build-essential bc curl git zip ftp gcc-aarch64-linux-gnu gcc-arm-linux-gnueabi libssl-dev lftp zstd wget libfl-dev python2 python3 libarchive-tools
- name: "⏰ Setup Anykernel3"
env:
params: "${{ toJSON(matrix.repos.AnyKernel3) }}"
run: |
ANYKERNEL_REPO=$(echo $params | jq -r ".repo")
ANYKERNEL_BRANCH=$(echo $params | jq -r ".branch")
git clone --recursive --depth=1 -j $(nproc) --branch $ANYKERNEL_BRANCH $ANYKERNEL_REPO AnyKernel3
echo "🤔 Setup Anykernel3 => ($ANYKERNEL_REPO)"
- name: "🌟 Clone kernel source => (${{ env.KERNEL_REPO }})"
run: |
git clone --recursive --depth=1 -j $(nproc) --branch $KERNEL_BRANCH $KERNEL_REPO $KERNEL_NAME
echo "🤔 Clone kernel source => ($KERNEL_REPO)"
- name: "💫 Get toolchains"
env:
toolchains: "${{ toJSON(matrix.repos.toolchains) }}"
run: |
toolchains_num="$(echo $toolchains | jq 'length')"
echo "🤔 There is $toolchains_num defined toolchains."
for ((i=0;i<toolchains_num;i++)); do
toolchain_name=$(echo $toolchains | jq -r ".[$i].name")
toolchain_repo=$(echo $toolchains | jq -r ".[$i].repo")
toolchain_branch=$(echo $toolchains | jq -r ".[$i].branch")
git clone --recursive --depth=1 -j $(nproc) --branch $toolchain_branch $toolchain_repo $toolchain_name
echo "🤔 Clone $toolchain_name => ($toolchain_repo)"
jq -r ".[$i].binPath[] | tostring" <<< "$toolchains" | while read -r bin_path; do
echo "$WORKSPACE/$toolchain_name/$bin_path" >> $GITHUB_PATH
done
done
- name: "😎 Set args"
id: generate-args
env:
params: "${{ toJSON(matrix.repos.params) }}"
THREAD: $(nproc --all)
run: |
echo "🤔 PATH Variable: $PATH"
ARCH=$(echo $params | jq -r ".ARCH")
CC=$(echo $params | jq -r ".CC")
args="-j${{ env.THREAD }}"
if [ -n "${{ env.OUT_DIR }}" ]; then
mkdir -p ${{ env.OUT_DIR }} && args="$args O=${{ env.OUT_DIR }}"
fi
if [ -n "$ARCH" ]; then
args="$args ARCH=$ARCH"
fi
if [ -n "$CC" ]; then
args="$args CC=${{ env.WORKSPACE }}/$CC"
fi
while read -r externalCommand; do
args="$args $externalCommand"
done < <(jq -r '.externalCommand | to_entries[] | "\(.key)=${{ env.WORKSPACE }}/\(.value)"' <<< "$params")
echo "🤔 $args"
echo "ARCH=$ARCH" >> $GITHUB_OUTPUT
echo "args=$args" >> $GITHUB_OUTPUT
- name: "😋 Update KernelSU"
working-directory: ${{ env.KERNEL_NAME }}
env:
arch: ${{ steps.generate-args.outputs.ARCH }}
if: ${{ env.withKernelSU == 'true' }}
run: |
if [ -d "./KernelSU" ]; then
rm -rf "./KernelSU"
fi
if [ -d "./drivers/kernelsu" ]; then
rm -rf "./drivers/kernelsu"
fi
curl -LSs "https://raw.githubusercontent.com/tiann/KernelSU/main/kernel/setup.sh" | bash -s main
echo -e "CONFIG_KPROBES=y" >> arch/${{ env.arch }}/configs/${{ env.DEFCONFIG_NAME }}
echo -e "CONFIG_HAVE_KPROBES=y" >> arch/${{ env.arch }}/configs/${{ env.DEFCONFIG_NAME }}
echo -e "CONFIG_KPROBE_EVENTS=y" >> arch/${{ env.arch }}/configs/${{ env.DEFCONFIG_NAME }}
cat arch/${{ env.arch }}/configs/${{ env.DEFCONFIG_NAME }}
- name: "👍 Make defconfig"
working-directory: ${{ env.KERNEL_NAME }}
env:
args: ${{ steps.generate-args.outputs.args }}
arch: ${{ steps.generate-args.outputs.ARCH }}
run: |
echo "PATH Variable: $PATH"
make ${{ env.args }} ${{ env.DEFCONFIG_NAME }}
- name: "🎶 Build kernel"
working-directory: ${{ env.KERNEL_NAME }}
env:
args: ${{ steps.generate-args.outputs.args }}
run: |
echo "PATH Variable: $PATH"
make ${args}
- name: "💛 Upload Image"
uses: actions/upload-artifact@v3
env:
arch: ${{ steps.generate-args.outputs.ARCH }}
with:
name: Image-${{ env.KERNEL_DEVICE }}-${{ env.KERNEL_NAME }}-${{ env.builddate }}
path: ${{ env.OUT_DIR }}/arch/${{ env.arch }}/boot/Image
if-no-files-found: ignore
retention-days: 7
- name: "💙 Upload Image.gz"
uses: actions/upload-artifact@v3
env:
arch: ${{ steps.generate-args.outputs.ARCH }}
with:
name: Image.gz-${{ env.KERNEL_DEVICE }}-${{ env.KERNEL_NAME }}-${{ env.builddate }}
path: ${{ env.OUT_DIR }}/arch/${{ env.arch }}/boot/Image.gz
if-no-files-found: ignore
retention-days: 7
- name: "💜 Upload dtb"
uses: actions/upload-artifact@v3
env:
arch: ${{ steps.generate-args.outputs.ARCH }}
with:
name: dtb-${{ env.KERNEL_DEVICE }}-${{ env.KERNEL_NAME }}-${{ env.builddate }}
path: ${{ env.OUT_DIR }}/arch/${{ env.arch }}/boot/dtb
if-no-files-found: ignore
retention-days: 7
- name: "❤️ Upload dtbo.img"
uses: actions/upload-artifact@v3
env:
arch: ${{ steps.generate-args.outputs.ARCH }}
with:
name: dtbo.img-${{ env.KERNEL_DEVICE }}-${{ env.KERNEL_NAME }}-${{ env.builddate }}
path: ${{ env.OUT_DIR }}/arch/${{ env.arch }}/boot/dtbo.img
if-no-files-found: ignore
retention-days: 7
- name: "❤️ Pack AnyKernel3.zip"
if: ${{ env.useAnykernel == 'true' }}
env:
arch: ${{ steps.generate-args.outputs.ARCH }}
anykernel: "${{ env.WORKSPACE }}/${{ env.KERNEL_DEVICE }}-${{ env.KERNEL_NAME }}_${{ env.builddate }}"
run: |
ls -al
if [ -e "${{ env.OUT_DIR }}/arch/${{ env.arch }}/boot/Image.gz-dtb" ]; then
cp -f ${{ env.OUT_DIR }}/arch/${{ env.arch }}/boot/Image.gz-dtb ./AnyKernel3/
fi
cd AnyKernel3/
zip -q -r "${{ env.anykernel }}.zip" *
- name: "💾 Upload AnyKernel3 image => (${{ env.builddate }})"
uses: actions/upload-artifact@v3
if: ${{ env.useAnykernel == 'true' }}
with:
name: "${{ env.KERNEL_DEVICE }}-${{ env.KERNEL_NAME }}_${{ env.builddate }}"
path: AnyKernel3/*
- name: 🧧 Create GitHub Release => (${{ env.builddate }})
continue-on-error: true
uses: softprops/action-gh-release@v1
if: ${{ env.useAnykernel == 'true' && env.release == 'true' }}
with:
tag_name: v${{ env.builddate }}.${{ github.run_number }}
files: "${{ env.WORKSPACE }}/${{ env.KERNEL_DEVICE }}-${{ env.KERNEL_NAME }}_${{ env.builddate }}.zip"
generate_release_notes: true