-
Notifications
You must be signed in to change notification settings - Fork 44
184 lines (154 loc) · 6.11 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
name: check and build
on:
workflow_dispatch:
inputs:
pseudo_make:
description: "Pseudo Make"
type: boolean
default: false
schedule:
- cron: "50 9,21 * * *"
env:
kernel_repository: PixelExperience-Devices/kernel_xiaomi_polaris
kernel_branch: thirteen
device: dipper
defconfig: dipper_defconfig
use_aosp_clang: false
clang_version: 15
jobs:
check_kernelsu_update:
name: check kernelsu update
runs-on: ubuntu-latest
steps:
- name: install common package
run: |
sudo apt update
sudo apt install -y curl jq
- name: check kernelsu release
id: check_kernelsu_release
run: |
kernelsu_release=`curl https://api.github.com/repos/tiann/KernelSU/releases/latest | jq -r .tag_name`
local_release=`curl --header 'authorization: Bearer ${{ github.token }}' https://api.github.com/repos/${{ github.repository }}/releases/latest | jq -r .tag_name`
echo $kernelsu_release
echo $local_release
echo kernelsu_release=$kernelsu_release >> $GITHUB_OUTPUT
echo local_release=$local_release >> $GITHUB_OUTPUT
outputs:
kernelsu_release: ${{ steps.check_kernelsu_release.outputs.kernelsu_release }}
local_release: ${{ steps.check_kernelsu_release.outputs.local_release }}
build:
needs: check_kernelsu_update
if: needs.check_kernelsu_update.outputs.kernelsu_release != needs.check_kernelsu_update.outputs.local_release
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: install common package
run: |
sudo apt update
sudo apt install -y curl zip unzip git make bc binutils-arm-linux-gnueabi binutils-aarch64-linux-gnu
- name: checkout kernel
uses: actions/checkout@v3
with:
repository: ${{ env.kernel_repository }}
ref: ${{ env.kernel_branch }}
- name: get latest kernel commit id
run: |
kernel_commit_id=$(git rev-parse HEAD)
echo kernel_commit_id=$kernel_commit_id >> $GITHUB_ENV
- name: "aosp-clang: get aosp clang version"
if: ${{ env.use_aosp_clang == 'true' }}
run: |
aosp_clang_version=$(curl https://android.googlesource.com/kernel/common/+/refs/heads/android-mainline/build.config.constants | sed -E -n 's .*(r[0-9]{6}[a-z]?[0-9]?).* \1 p')
echo aosp_clang_version=$aosp_clang_version >> $GITHUB_ENV
- name: "aosp-clang: compiler restore"
id: compiler_restore
if: ${{ env.use_aosp_clang == 'true' }}
uses: actions/cache/restore@v3
with:
path: compiler
key: compiler-${{ env.aosp_clang_version }}
- name: "aosp-clang: compiler download"
id: compiler_download
if: ${{ env.use_aosp_clang == 'true' && steps.compiler_restore.outputs.cache-hit != 'true' }}
run: |
curl -o aosp-clang.tar.gz https://android.googlesource.com/platform/prebuilts/clang/host/linux-x86/+archive/refs/heads/master/clang-$aosp_clang_version.tar.gz
mkdir -p compiler/aosp-clang
tar -xf aosp-clang.tar.gz -C compiler/aosp-clang
rm -rf aosp-clang.tar.gz
- name: "aosp-clang: compiler save"
id: compiler_save
if: ${{ env.use_aosp_clang == 'true' && steps.compiler_download.outcome == 'success' }}
uses: actions/cache/save@v3
with:
path: compiler
key: ${{ steps.compiler_restore.outputs.cache-primary-key }}
- name: "aosp-clang: setup"
if: ${{ env.use_aosp_clang == 'true' }}
run: |
PATH=$(pwd)/compiler/aosp-clang/bin:$PATH
echo PATH=$PATH >> $GITHUB_ENV
- name: "vanilla-clang: setup"
if: ${{ env.use_aosp_clang == 'false' }}
run: |
sudo apt install -y clang-$clang_version lld-$clang_version
PATH=/usr/lib/llvm-$clang_version/bin:$PATH
echo PATH=$PATH >> $GITHUB_ENV
- name: setup kernelsu
run: |
curl -LSs "https://raw.githubusercontent.com/tiann/KernelSU/main/kernel/setup.sh" | bash -
echo 'CONFIG_KPROBES=y' >> arch/arm64/configs/${{ env.defconfig }}
cd KernelSU
# git checkout main
git checkout ${{ needs.check_kernelsu_update.outputs.kernelsu_release }}
- name: export flags
run: |
flags="O=out ARCH=arm64 LLVM=1 LLVM_IAS=1 CROSS_COMPILE=aarch64-linux-gnu- CROSS_COMPILE_ARM32=arm-linux-gnueabi-"
echo flags=$flags >> $GITHUB_ENV
- name: make defconfig
run: |
make $flags ${{ env.defconfig }}
- name: make
if: ${{ !inputs.pseudo_make }}
run: |
make $flags -j$(nproc --all)
- name: pseudo make
if: ${{ inputs.pseudo_make }}
run: |
mkdir -p out/arch/arm64/boot/
echo 123 > out/arch/arm64/boot/Image
echo 123 > out/arch/arm64/boot/Image.gz
echo 123 > out/arch/arm64/boot/Image.gz-dtb
- name: anykernel
run: |
curl -Lo AnyKernel3.zip https://github.com/osm0sis/AnyKernel3/archive/refs/heads/master.zip
unzip AnyKernel3.zip
cd AnyKernel3-master
cat > anykernel.sh <<EOF
properties() { '
do.devicecheck=1
do.cleanup=1
device.name1=${{ env.device }}
'; }
block=auto
is_slot_device=0
. tools/ak3-core.sh
split_boot
flash_boot
EOF
cp ../out/arch/arm64/boot/Image.gz-dtb .
zip -r boot.zip * -x .git README.md *placeholder
- name: release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ needs.check_kernelsu_update.outputs.kernelsu_release }}
body: |
Device:
${{ env.device }}
Kernel:
https://github.com/${{ env.kernel_repository }}/tree/${{ env.kernel_commit_id }}
KernelSU:
https://github.com/tiann/KernelSU/releases/tag/${{ needs.check_kernelsu_update.outputs.kernelsu_release }}
files: |
out/arch/arm64/boot/Image*
AnyKernel3-master/boot.zip