-
Notifications
You must be signed in to change notification settings - Fork 9
468 lines (434 loc) · 19.2 KB
/
build-single-istoreos-rockchip.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
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
name: Build Rockchip IstoreOS Single
# Fix for broken build: https://github.com/softprops/action-gh-release/issues/236
permissions:
contents: write
actions: write
on:
repository_dispatch:
workflow_dispatch:
inputs:
Cache:
description: 'Use Cache'
required: true
default: 'true'
type: choice
options:
- 'true'
- 'false'
UPLOAD_RELEASE:
description: 'UPLOAD To RELEASE'
required: true
default: 'true'
type: choice
options:
- 'true'
- 'false'
MACH:
description: 'Choose machine'
required: true
default: 'fmx1'
type: choice
options:
- 'tpm312'
- 'mpc1917'
- 'r08'
- 'fmx1'
REPO:
description: 'Choose repo'
required: true
default: 'istoreos-22.03'
type: choice
options:
- 'istoreos-22.03'
- 'main'
SETIP:
description: 'Set ip address'
default: '192.168.66.1'
required: false
type: choice
options:
- '192.168.66.1'
- '192.168.8.1'
- '192.168.16.1'
- '192.168.19.1'
- '192.168.9.1'
- '192.168.99.1'
- '192.168.166.1'
- '172.16.0.1'
- '172.18.0.1'
- '10.0.0.1'
- '10.88.0.1'
ALLKMOD:
description: 'Compile All Kmods'
required: true
default: 'false'
type: choice
options:
- 'true'
- 'false'
env:
TZ: Asia/Shanghai
jobs:
prepare:
runs-on: ubuntu-22.04
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
strategy:
matrix:
include:
- rockchip: mpc1917
- rockchip: tpm312
- rockchip: r08
- rockchip: fmx1
steps:
- name: 检查
uses: actions/checkout@main
- name: 生成矩阵配置
id: set-matrix
run: |
if [ "${{ github.event.inputs.MACH }}" == "${{ matrix.rockchip }}" ] && [ "${{ github.event.inputs.REPO }}" == "istoreos-22.03" ]; then
matrix={\"include\":[{\"target\":\"rockchip-ipt\",\"repo\":\"istoreos-22.03\"}]}
elif [ "${{ github.event.inputs.MACH }}" == "${{ matrix.rockchip }}" ] && [ "${{ github.event.inputs.REPO }}" == "main" ]; then
matrix={\"include\":[{\"target\":\"rockchip-ipt\",\"repo\":\"main\"},{\"target\":\"rockchip-nft\",\"repo\":\"main\"}]}
fi
echo "Generated matrix: "$matrix""
echo "matrix=$matrix" >> $GITHUB_OUTPUT
build:
runs-on: Ubuntu-latest
needs: prepare
strategy:
matrix: ${{ fromJSON(needs.prepare.outputs.matrix) }}
name: Build ${{github.event.inputs.MACH}} openwrt ${{ github.event.inputs.REPO }}
steps:
- name: 检查
uses: actions/checkout@main
- name: 释放Ubuntu磁盘空间
uses: endersonmenezes/free-disk-space@v2
with:
remove_android: true
remove_dotnet: true
remove_haskell: true
remove_tool_cache: true
remove_swap: true
remove_packages: "azure-cli google-cloud-cli microsoft-edge-stable google-chrome-stable firefox postgresql* temurin-* *llvm* mysql* dotnet-sdk-*"
remove_packages_one_command: true
remove_folders: "/usr/share/swift /usr/share/miniconda /usr/share/az* /usr/share/glade* /usr/local/lib/node_modules /usr/local/share/chromium /usr/local/share/powershell"
testing: false
- name: 初始化环境
env:
DEBIAN_FRONTEND: noninteractive
run: |
sudo rm -rf /etc/apt/sources.list.d/* /usr/share/dotnet /usr/local/lib/android /opt/ghc
sudo -E apt-get -qq update
sudo -E apt-get -qq install build-essential clang flex g++ gawk gcc-multilib gettext \
git libncurses5-dev libssl-dev python3-distutils python3-pyelftools python3-setuptools \
libpython3-dev rsync unzip zlib1g-dev swig aria2 jq subversion qemu-utils ccache rename \
libelf-dev device-tree-compiler libgnutls28-dev coccinelle libgmp3-dev libmpc-dev libfuse-dev b43-fwcutter cups-ppdc
sudo -E apt-get -qq purge azure-cli ghc* zulu* llvm* firefox powershell openjdk* dotnet* google* mysql* php* android*
sudo -E apt-get -qq autoremove --purge
sudo -E apt-get -qq clean
sudo timedatectl set-timezone "$TZ"
sudo mkdir -p /workdir
sudo chown $USER:$GROUPS /workdir
- name: 设置GITHUB_ENV
id: env
run: |
echo "date=$(date +'%m/%d_%Y_%H/%M')" >> $GITHUB_ENV
echo "date2=$(date +'%Y/%m %d')" >> $GITHUB_ENV
echo "date3=$(date +'%m.%d')" >> $GITHUB_ENV
VERSION="$(echo "${{github.event.action}}" | grep -Eo " [0-9.]+" | sed -e 's/ //')" || true
[ "$VERSION" ] && echo "VERSION=$VERSION" >> $GITHUB_ENV || echo "VERSION=$(date +'%m.%d')" >> $GITHUB_ENV
echo ${{matrix.target}}
source "${GITHUB_WORKSPACE}/env/common-rk3399.txt"
if [ "${{ matrix.repo }}" == "istoreos-22.03" ]; then
source "${GITHUB_WORKSPACE}/env/istoreos-22.03.repo"
elif [ "${{ matrix.repo }}" == "main" ]; then
source "${GITHUB_WORKSPACE}/env/openwrt-main.repo"
fi
echo "REPO_URL=${REPO_URL}" >> $GITHUB_ENV
echo "BURN_UBOOT_IMG_URL=${BURN_UBOOT_IMG_URL}" >> $GITHUB_ENV
echo "AMLIMG_TOOL_URL=${AMLIMG_TOOL_URL}" >> $GITHUB_ENV
echo "REPO_BRANCH=${{ matrix.repo }}" >> $GITHUB_ENV
echo "DIY_SH=${DIY_SH}" >> $GITHUB_ENV
echo "DIY_SH_AFB=${DIY_SH_AFB}" >> $GITHUB_ENV
echo "DIY_SH_RFC=${DIY_SH_RFC}" >> $GITHUB_ENV
echo "UPLOAD_BIN_DIR=${UPLOAD_BIN_DIR}" >> $GITHUB_ENV
echo "UPLOAD_IPK_DIR=${UPLOAD_IPK_DIR}" >> $GITHUB_ENV
echo "UPLOAD_FIRMWARE=${UPLOAD_FIRMWARE}" >> $GITHUB_ENV
echo "UPLOAD_COWTRANSFER=${UPLOAD_COWTRANSFER}" >> $GITHUB_ENV
echo "UPLOAD_WETRANSFER=${UPLOAD_WETRANSFER}" >> $GITHUB_ENV
echo "UPLOAD_RELEASE=${UPLOAD_RELEASE}" >> $GITHUB_ENV
echo "UPLOAD_ALLKMOD=${UPLOAD_ALLKMOD}" >> $GITHUB_ENV
echo "UPLOAD_SYSUPGRADE=${UPLOAD_SYSUPGRADE}" >> $GITHUB_ENV
echo "USE_Cache=${USE_Cache}" >> $GITHUB_ENV
chmod +x $DIY_SH $DIY_SH_AFB $DIY_SH_RFC gen-sha256sum.sh add-test-packages.sh
- name: 导入机器及安装包config
run: |
if [ ${{matrix.target}} == 'rockchip-nft' ]; then
bash $GITHUB_WORKSPACE/add-test-packages.sh nft
echo "----${{matrix.target}}-----NFT-test---"
fi
if [ ${{matrix.target}} == 'rockchip-ipt' ]; then
mv -f machine-configs/single/${{github.event.inputs.MACH}}-ipt.config machine-configs/${{matrix.target}}.config
echo "----${{matrix.target}}-----IPT-Machine--------"
elif [ ${{matrix.target}} == 'rockchip-nft' ]; then
mv -f machine-configs/single/${{github.event.inputs.MACH}}-nft.config machine-configs/${{matrix.target}}.config
echo "----${{matrix.target}}-----NFT-Machine--------"
fi
if [ ${{matrix.target}} == 'rockchip-ipt' ]; then
mv -f package-configs/single/${{github.event.inputs.MACH}}-ipt-istore.config package-configs/rockchip-ipt-2203.config
echo "----${{matrix.target}}-----IPT-Package-Config----"
elif [ ${{matrix.target}} == 'rockchip-nft' ]; then
mv -f package-configs/single/${{github.event.inputs.MACH}}-nft.config package-configs/rockchip-nft-2203.config
echo "----${{matrix.target}}-----NFT-Package-Config----"
fi
- name: 克隆源代码
working-directory: /workdir
id: clone
run: |
df -hT $PWD
git clone $REPO_URL -b $REPO_BRANCH openwrt --single-branch
ln -sf /workdir/openwrt $GITHUB_WORKSPACE/openwrt
cd openwrt
sed -i '$a src-git lunatic7 https://github.com/lunatickochiya/actionbased-openwrt-packages.git' feeds.conf.default
sed -i 's|https://github.com/jjm2473/packages.git|https://github.com/lunatickochiya/istoreos-packages-2203.git|' feeds.conf.default
echo "status=success" >> $GITHUB_OUTPUT
- name: 增加磁盘空间
env:
DEBIAN_FRONTEND: noninteractive
run: |
sudo mkdir -p -m 777 /mnt/openwrt/dl /mnt/openwrt/bin /mnt/openwrt/staging_dir /mnt/openwrt/build_dir
#ln -sf /mnt/openwrt/dl openwrt/dl
ln -sf /mnt/openwrt/bin openwrt/bin
ln -sf /mnt/openwrt/staging_dir openwrt/staging_dir
ln -sf /mnt/openwrt/build_dir openwrt/build_dir
df -hT
ls /mnt/openwrt
- name: 自定义安装包(优先于feeds)
if: steps.clone.outputs.status == 'success'
id: files
run: |
mkdir openwrt/feeds-bump
mkdir openwrt/patch-istoreos
[ -d openwrt/package/diy/ntfs3-mount ] && rm -rf openwrt/package/diy/ntfs3-mount
[ -d package ] && mv -f package/* openwrt/package
[ -d openwrt-2203/files-for-istoreos ] && cp -r openwrt-2203/files-for-istoreos/. openwrt/
[ -d openwrt-2203/package-for-istoreos ] && mv -f openwrt-2203/package-for-istoreos/* openwrt/package
[ -d feeds-packages ] && mv -f feeds-packages/openwrt-23.05/feeds/* openwrt/feeds-bump
[ -d openwrt-2203/target ] && mv -f openwrt-2203/target openwrt/target
[ -d openwrt-2203/patch-istoreos-${{matrix.target}} ] && mv -f openwrt-2203/patch-istoreos-${{matrix.target}}/* openwrt/patch-istoreos
git clone https://github.com/Ljzkirito/shadowsocks-rust openwrt/package/shadowsocks-rust
cd openwrt
$GITHUB_WORKSPACE/$DIY_SH patch-openwrt
echo "status=success" >> $GITHUB_OUTPUT
- name: 设置 IP 地址
if: github.event.inputs.SETIP != '192.168.66.1'
id: setip
run: |
IPSET_VALUE="${{ github.event.inputs.SETIP }}"
sed -i "s/192\.168\.66\.1/$IPSET_VALUE/g" openwrt/package/kochiya/autoset/files/zzz-autoset-rockchip
sed -i "s/192\.168\.66\.1/$IPSET_VALUE/g" openwrt/package/kochiya/autoset/files/zzz-autoset-meson
grep 'set network.lan.ipaddr=' openwrt/package/kochiya/autoset/files/zzz-autoset-rockchip
grep 'set network.lan.ipaddr=' openwrt/package/kochiya/autoset/files/zzz-autoset-meson
echo "status=success" >> $GITHUB_OUTPUT
- name: 更新 & 安装 feeds
if: steps.files.outputs.status == 'success'
id: feeds
run: |
cd openwrt
./scripts/feeds update -a
./scripts/feeds install -a
echo "status=success" >> $GITHUB_OUTPUT
- name: 自定义配置(修复feeds)
if: steps.feeds.outputs.status == 'success'
id: config
run: |
if [ "${{ matrix.repo }}" == "istoreos-22.03" ]; then
[ -d openwrt-2203/istoreos-luci-patch ] && mv -f openwrt-2203/istoreos-luci-patch openwrt/feeds/luci/istoreos-luci-patch
elif [ "${{ matrix.repo }}" == "main" ]; then
[ -d openwrt-main/lunatic7-revert ] && mv -f openwrt-main/lunatic7-revert openwrt/feeds/lunatic7/lunatic7-revert
[ -d openwrt-main/luci-patch ] && mv -f openwrt-main/luci-patch openwrt/feeds/luci/luci-patch
[ -d openwrt-main/feeds-package-patch ] && mv -f openwrt-main/feeds-package-patch openwrt/feeds/packages/feeds-package-patch
fi
[ -e files ] && mv files openwrt/files
[ -e package-configs ] && mv package-configs openwrt/package-configs
[ -e machine-configs/${{matrix.target}}.config ] && mv -f machine-configs/${{matrix.target}}.config openwrt/package-configs/.config
cd openwrt
$GITHUB_WORKSPACE/$DIY_SH ${{matrix.target}}
make defconfig
$GITHUB_WORKSPACE/$DIY_SH_RFC ${{matrix.target}}
echo "status=success" >> $GITHUB_OUTPUT
- name: 添加kmod
if: steps.config.outputs.status == 'success' && github.event.inputs.ALLKMOD == 'true'
id: config2
run: |
cd openwrt
$GITHUB_WORKSPACE/$DIY_SH_RFC kmod-istoreos
make defconfig
$GITHUB_WORKSPACE/$DIY_SH_RFC kmod-istoreos
make defconfig
$GITHUB_WORKSPACE/$DIY_SH_RFC kmod-istoreos
make defconfig
$GITHUB_WORKSPACE/$DIY_SH_RFC ${{matrix.target}}
echo "status=success" >> $GITHUB_OUTPUT
- name: Run awk command
if: steps.config.outputs.status == 'success'
working-directory: ./openwrt
run: |
echo "------------------------"
awk '/CONFIG_LINUX/ { print }' .config
awk '/${{matrix.target}}/ { print }' .config
awk '/${{github.event.inputs.MACH}}/ { print }' .config
echo "------------------------"
awk '/docker/ { print }' .config
echo "------------------------"
awk '/DOCKER/ { print }' .config
echo "------------------------"
awk '/store/ { print }' .config
echo "------------------------"
awk '/perl/ { print }' .config
echo "------------------------"
awk '/dnsmasq/ { print }' .config
echo "------------------------"
awk '/passwall/ { print }' .config
echo "------------------------"
awk '/nft/ { print }' .config
echo "------------------------"
awk '/firewall/ { print }' .config
echo "------------------------"
awk '/fullcone/ { print }' .config
echo "------------------------"
awk '/syncthing/ { print }' .config
echo "------------------------"
awk '/shadowsocks-rust/ { print }' .config
echo "------------------------"
awk '/rust/ { print }' .config
echo "------------------------"
awk '/GCC_VERSION/ { print }' .config
echo "------------------------"
awk '/CONFIG_PACKAGE_kmod/ { print }' .config
- name: 下载包文件
if: steps.config.outputs.status == 'success'
run: |
cd openwrt
make download -j$(nproc)
find dl -size -1024c -exec rm -f {} \;
- name: 缓存
uses: stupidloud/cachewrtbuild@main
if: github.event.inputs.Cache == 'true' && !cancelled()
with:
ccache: 'true'
mixkey: ${{ matrix.target }}
clean: ${{ contains(github.event.action, 'nocache') }}
prefix: ${{ github.workspace }}/openwrt
- name: 编译固件
id: compile
working-directory: ./openwrt
run: |
echo -e "$(($(nproc)+1)) thread compile"
make -j$(($(nproc)+1)) || make -j1 V=s
echo "status=success" >> $GITHUB_OUTPUT
- name: 检查空间使用情况
if: (!cancelled())
run: df -hT
- name: 上传bin目录
uses: actions/upload-artifact@main
continue-on-error: true
if: steps.compile.outputs.status == 'success' && env.UPLOAD_BIN_DIR == 'true'
with:
name: ${{ env.VERSION }}_${{matrix.target}}_${{ matrix.repo }}
path: |
openwrt/bin/
- name: 打包ipk成zip文件
id: afb
continue-on-error: true
if: steps.compile.outputs.status == 'success' && !cancelled()
run: |
$GITHUB_WORKSPACE/$DIY_SH_AFB
echo "status=success" >> $GITHUB_OUTPUT
- name: 整理文件
id: organize
if: env.UPLOAD_FIRMWARE == 'true' && steps.afb.outputs.status == 'success' && !cancelled()
run: |
mkdir firmware ipks
cp -u -f openwrt/kernelipks.zip ipks
cp -u -f openwrt/ipks.zip ipks
[ ${{github.event.inputs.UPLOAD_RELEASE}} = true ] && cp -u -f openwrt/kernelipks.zip firmware
[ ${{github.event.inputs.UPLOAD_RELEASE}} = true ] && cp -u -f openwrt/ipks.zip firmware
cp openwrt/.config ./firmware/${{matrix.target}}.config
cp openwrt/build_dir/target-*/linux-*/linux-*/.config ./firmware/${{matrix.target}}_kernel.config
mv -f openwrt/bin/targets/*/*/{*combined*,*ext4*,*sdk*,*imagebuilder*,*buildinfo*,*manifest*,*json*,*sha256sums*} ./firmware/ 2>/dev/null || true
[ $UPLOAD_SYSUPGRADE = true ] && mv -f openwrt/bin/targets/*/*/{*squashfs*,*sysupgrade*} ./firmware/ 2>/dev/null || true
cd firmware
echo "v${{ env.date2 }}" > version.txt
echo ${{matrix.target}} >> version.txt
rm -rf sha256sums
echo "FIRMWARE=$PWD" >> $GITHUB_ENV
echo "status=success" >> $GITHUB_OUTPUT
- name: 上传firmware目录
uses: actions/upload-artifact@main
continue-on-error: true
if: steps.organize.outputs.status == 'success' && env.UPLOAD_FIRMWARE == 'true'
with:
name: ${{ env.VERSION }}_${{matrix.target}}_firmware_${{ matrix.repo }}-${{github.event.inputs.MACH}}-${{ github.event.inputs.SETIP }}${{ env.Kernel_Test }}
path: |
firmware
- name: 上传ipk目录
uses: actions/upload-artifact@main
continue-on-error: true
if: steps.organize.outputs.status == 'success' && env.UPLOAD_IPK_DIR == 'true' && steps.afb.outputs.status == 'success'
with:
name: ${{ env.VERSION }}_${{matrix.target}}_ipks_${{ matrix.repo }}-${{github.event.inputs.MACH}}${{ env.Kernel_Test }}
path: |
ipks
- name: 上传固件cowtransfer
id: cowtransfer
if: steps.organize.outputs.status == 'success' && env.UPLOAD_COWTRANSFER == 'true' && !cancelled()
run: |
curl -fsSL git.io/file-transfer | sh
./transfer cow --block 2621440 -s -p 64 --no-progress ${FIRMWARE} 2>&1 | tee cowtransfer.log
echo "::warning file=cowtransfer.com::$(cat cowtransfer.log | grep https)"
echo "url=$(cat cowtransfer.log | grep https | cut -f3 -d" ")" >> $GITHUB_OUTPUT
- name: 上传固件WeTransfer
id: wetransfer
if: steps.organize.outputs.status == 'success' && env.UPLOAD_WETRANSFER == 'true' && !cancelled()
run: |
curl -fsSL git.io/file-transfer | sh
./transfer wet -s -p 16 --no-progress ${FIRMWARE} 2>&1 | tee wetransfer.log
echo "::warning file=wetransfer.com::$(cat wetransfer.log | grep https)"
echo "url=$(cat wetransfer.log | grep https | cut -f3 -d" ")" >> $GITHUB_OUTPUT
- name: 生成发布标签
id: tag
if: steps.organize.outputs.status == 'success' && github.event.inputs.UPLOAD_RELEASE == 'true' && !cancelled()
run: |
touch release.txt
$GITHUB_WORKSPACE/gen-sha256sum.sh
echo "# 当前固件IP地址:"${{ github.event.inputs.SETIP }}" " >> release.txt
[ $UPLOAD_COWTRANSFER = true ] && echo "🔗 [Cowtransfer](${{ steps.cowtransfer.outputs.url }})" >> release.txt
[ $UPLOAD_WETRANSFER = true ] && echo "🔗 [WeTransfer](${{ steps.wetransfer.outputs.url }})" >> release.txt
echo "status=success" >> $GITHUB_OUTPUT
- name: 上传固件发布
uses: softprops/action-gh-release@v2
if: steps.tag.outputs.status == 'success' && !cancelled()
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
files: "${{ env.FIRMWARE }}/*"
name: ${{ env.date }} ${{matrix.target}}-${{github.event.inputs.MACH}}-${{ matrix.repo }}
tag_name: ${{ env.date }}_${{matrix.target}}-${{github.event.inputs.MACH}}-${{ matrix.repo }}
body_path: release.txt
- name: 删除工作流
uses: Mattraks/delete-workflow-runs@main
continue-on-error: true
with:
retain_days: 6
keep_minimum_runs: 9
- name: 删除旧版本
uses: dev-drprasad/delete-older-releases@master
continue-on-error: true
if: env.UPLOAD_RELEASE == 'true' && !cancelled()
with:
keep_latest: 24
delete_tags: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}