-
Notifications
You must be signed in to change notification settings - Fork 4
executable file
·376 lines (346 loc) · 14.5 KB
/
op.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
name: openwrt
on:
repository_dispatch:
workflow_dispatch:
inputs:
ENABLE_DHCP:
description: '是否开启DHCP'
required: false
default: 'false'
type: boolean
ENABLE_Cache:
description: '缓存加速'
required: false
default: 'true'
type: boolean
OP_IP:
description: '静态IP地址'
required: false
default: '192.168.2.2'
type: string
OP_rootfs:
description: '预设镜像大小'
required: false
default: '600'
type: string
OP_author:
description: '定制作者'
required: false
default: 'shiyu1314'
type: string
CUSTOM_PLUGINS:
description: '自定义插件名称,用空格分隔'
required: false
default: 'luci-app-dockerman luci-theme-argon luci-app-argon-config luci-app-ttyd luci-app-diskman luci-app-hd-idle luci-app-mihomo luci-app-samba4 luci-app-emby luci-app-aria2 luci-app-alist luci-app-adguardhome'
type: string
env:
DIY_P1_SH: sh/op.sh
DIY_P2_SH: sh/ad.sh
jobs:
build_firmware:
name: 编译固件
runs-on: ubuntu-22.04
strategy:
matrix:
repo_info:
- {branch: "openwrt-23.05"}
steps:
- name: 检查分支
uses: actions/checkout@v4
- name: 释放磁盘空间
run: |
sudo rm -rf /etc/apt/sources.list.d
sudo swapoff -a
sudo rm -f /swapfile /mnt/swapfile
sudo docker image prune -a -f
sudo systemctl stop docker
sudo snap set system refresh.retain=2
sudo apt-get -y purge firefox clang* ghc* google* llvm* mono* mongo* mysql* php*
sudo apt-get -y autoremove --purge
sudo apt-get clean
sudo rm -rf /etc/mysql /etc/php /usr/lib/jvm /usr/libexec/docker /usr/local /usr/src/* /var/lib/docker /var/lib/gems /var/lib/mysql /var/lib/snapd /etc/skel /opt/{microsoft,az,hostedtoolcache,cni,mssql-tools,pipx} /usr/share/{az*,dotnet,swift,miniconda,gradle*,java,kotlinc,ri,sbt} /root/{.sbt,.local,.npm}
sudo sed -i '/NVM_DIR/d;/skel/d' /root/{.bashrc,.profile}
rm -rf ~/{.cargo,.dotnet,.rustup}
df -Th
- name: 编译环境
env:
DEBIAN_FRONTEND: noninteractive
run: |
sudo apt-get update
sudo apt-get install -y tar img2simg build-essential flex bison cmake g++ gawk gcc-multilib g++-multilib gettext git libfuse-dev libncurses5-dev libssl-dev python3 python3-pip python3-ply python3-distutils python3-pyelftools rsync unzip zlib1g-dev file wget subversion patch upx-ucl autoconf automake curl asciidoc binutils bzip2 lib32gcc-s1 libc6-dev-i386 uglifyjs msmtp texinfo libreadline-dev libglib2.0-dev xmlto libelf-dev libtool autopoint antlr3 gperf ccache swig coreutils haveged scons libpython3-dev rename qemu-utils
sudo apt-get clean
git config --global user.name 'GitHub Actions' && git config --global user.email 'noreply@github.com'
sudo timedatectl set-timezone 'Asia/Shanghai'
sudo mkdir -p /workdir
sudo chown $USER:$GROUPS /workdir
df -Th
- name: 设置环境变量
run: |
TAG="$(date +'%Y%m%d')-$(openssl rand -hex 3)"
echo "tag=$TAG" >> $GITHUB_ENV
echo "REPO_URL=https://github.com/openwrt/openwrt" >> $GITHUB_ENV
echo "REPO_BRANCH=${{ matrix.repo_info.branch }}" >> $GITHUB_ENV
echo "OP_IP=${{ github.event.inputs.OP_IP }}" >> $GITHUB_ENV
echo "OP_author=${{ github.event.inputs.OP_author }}" >> $GITHUB_ENV
echo "OP_rootfs=${{ github.event.inputs.OP_rootfs }}" >> $GITHUB_ENV
echo "CUSTOM_PLUGINS=${{ github.event.inputs.CUSTOM_PLUGINS }}" >> $GITHUB_ENV
echo "ENABLE_DHCP=${{ github.event.inputs.ENABLE_DHCP }}" >> $GITHUB_ENV
echo "ENABLE_Cache=${{ github.event.inputs.ENABLE_Cache }}" >> $GITHUB_ENV
- name: 克隆源代码
working-directory: /workdir
run: |
df -hT $PWD
git clone $REPO_URL openwrt
ln -sf /workdir/openwrt $GITHUB_WORKSPACE/openwrt
- name: 切换23.05
working-directory: ./openwrt
id: var
run: |
case $REPO_BRANCH in
openwrt-23.05)
_release_tag=$(git tag --sort=taggerdate --list 'v23.*' | tail -1)
git checkout $_release_tag
_prerelease=false
;;
*)
echo "Can't get local/upstream's branch/tags"
;;
esac
echo "release_tag=$_release_tag" >> $GITHUB_ENV
if [[ "${{ github.event.inputs.ENABLE_Cache }}" == "true" ]]; then
git clone -b 23.05 --depth 1 --single-branch https://github.com/shiyu1314/openwrt-onecloud staging_dir
fi
ls
- name: 添加6.11内核
run: |
rm -rf openwrt/package/kernel/linux/modules/[a-z]*.mk
[ -e patch ] && cp -rf patch/modules/*.mk openwrt/package/kernel/linux/modules
[ -e tags ] && cp -rf tags/kernel-6.11 openwrt/include
rm -rf openwrt/target/linux/generic
git clone https://shiyu1314:${{ secrets.PERSONAL_ACCESS_TOKEN }}@github.com/shiyu1314/target_linux_generic -b 6.11 openwrt/target/linux/generic
cd openwrt
./scripts/feeds update -a
cd ..
[ -e patch ] && cp -rf patch/luci/*.patch openwrt/feeds/luci
[ -e patch ] && cp -rf patch/nginx/nginx-util/*.patch openwrt/feeds/packages
[ -e patch ] && cp -rf patch/openssl/quic/*.patch openwrt/package/libs/openssl/patches
[ -e patch ] && cp -rf patch/generic/*.patch openwrt
mkdir -p openwrt/package/utils/util-linux/patches
[ -e patch ] && cp -rf patch/util-linux/201-util-linux_ntfs3.patch openwrt/package/utils/util-linux/patches
[ -e patch ] && cp -rf patch/fstools/Makefile openwrt/package/system/fstools
sed -i 's|$(PROJECT_GIT)/project|https://github.com/openwrt|g' openwrt/package/system/fstools/Makefile
mkdir -p openwrt/package/system/fstools/patches
[ -e patch ] && cp -rf patch/fstools/*.patch openwrt/package/system/fstools/patches
[ -e patch ] && cp -rf patch/luci/dhcp/dhcp.js openwrt/feeds/luci/modules/luci-mod-network/htdocs/luci-static/resources/view/network
[ -e patch ] && cp -rf patch/luci/dhcp/dnsmasq.init openwrt/package/network/services/dnsmasq/files
# odhcpd RFC-9096
mkdir -p openwrt/package/network/services/odhcpd/patches
[ -e patch ] && cp -rf patch/odhcpd/*.patch openwrt/package/network/services/odhcpd/patches
ls openwrt/target/linux/generic
- name: 加载自定义脚本
run: |
chmod +x $DIY_P1_SH
cd openwrt
$GITHUB_WORKSPACE/$DIY_P1_SH
cd ..
[ -e patch ] && cp -rf patch/nginx/luci.locations openwrt/feeds/packages/net/nginx/files-luci-support
[ -e patch ] && cp -rf patch/nginx/uci.conf.template openwrt/feeds/packages/net/nginx-util/files
[ -e patch ] && cp -rf patch/kernel-6.11/bbr3/*.patch openwrt/target/linux/generic/backport-6.11
[ -e patch ] && cp -rf patch/kernel-6.11/btf/*.patch openwrt/target/linux/generic/hack-6.11
- name: 添加玩客云
run: |
git clone https://shiyu1314:${{ secrets.PERSONAL_ACCESS_TOKEN }}@github.com/shiyu1314/s805 -b 6.11 openwrt/target/linux/amlogic
- name: 下载ad核心
run: |
chmod +x $DIY_P2_SH
$GITHUB_WORKSPACE/$DIY_P2_SH
- name: 加载自定义配置
run: |
[ -e files ] && mv files openwrt/files
cat <<EOF >>openwrt/.config
CONFIG_TARGET_amlogic=y
CONFIG_TARGET_amlogic_meson8b=y
CONFIG_TARGET_amlogic_meson8b_DEVICE_thunder-onecloud=y
CONFIG_TARGET_KERNEL_PARTSIZE=32
CONFIG_TARGET_ROOTFS_PARTSIZE=${{ github.event.inputs.OP_rootfs }}
CONFIG_KERNEL_EXT4_FS_SECURITY=y
# CONFIG_TARGET_ROOTFS_SQUASHFS is not set
CONFIG_PACKAGE_dnsmasq-full=y
CONFIG_PACKAGE_dnsmasq_full_ipset=y
# CONFIG_PACKAGE_dnsmasq_full_broken_rtc is not set
# CONFIG_PACKAGE_dnsmasq is not set
CONFIG_PACKAGE_luci-app-firewall=y
CONFIG_PACKAGE_bash=y
CONFIG_PACKAGE_bash-completion=y
CONFIG_PACKAGE_fuse-utils=y
CONFIG_PACKAGE_ethtool=y
CONFIG_PACKAGE_automount=y
CONFIG_PACKAGE_autocore-arm=y
CONFIG_PACKAGE_autosamba=y
CONFIG_PACKAGE_my-default-settings=y
### Luci
CONFIG_PACKAGE_ariang-nginx=y
### Kernel Modules
CONFIG_PACKAGE_kmod-nft-socket=y
CONFIG_PACKAGE_kmod-usb-net-rndis=y
CONFIG_PACKAGE_kmod-usb-net=y
CONFIG_PACKAGE_kmod-usb-net-cdc-ether=y
CONFIG_PACKAGE_kmod-tcp-brutal=y
CONFIG_PACKAGE_kmod-tcp-bbr3=y
CONFIG_PACKAGE_kmod-usb2=y
### Zram
CONFIG_PACKAGE_zram-swap=y
CONFIG_PACKAGE_kmod-lib-lz4=y
CONFIG_PACKAGE_kmod-lib-lzo=y
CONFIG_PACKAGE_kmod-lib-zstd=y
### Utilities
CONFIG_PACKAGE_fdisk=y
CONFIG_PACKAGE_htop=y
CONFIG_PACKAGE_iperf3=y
CONFIG_PACKAGE_iputils-ping=y
CONFIG_PACKAGE_less=y
CONFIG_PACKAGE_lsblk=y
CONFIG_PACKAGE_lscpu=y
CONFIG_PACKAGE_lsof=y
CONFIG_PACKAGE_openssh-sftp-server=y
CONFIG_PACKAGE_pciutils=y
CONFIG_PACKAGE_rename=y
CONFIG_PACKAGE_rsync=y
CONFIG_PACKAGE_sed=y
CONFIG_PACKAGE_unzip=y
CONFIG_PACKAGE_usbutils=y
CONFIG_PACKAGE_vim=y
CONFIG_PACKAGE_wget-ssl=y
CONFIG_PACKAGE_wpad-openssl=y
### OpenSSL
CONFIG_OPENSSL_ENGINE=y
CONFIG_OPENSSL_OPTIMIZE_SPEED=y
CONFIG_OPENSSL_WITH_ASM=y
CONFIG_PACKAGE_libopenssl-afalg=y
CONFIG_PACKAGE_libopenssl-conf=y
CONFIG_PACKAGE_libopenssl-devcrypto=y
CONFIG_PACKAGE_libopenssl-legacy=y
CONFIG_PACKAGE_openssl-util=y
# CONFIG_PACKAGE_libopenssl-padlock is not set
# CONFIG_OPENSSL_WITH_ERROR_MESSAGES is not set
### nginx
CONFIG_PACKAGE_luci-nginx=y
CONFIG_PACKAGE_nginx-all-module=y
CONFIG_PACKAGE_nginx-ssl=y
CONFIG_PACKAGE_nginx-mod-brotli=y
CONFIG_PACKAGE_nginx-mod-luci=y
CONFIG_PACKAGE_nginx-mod-rtmp=y
CONFIG_PACKAGE_nginx-mod-stream=y
CONFIG_PACKAGE_nginx-mod-ubus=y
CONFIG_PACKAGE_nginx-mod-zstd=y
CONFIG_PACKAGE_nginx-ssl-util=y
CONFIG_NGINX_DAV=y
CONFIG_NGINX_HTTP_AUTH_BASIC=y
CONFIG_NGINX_HTTP_QUIC=y
CONFIG_NGINX_HTTP_REAL_IP=y
CONFIG_NGINX_HTTP_SUB=y
CONFIG_NGINX_STREAM_REAL_IP=y
### Curl
CONFIG_PACKAGE_curl=y
CONFIG_PACKAGE_libcurl=y
CONFIG_LIBCURL_NGHTTP3=y
CONFIG_LIBCURL_NGTCP2=y
CONFIG_LIBCURL_OPENSSL=y
# CONFIG_LIBCURL_GNUTLS is not set
# CONFIG_LIBCURL_MBEDTLS is not set
# CONFIG_LIBCURL_NOSSL is not set
# CONFIG_LIBCURL_WOLFSSL is not set
### Firewall
CONFIG_PACKAGE_nat6=y
CONFIG_PACKAGE_ip6tables-nft=y
CONFIG_PACKAGE_ip6tables-mod-nat=y
CONFIG_PACKAGE_iptables-mod-conntrack-extra=y
CONFIG_PACKAGE_iptables-mod-iprange=y
CONFIG_PACKAGE_iptables-mod-nat-extra=y
CONFIG_PACKAGE_iptables-mod-socket=y
CONFIG_PACKAGE_iptables-mod-tproxy=y
CONFIG_PACKAGE_iptables-nft=y
CONFIG_PACKAGE_libip4tc=y
CONFIG_PACKAGE_libip6tc=y
CONFIG_PACKAGE_xtables-nft=y
# CONFIG_PACKAGE_iptables-legacy is not set
### Busybox
CONFIG_BUSYBOX_CUSTOM=y
CONFIG_BUSYBOX_CONFIG_ASH_HELP=y
CONFIG_BUSYBOX_CONFIG_FEATURE_EDITING_HISTORY=1024
CONFIG_BUSYBOX_CONFIG_FEATURE_EDITING_SAVEHISTORY=y
CONFIG_BUSYBOX_CONFIG_FEATURE_PREFER_IPV4_ADDRESS=y
CONFIG_BUSYBOX_CONFIG_FEATURE_SH_HISTFILESIZE=y
CONFIG_BUSYBOX_CONFIG_FEATURE_SYSLOG_INFO=y
EOF
if [[ "${{ github.event.inputs.ENABLE_DHCP }}" == "false" ]]; then
rm -rf openwrt/files/etc/uci-defaults/dhcp-lan
sed -i "s/192.168.1.1/${{ github.event.inputs.OP_IP }}/" openwrt/package/base-files/files/bin/config_generate
fi
IFS=' ' read -r -a plugins <<< "${{ github.event.inputs.CUSTOM_PLUGINS }}"
for plugin in "${plugins[@]}"; do
echo "CONFIG_PACKAGE_${plugin}=y" >> openwrt/.config
done
- name: 下载编译依赖
id: package
run: |
cd openwrt
make defconfig
make download -j8
find dl -size -1024c -exec ls -l {} \;
find dl -size -1024c -exec rm -f {} \;
- name: 编译源码
id: compile
run: |
cd openwrt
echo -e "$(nproc) thread compile"
make -j$(nproc) || make -j1 || make -j1 V=s
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: 查看磁盘使用情况
if: (!cancelled())
run: df -hT
- name: 整理文件
id: organize
run: |
gunzip openwrt/bin/targets/*/*/*.gz
for f in openwrt/bin/targets/*/*/*.img; do
xz -9 --threads=0 --compress "$f"
done
rm -rf openwrt/bin/targets/*/*/*.img
rm -rf openwrt/bin/targets/*/*/*.gz
cd openwrt/bin/targets/*/*
mv *.xz ${{ matrix.repo_info.branch }}-k6.11-onecloud_burn.img.xz
rm -rf packages
rm -rf *.buildinfo
rm -rf profiles.json
rm -rf *.manifest
rm -rf *.sha
rm -rf sha256sums
echo "FIRMWARE=$PWD" >> $GITHUB_ENV
- name: 上传固件到Releases
uses: softprops/action-gh-release@v2.1.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ env.release_tag }}-${{env.tag}}
files: ${{ env.FIRMWARE }}/*
body: |
====================固件信息=======================
源码:${{ env.REPO_URL }}
分支:${{ matrix.repo_info.branch }}
静态IP:${{ github.event.inputs.OP_IP }}
DHCP状态:${{ github.event.inputs.ENABLE_DHCP }}
插件:${{ github.event.inputs.CUSTOM_PLUGINS }}
定制作者:${{ github.event.inputs.OP_author }}
扩容:sh 1.sh
默认密码:无
- name: 清理Releases
uses: dev-drprasad/delete-older-releases@v0.3.4
with:
keep_latest: 2
delete_tags: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}