-
Notifications
You must be signed in to change notification settings - Fork 21
239 lines (232 loc) · 11.5 KB
/
Build MI-R4A Padavan-4.4.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
# 注意:修改 default: 中的型号为你需要编译的型号,注意名称要与configs/templates/目录下的名字相同
name: Build MI-R4A Padavan-4.4
on:
workflow_dispatch:
inputs:
production:
description: 设置编译的固件型号,空格分隔.
default: "MI-R4A"
required: false
release:
description: "是否需要发布到Release? (不发布也可以到Artifacts下载)"
default: 'yes'
required: false
env:
TNAME: ${{ github.event.inputs.production }}
REPOSITORY_URL: https://github.com/vipshmily/padavan-4.4.git
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@main
- uses: hendrikmuhs/ccache-action@main
with:
key: ${{ github.event.inputs.production }}-4.4
- uses: actions/setup-go@main
with:
go-version: '1.23'
check-latest: true
cache: false
- uses: actions/setup-node@main
with:
node-version: 22
check-latest: true
- name: Generate version number
run: |
whoami
id
echo input parameters received:
echo $TNAME
echo ${{ github.event.inputs.release }}
echo
echo 当前目录:$(pwd)
# 版本号,用日期
VERSION=$(TZ='Asia/Shanghai' date +%Y.%m.%d-%H%M)
echo "VERSION=$VERSION" >> $GITHUB_ENV
# $GITHUB_ENV变量必须要在下一个流程才生效
echo "DIR=/opt/rt-n56u" >> $GITHUB_ENV
val1=$TNAME
#val2=$(echo $val1 | sed 's/ /-/')
echo "NAME=${val1}_4.4_$VERSION" >> $GITHUB_ENV
echo "TAG=v$VERSION" >> $GITHUB_ENV
ip addr
- name: Create a directory
run: |
echo ${{ env.NAME }}
echo ${{ env.TAG }}
sudo mkdir -m 777 -p ${{ env.DIR }}
sudo mkdir -m 777 -p /opt/images/
echo 开始编译时间 >> /opt/images/readme.txt
TZ='Asia/Shanghai' date '+%Y-%m-%d %H:%M:%S' >> /opt/images/readme.txt
- name: Prepare environment
run: |
sudo apt update
sudo apt install libtool-bin gperf python3-docutils autopoint gettext ccache
- name: Clone source code
run: |
git clone --depth=1 $REPOSITORY_URL ${{ env.DIR }}
cd ${{ env.DIR }}
sed -i '/cp -f/d' Makefile
mkdir -p /opt/images/
- name: Build firmware
run: |
if [ -f public/adguardhome.Makefile ] ; then
mv -f public/adguardhome.Makefile ${{ env.DIR }}/trunk/user/adguardhome/Makefile
echo "Makefile file copy success"
else
exit 1
fi
#cp -f public/MI-R4A.config ${{ env.DIR }}/trunk/configs/templates
cp -f public/adguardhome.sh ${{ env.DIR }}/trunk/user/adguardhome
cd ${{ env.DIR }}/trunk
for m in $TNAME;
do
if [ ! -f configs/templates/$m.config ] ; then
echo "configs/templates/$m.config not found "
exit 0
fi
cp -f configs/templates/$m.config .config
sed -i 's/CONFIG_FIRMWARE_INCLUDE_OPENSSL_EXE=n/CONFIG_FIRMWARE_INCLUDE_OPENSSL_EXE=y/g' .config
############################################################################################
#因不同型号配置功能不一样,所以先把配置项删除,如果你自己要添加其他的,也要写上删除这一条,切记!!!
############################################################################################
sed -i '/CONFIG_FIRMWARE_INCLUDE_MENTOHUST/d' .config #删除配置项MENTOHUST
sed -i '/CONFIG_FIRMWARE_INCLUDE_SOFTETHERVPN_SERVER/d' .config #删除配置项SOFTETHERVPN
sed -i '/CONFIG_FIRMWARE_INCLUDE_SOFTETHERVPN_CLIENT/d' .config #删除配置项SOFTETHERVPN
sed -i '/CONFIG_FIRMWARE_INCLUDE_SOFTETHERVPN_CMD/d' .config #删除配置项SOFTETHERVPN
sed -i '/CONFIG_FIRMWARE_INCLUDE_SCUTCLIENT/d' .config #删除配置项SCUTCLIENT
sed -i '/CONFIG_FIRMWARE_INCLUDE_SHADOWSOCKS/d' .config #删除配置项SS plus+
sed -i '/CONFIG_FIRMWARE_INCLUDE_SSSERVER/d' .config #删除配置项SS server
sed -i '/CONFIG_FIRMWARE_INCLUDE_DNSFORWARDER/d' .config #删除配置项DNSFORWARDER
sed -i '/CONFIG_FIRMWARE_INCLUDE_ADBYBY/d' .config #删除配置项adbyby plus+
sed -i '/CONFIG_FIRMWARE_INCLUDE_FRPC/d' .config #删除配置项FRPC
sed -i '/CONFIG_FIRMWARE_INCLUDE_FRPS/d' .config #删除配置项FRPS
sed -i '/CONFIG_FIRMWARE_INCLUDE_TUNSAFE/d' .config #删除配置项TUNSAFE
sed -i '/CONFIG_FIRMWARE_INCLUDE_ALIDDNS/d' .config #删除配置项阿里DDNS
sed -i '/CONFIG_FIRMWARE_INCLUDE_SMARTDNS/d' .config #删除配置项SMARTDNS
sed -i '/CONFIG_FIRMWARE_INCLUDE_SRELAY/d' .config #删除配置项SRELAY
sed -i '/CONFIG_FIRMWARE_INCLUDE_KUMASOCKS/d' .config #删除配置项KUMASOCKS
sed -i '/CONFIG_FIRMWARE_INCLUDE_SSOBFS/d' .config
sed -i '/CONFIG_FIRMWARE_INCLUDE_V2RAY/d' .config
sed -i '/CONFIG_FIRMWARE_INCLUDE_XRAY/d' .config
sed -i '/CONFIG_FIRMWARE_INCLUDE_TROJAN/d' .config
sed -i '/CONFIG_FIRMWARE_INCLUDE_KOOLPROXY/d' .config
sed -i '/CONFIG_FIRMWARE_INCLUDE_SMARTDNSBIN/d' .config
sed -i '/CONFIG_FIRMWARE_INCLUDE_ADGUARDHOME/d' .config
sed -i '/CONFIG_FIRMWARE_INCLUDE_CADDY/d' .config
sed -i '/CONFIG_FIRMWARE_INCLUDE_CADDYBIN/d' .config
sed -i '/CONFIG_FIRMWARE_INCLUDE_WYY/d' .config
sed -i '/CONFIG_FIRMWARE_INCLUDE_WYYBIN/d' .config
sed -i '/CONFIG_FIRMWARE_INCLUDE_ZEROTIER/d' .config
sed -i '/CONFIG_FIRMWARE_INCLUDE_DDNSTO/d' .config
sed -i '/CONFIG_FIRMWARE_INCLUDE_WIREGUARD/d' .config
sed -i '/CONFIG_FIRMWARE_INCLUDE_ALDRIVER/d' .config
sed -i '/CONFIG_FIRMWARE_INCLUDE_SQM/d' .config
sed -i '/CONFIG_FIRMWARE_INCLUDE_MSD_LITE/d' .config
sed -i '/CONFIG_FIRMWARE_INCLUDE_IPERF3/d' .config
sed -i '/CONFIG_FIRMWARE_INCLUDE_OC/d' .config
sed -i '/CONFIG_FIRMWARE_MT7621_OC/d' .config
sed -i 's/CONFIG_FIRMWARE_INCLUDE_OPENSSL_EXE=n/CONFIG_FIRMWARE_INCLUDE_OPENSSL_EXE=y/g' .config
######################################################################
#以下选项是定义你需要的功能(y=集成,n=忽略),重新写入到.config文件
######################################################################
echo "CONFIG_FIRMWARE_INCLUDE_MENTOHUST=n" >> .config #MENTOHUST
echo "CONFIG_FIRMWARE_INCLUDE_SCUTCLIENT=n" >> .config #SCUTCLIENT
echo "CONFIG_FIRMWARE_INCLUDE_SSSERVER=n" >> .config #SS server
echo "CONFIG_FIRMWARE_INCLUDE_DNSFORWARDER=n" >> .config #DNSFORWARDER
echo "CONFIG_FIRMWARE_INCLUDE_TUNSAFE=n" >> .config #TUNSAFE
echo "CONFIG_FIRMWARE_INCLUDE_SRELAY=n" >> .config #可以不集成
##科学上网##
echo "CONFIG_FIRMWARE_INCLUDE_SHADOWSOCKS=y" >> .config #科学上网插件,选择n后全部有关插件都不集成
echo "CONFIG_FIRMWARE_INCLUDE_SSOBFS=n" >> .config # simple-obfs混淆插件
echo "CONFIG_FIRMWARE_INCLUDE_V2RAY=n" >> .config #集成v2ray执行文件(3.6M左右)
echo "CONFIG_FIRMWARE_INCLUDE_XRAY=y" >> .config #集成xray执行文件(3.6M左右)
echo "CONFIG_FIRMWARE_INCLUDE_TROJAN=y" >> .config #集成trojan执行文件(1.1M左右)
echo "CONFIG_FIRMWARE_INCLUDE_KUMASOCKS=n" >> .config #socks5服务端
##科学上网##
##广告管理##
echo "CONFIG_FIRMWARE_INCLUDE_ADBYBY=y" >> .config #adbyby plus+
echo "CONFIG_FIRMWARE_INCLUDE_KOOLPROXY=n" >> .config #KP广告过滤
##广告管理##
##DNS服务##
echo "CONFIG_FIRMWARE_INCLUDE_SMARTDNS=y" >> .config #smartdns
echo "CONFIG_FIRMWARE_INCLUDE_SMARTDNSBIN=n" >> .config #smartdns二进制文件
echo "CONFIG_FIRMWARE_INCLUDE_ADGUARDHOME=y" >> .config #adg DNS去AD
##DNS服务##
##文件管理##
echo "CONFIG_FIRMWARE_INCLUDE_CADDY=n" >> .config #在线文件管理服务
echo "CONFIG_FIRMWARE_INCLUDE_CADDYBIN=n" >> .config #集成caddu执行文件,此文件有13M,请注意固件大小。如果不集成,会从网上下载下来执行,不影响正常使用
##文件管理##
##音乐解锁##
echo "CONFIG_FIRMWARE_INCLUDE_WYY=n" >> .config #网易云解锁
echo "CONFIG_FIRMWARE_INCLUDE_WYYBIN=n" >> .config #网易云解锁GO版本执行文件(4M多)注意固件超大小,不集成会自动下载
##音乐解锁##
##内网穿透服务##
echo "CONFIG_FIRMWARE_INCLUDE_ZEROTIER=y" >> .config #zerotier ~1.3M
echo "CONFIG_FIRMWARE_INCLUDE_ALIDDNS=n" >> .config #阿里DDNS
echo "CONFIG_FIRMWARE_INCLUDE_FRPC=n" >> .config #内网穿透FRPC
echo "CONFIG_FIRMWARE_INCLUDE_FRPS=n" >> .config #内网穿透FRPS
echo "CONFIG_FIRMWARE_INCLUDE_DDNSTO=n" >> .config #ddnsto ~0.5M
echo "CONFIG_FIRMWARE_INCLUDE_WIREGUARD=n" >>.config #wireguard 10k
##内网穿透服务##
echo "CONFIG_FIRMWARE_INCLUDE_ALDRIVER=n" >> .config #ALDRIVER ~3m
echo "CONFIG_FIRMWARE_INCLUDE_SQM=y" >> .config #SQM
echo "CONFIG_FIRMWARE_INCLUDE_MSD_LITE=y" >> .config #MSD_LITE
echo "CONFIG_FIRMWARE_INCLUDE_IPERF3=y" >> .config #IPERF3
#CPU超频
echo "CONFIG_FIRMWARE_INCLUDE_OC=y" >> .config #CPU超频开关
echo 'CONFIG_FIRMWARE_MT7621_OC="0x3B2"' >> .config #此处填写对应频率的十六进制:1000Mhz=0x312 1100Mhz=0x362 1120Mhz=0x372 1200Mhz=0x3B2
#########################################################################################
# 自定义添加其它功能请参考源码configs/templates/目录下的config文件。按照上面的格式添加即可
# 格式如下:
# sed -i '/自定义项/d' .config
# echo "自定义项=y" >> .config
#########################################################################################
cd ${{ env.DIR }}
sudo make $m
cd ${{ env.DIR }}/trunk
sudo mv -f images/*.trx /opt/images/
done
- name: Collect information
if: true
run: |
cd /opt/images
#记录一个版本号
echo 完成编译时间 >> /opt/images/readme.txt
TZ='Asia/Shanghai' date '+%Y-%m-%d %H:%M:%S' >> /opt/images/readme.txt
echo >> /opt/images/readme.txt
echo 编译版本 >> /opt/images/readme.txt
pushd ${{ env.DIR }}
git ls-remote --get-url origin >> /opt/images/readme.txt
git log -1 >> /opt/images/readme.txt
popd
echo >> /opt/images/readme.txt
echo md5校验值 >> /opt/images/readme.txt
cd /opt/images
#为固件文件名加上日期
for i in *.trx
do
#echo org $i
mv -v "$i" "${i%.*}-${{ env.VERSION }}.trx"
done
#测试
md5sum *.trx >> /opt/images/readme.txt || echo
ls -l
- name : Upload images to Artifact
uses: actions/upload-artifact@main
if: true
with:
name: ${{ env.NAME }}
path: /opt/images
- name: Upload images to Releases
if: ${{ github.event.inputs.release == 'yes' }}
uses: softprops/action-gh-release@master
with:
name: ${{ env.NAME }}
tag_name: ${{ env.TAG }}
body_path: /opt/images/readme.txt
draft: false
prerelease: false
files: /opt/images/*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}