-
Notifications
You must be signed in to change notification settings - Fork 4
300 lines (264 loc) · 9.82 KB
/
Build-MI-R3G-Lede-504.yml
File metadata and controls
300 lines (264 loc) · 9.82 KB
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
#
# Copyright (c) 2019-2020 P3TERX <https://p3terx.com>
#
# This is free software, licensed under the MIT License.
# See /LICENSE for more information.
#
# https://github.com/P3TERX/Actions-OpenWrt
# Description: Build OpenWrt using GitHub Actions
#
name: Build OpenWrt 504
on:
repository_dispatch:
workflow_dispatch:
inputs:
ssh:
description: 'SSH connection to Actions'
required: false
default: 'false'
watch:
types: [started]
env:
REPO_URL: https://github.com/coolsnowwolf/lede
REPO_BRANCH: master
UPLOAD_BIN_DIR: true
UPLOAD_FIRMWARE: true
UPLOAD_RELEASE: true
DIY_SH: diy.sh
TZ: Asia/Shanghai
jobs:
build:
runs-on: Ubuntu-22.04
# if: github.event.repository.owner.id == github.event.sender.id
steps:
- name: Checkout
uses: actions/checkout@main
- name: Initialization environment
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 $(curl -fsSL https://is.gd/depends_ubuntu_2204)
sudo -E apt-get -qq autoremove --purge
sudo -E apt-get -qq clean
sudo -E apt-get -qq install libfuse-dev
sudo timedatectl set-timezone "$TZ"
sudo chmod 777 /mnt
- name: Clone source code
working-directory: /mnt
run: |
df -hT $PWD
git clone $REPO_URL -b $REPO_BRANCH openwrt
ln -sf /mnt/openwrt $GITHUB_WORKSPACE/openwrt
cd openwrt
useVersionInfo=$(git show -s --date=short --format="Author: %an<br/>date: %cd<br/>commit: %s<br/>commit hash: %H<br/>")
echo "useVersionInfo=$useVersionInfo" >> $GITHUB_ENV
- name: Cache
uses: klever1988/cachewrtbuild@main
with:
ccache: 'true'
prefix: ${{ github.workspace }}/openwrt
- name: Update feeds
run: cd openwrt && ./scripts/feeds update -a && ./scripts/feeds install -a
- name: File Diy Patch
run: |
chmod +x $DIY_SH
cd openwrt
$GITHUB_WORKSPACE/$DIY_SH
- name: Generate configuration file
run: |
cd openwrt
rm -f ./.config*
touch ./.config
#
# ========================固件定制部分========================
#
#
# 如果不对本区块做出任何编辑, 则生成默认配置固件.
#
# 以下为定制化固件选项和说明:
#
#
# 有些插件/选项是默认开启的, 如果想要关闭, 请参照以下示例进行编写:
#
# =========================================
# | # 取消编译VMware镜像: |
# | cat >> .config <<EOF |
# | # CONFIG_VMDK_IMAGES is not set |
# | EOF |
# =========================================
#
#
# 以下是一些提前准备好的一些插件选项.
# 直接取消注释相应代码块即可应用. 不要取消注释代码块上的汉字说明.
# 如果不需要代码块里的某一项配置, 只需要删除相应行.
#
# 如果需要其他插件, 请按照示例自行添加.
# 注意, 只需添加依赖链顶端的包. 如果你需要插件 A, 同时 A 依赖 B, 即只需要添加 A.
#
# 无论你想要对固件进行怎样的定制, 都需要且只需要修改 EOF 回环内的内容.
#
# 编译MI-R3G固件:
cat >> .config <<EOF
CONFIG_TARGET_ramips=y
CONFIG_TARGET_ramips_mt7621=y
CONFIG_TARGET_ramips_mt7621_DEVICE_xiaomi_mi-router-3g=y
CONFIG_LINUX_5_4=y
CONFIG_TESTING_KERNEL=y
EOF
# IPv6支持:
cat >> .config <<EOF
CONFIG_PACKAGE_dnsmasq_full_dhcpv6=y
CONFIG_PACKAGE_ip6tables=y
CONFIG_PACKAGE_ip6tables-extra=y
CONFIG_PACKAGE_ip6tables-mod-nat=y
CONFIG_PACKAGE_ipv6helper=y
EOF
# LuCI插件选择:
cat >> .config <<EOF
CONFIG_PACKAGE_luci-app-passwall=y
CONFIG_PACKAGE_luci-app-autoreboot=y
CONFIG_PACKAGE_luci-app-ddns=y
CONFIG_PACKAGE_easytier=y
CONFIG_PACKAGE_luci-app-easytier=y
CONFIG_PACKAGE_luci-app-filetransfer=y
CONFIG_PACKAGE_luci-app-filebrowser=y
CONFIG_PACKAGE_luci-app-nlbwmon=y
CONFIG_PACKAGE_luci-app-firewall=y
CONFIG_PACKAGE_luci-app-ssr-plus=y
CONFIG_PACKAGE_luci-app-ssr-plus_INCLUDE_Xray=y
CONFIG_PACKAGE_luci-app-openlist2=y
CONFIG_PACKAGE_luci-app-pptp-server=y
# CONFIG_PACKAGE_luci-app-samba4 is not set
CONFIG_PACKAGE_luci-app-smartdns=y
CONFIG_PACKAGE_luci-app-ttyd=y
CONFIG_PACKAGE_luci-app-webadmin=y
CONFIG_PACKAGE_luci-app-wol=y
CONFIG_PACKAGE_luci-app-watchcat=y
CONFIG_PACKAGE_luci-app-wechatpush=y
CONFIG_PACKAGE_luci-app-wrtbwmon=y
CONFIG_PACKAGE_luci-app-ramfree=y
CONFIG_PACKAGE_luci-app-usb-printer=y
CONFIG_PACKAGE_luci-app-upnp=y
CONFIG_PACKAGE_luci-app-vsftpd=y
CONFIG_PACKAGE_luci-app-vlmcsd=y
CONFIG_PACKAGE_luci-app-zerotier=y
CONFIG_PACKAGE_luci-app-adguardhome=y
CONFIG_PACKAGE_luci-app-sqm=y
CONFIG_PACKAGE_luci-app-mosdns=y
CONFIG_PACKAGE_luci-app-turboacc=y
EOF
# LuCI主题:
cat >> .config <<EOF
CONFIG_PACKAGE_luci-theme-argon=y
CONFIG_PACKAGE_luci-app-argon-config=y
# CONFIG_PACKAGE_luci-theme-design is net set
EOF
# 常用软件包:
cat >> .config <<EOF
CONFIG_PACKAGE_kmod-sched-red=y
# CONFIG_PACKAGE_luci-app-unblockmusic is net set
EOF
# 取消编译VMware镜像以及镜像填充 (不要删除被缩进的注释符号):
# cat >> .config <<EOF
# # CONFIG_TARGET_IMAGES_PAD is not set
# # CONFIG_VMDK_IMAGES is not set
# EOF
#
# ========================固件定制部分结束========================
#
sed -i 's/^[ \t]*//g' ./.config
make defconfig
- name: SSH connection to Actions
uses: P3TERX/ssh2actions@v1.0.0
if: (github.event.inputs.ssh == 'true' && github.event.inputs.ssh != 'false') || contains(github.event.action, 'ssh')
env:
TELEGRAM_CHAT_ID: ${{ secrets.TELEGRAM_CHAT_ID }}
TELEGRAM_BOT_TOKEN: ${{ secrets.TELEGRAM_BOT_TOKEN }}
- name: Download package
id: package
run: |
cd openwrt
make download -j8
find dl -size -1024c -exec ls -l {} \;
find dl -size -1024c -exec rm -f {} \;
- name: Compile the firmware
id: compile
run: |
cd openwrt
echo -e "$(nproc) thread compile"
make -j$(nproc)
echo "status=success" >> ${GITHUB_OUTPUT}
grep '^CONFIG_TARGET.*DEVICE.*=y' .config | sed -r 's/.*DEVICE_(.*)=y/\1/' > DEVICE_NAME
[ -s DEVICE_NAME ] && echo "DEVICE_NAME=_$(cat DEVICE_NAME)" >> $GITHUB_ENV
echo "FILE_DATE=_$(date +"%Y%m%d%H%M")" >> $GITHUB_ENV
- name: Compile debug
if: ${{ failure() && steps.compile.conclusion == 'failure' }}
run: |
cd openwrt
echo -e "1 thread compile debug"
make -j1 V=s
- name: Check space usage
if: steps.compile.outputs.status == 'success' && !cancelled()
run: df -hT
- name: Organize files
id: organize
if: steps.compile.outputs.status == 'success' && !cancelled()
run: |
cd $GITHUB_WORKSPACE/openwrt/bin/packages
tar -zcvf Packages.tar.gz ./*
cp Packages.tar.gz $GITHUB_WORKSPACE/openwrt/bin/targets/*/*
cd $GITHUB_WORKSPACE/openwrt/bin/targets/*/*
cp $GITHUB_WORKSPACE/openwrt/.config ./config.txt
rm -rf packages
echo "FIRMWARE=$PWD" >> $GITHUB_ENV
echo "status=success" >> ${GITHUB_OUTPUT}
echo "release_tag=$(date +"%Y.%m.%d-%H%M")" >> $GITHUB_OUTPUT
- name: Calculate MD5
run: |
cd ${{ env.FIRMWARE }} && rm -rf sha256sums
MD5=$(md5sum * | sed ':a;N;$!ba;s/\n/<br>/g')
echo "MD5=$MD5" >> $GITHUB_ENV
- name: Upload firmware directory
uses: actions/upload-artifact@main
if: steps.organize.outputs.status == 'success' && !cancelled()
with:
name: OpenWrt_firmware${{ env.DEVICE_NAME }}${{ env.FILE_DATE }}
path: ${{ env.FIRMWARE }}
- name: Upload OpenWrt Firmware to Release
id: release
uses: ncipollo/release-action@main
if: steps.organize.outputs.status == 'success' && env.UPLOAD_RELEASE == 'true' && !cancelled()
with:
name: R${{ steps.organize.outputs.release_tag }} for MI-R3G
allowUpdates: true
removeArtifacts: true
tag: 504-${{ steps.organize.outputs.release_tag }}
commit: main
token: ${{ secrets.GITHUB_TOKEN }}
artifacts: ${{ env.FIRMWARE }}/*
body: |
- 默认IP:192.168.10.1
- 默认密码:password
- 内核版本:5.4
- 当前使用版本:【编译前的最后一次[➦主源码](${{ env.REPO_URL }})更新记录】
- 下载后请仔细校验MD5,如不正确请重新下载
${{ env.useVersionInfo }}
`md5sum`
> ${{ env.MD5 }}
- name: Delete workflow runs
uses: Mattraks/delete-workflow-runs@main
with:
token: ${{ github.token }}
repository: ${{ github.repository }}
retain_days: 60
keep_minimum_runs: 60
- name: Remove old Releases
uses: dev-drprasad/delete-older-releases@master
if: env.UPLOAD_RELEASE == 'true' && !cancelled()
with:
keep_latest: 8
delete_tags: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}