-
Notifications
You must be signed in to change notification settings - Fork 41
160 lines (156 loc) · 7.45 KB
/
Padavan_CI_NEWIFI-MINI.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
# # # # # # # # # # #
# 自动构建K2P
#
# # # # # # # # # # #
name: Padavan CI NEWIFI-MINI
on:
schedule:
- cron: '0 18 * * *'
workflow_dispatch:
inputs:
clean_cache:
description: 'Clear caches'
required: false
type: boolean
watch:
types: [started]
env:
T_NAMES: "NEWIFI-MINI" # 设备名字数组
BASE_PATH: padavan # 基础目录
PUBLIC_PATH: public # 公共目录
VERSION_FILE: versions.inc # 版本后缀
PUBLIC_SH: public.sh # 公共命令
THEME_PATH: theme
UPLOAD_FIRMWARE: true # 是否打包文件
CLONE_URL: https://github.com/immortalwrt/padavan.git # padavan 地址
CLONE_BRANCH: master # padavan 分支
WORK_PATH: /opt/rt-n56u # 工作目录 一定要加 /
UPLOAD_COWTRANSFER: false
UPLOAD_WETRANSFER: true
FILE_NAME: "NEWIFI-MINI"
IMAGES_PATH: /opt/rt-n56u/images/
jobs:
build:
runs-on: ubuntu-18.04
if: github.event.repository.owner.id == github.event.sender.id # 自己点的 start
steps:
- name: Checkout Master # 1.导入主分支
uses: actions/checkout@master
- name: Initialization Environment # 2.初始环境的设置
env:
DEBIAN_FRONTEND: noninteractive # 非交互模式
run: |
sudo apt-get update
sudo apt-get -y install unzip libtool-bin curl cmake gperf gawk flex bison nano xxd fakeroot \
cpio git python-docutils gettext automake autopoint texinfo build-essential help2man \
pkg-config zlib1g-dev libgmp3-dev libmpc-dev libmpfr-dev libncurses5-dev libltdl-dev wget
sudo timedatectl set-timezone 'Asia/Shanghai' # 设置时区
- name: Clone Code # 3.拷贝代码
run: |
git clone --depth=1 $CLONE_URL -b $CLONE_BRANCH $WORK_PATH
- name: Build Tool Chain # 4.构建工具链
run: |
cd $WORK_PATH/toolchain-mipsel
sh dl_toolchain.sh
# mkdir -p toolchain-3.4.x
# wget https://github.com/hanwckf/padavan-toolchain/releases/download/v1.1/mipsel-linux-uclibc.tar.xz
# tar -xvf mipsel-linux-uclibc.tar.xz -C toolchain-3.4.x
mkdir ${WORK_PATH}/images/
- name: Clear And Build # 5.清理构建树并开始构建
run: |
# 1.拷贝公共文件
cp -r $BASE_PATH/$PUBLIC_PATH $WORK_PATH/
sudo chmod +x $WORK_PATH/$PUBLIC_PATH/$PUBLIC_SH
# 2. 循环替换自定义默认模板和构建,单个设备的 sh 拷贝 t_item 需要编译的固件名字
for t_item in $T_NAMES;
do
if [ ! -e $BASE_PATH/$t_item/$t_item.config ] ; then
echo "${BASE_PATH}/${t_item}/${t_item}.config 自定义模板文件未找到"
else
cp -f $BASE_PATH/$t_item/$t_item.config $WORK_PATH/trunk/configs/templates/$t_item.config
echo "${t_item} 修改模板完成"
fi
if [ ! -f $BASE_PATH/$t_item/$t_item.sh ] ; then
echo "${BASE_PATH}/${t_item}/${t_item}.sh 自定义SH文件未找到"
else
cp -f $BASE_PATH/$t_item/$t_item.sh $WORK_PATH/
sudo chmod +x $WORK_PATH/$t_item.sh
echo "${t_item} 自定义SH文件拷贝成功"
fi
if [ ! -d $BASE_PATH/$t_item/$THEME_PATH ] ; then
echo "${BASE_PATH}/${t_item}/${THEME_PATH} 自定义主题文件夹未找到"
elif [! -d $WORK_PATH/$PUBLIC_PATH/$THEME_PATH ] ; then
cp -r $BASE_PATH/$t_item/$THEME_PATH $WORK_PATH/$PUBLIC_PATH
echo "${THEME_PATH} 自定义主题文件夹拷贝成功"
else
#删除public拷贝的主题
sudo rm -rf $WORK_PATH/$PUBLIC_PATH/$THEME_PATH
cp -r $BASE_PATH/$t_item/$THEME_PATH $WORK_PATH/$PUBLIC_PATH
echo "${THEME_PATH} 自定义主题文件夹拷贝成功"
fi
done
# 3. 开始构建
cd $WORK_PATH/trunk
for t_item in $T_NAMES;
do
cp -f $WORK_PATH/trunk/configs/templates/$t_item.config .config # 拷贝模板到 .config
echo "执行 ${PUBLIC_SH} sh"
sudo $WORK_PATH/$PUBLIC_PATH/$PUBLIC_SH
if [ -e $WORK_PATH/$t_item.sh ] ; then
echo "执行自定义 ${t_item} sh"
sudo $WORK_PATH/$t_item.sh
fi
# 4. 清理构建
cp -f configs/templates/$t_item.config .config
sed -i '/CONFIG_FIRMWARE_INCLUDE_CURL/d' .config
sed -i '/CONFIG_FIRMWARE_INCLUDE_SCUTCLIENT/d' .config
sed -i '/CONFIG_FIRMWARE_INCLUDE_GDUT_DRCOM/d' .config
sed -i '/CONFIG_FIRMWARE_INCLUDE_DOGCOM/d' .config
sed -i '/CONFIG_FIRMWARE_INCLUDE_MINIEAP/d' .config
sed -i '/CONFIG_FIRMWARE_INCLUDE_NJIT_CLIENT/d' .config
sed -i '/CONFIG_FIRMWARE_INCLUDE_NAPT66/d' .config
sed -i '/CONFIG_FIRMWARE_INCLUDE_SOFTETHERVPN_SERVER/d' .config
sed -i '/CONFIG_FIRMWARE_INCLUDE_SOFTETHERVPN_CLIENT/d' .config
sed -i '/CONFIG_FIRMWARE_INCLUDE_SOFTETHERVPN_CMD/d' .config
sed -i '/CONFIG_FIRMWARE_INCLUDE_VLMCSD/d' .config
sed -i '/CONFIG_FIRMWARE_INCLUDE_TTYD/d' .config
sed -i '/CONFIG_FIRMWARE_INCLUDE_LRZSZ/d' .config
sed -i '/CONFIG_FIRMWARE_INCLUDE_HTOP/d' .config
sed -i '/CONFIG_FIRMWARE_INCLUDE_NANO/d' .config
sed -i '/CONFIG_FIRMWARE_INCLUDE_IPERF3/d' .config
sed -i '/CONFIG_FIRMWARE_INCLUDE_DUMP1090/d' .config
sed -i '/CONFIG_FIRMWARE_INCLUDE_RTL_SDR/d' .config
sed -i '/CONFIG_FIRMWARE_INCLUDE_MTR/d' .config
sed -i '/CONFIG_FIRMWARE_INCLUDE_SOCAT/d' .config
sed -i '/CONFIG_FIRMWARE_INCLUDE_SRELAY/d' .config
sed -i '/CONFIG_FIRMWARE_INCLUDE_MENTOHUST/d' .config
sed -i '/CONFIG_FIRMWARE_INCLUDE_FRPC/d' .config
sed -i '/CONFIG_FIRMWARE_INCLUDE_FRPS/d' .config
sed -i '/CONFIG_FIRMWARE_INCLUDE_TUNSAFE/d' .config
sed -i '/CONFIG_FIRMWARE_INCLUDE_WIREGUARD/d' .config
sed -i 's/{ "wl_auth_mode", "psk" },/{ "wl_auth_mode", "open" },/g' $WORK_PATH/trunk/user/shared/defaults.c
sed -i 's/{ "rt_auth_mode", "psk" },/{ "rt_auth_mode", "open" },/g' $WORK_PATH/trunk/user/shared/defaults.c
sudo ./clear_tree
sudo ./build_firmware_modify $t_item # $t_item 是循环的子对象
sudo mv -f images/*.trx ${WORK_PATH}/images/
done
# echo "::set-env name=FILE_NAME::$T_NAMES-$(date "+%Y%m%d")" # 包名
# echo "::set-env name=IMAGES_PATH::${WORK_PATH}/images/" # 打包目录
- name : Upload Packages # 6. 打包文件并且上传到当前主分支
uses: actions/upload-artifact@master
if: env.UPLOAD_FIRMWARE == 'true' && success() # 成功才执行
with:
name: ${{ env.FILE_NAME }}
path: ${{ env.IMAGES_PATH }}
- name: Upload firmware to cowtransfer
if: env.UPLOAD_COWTRANSFER == 'true' && success()
run: |
curl -fsSL git.io/file-transfer | sh
./transfer cow --block 2621440 -s -p 64 --no-progress ${IMAGES_PATH} 2>&1 | tee cowtransfer.log
echo "::warning file=cowtransfer.com::$(cat cowtransfer.log | grep https)"
- name: Upload firmware to WeTransfer
if: env.UPLOAD_WETRANSFER == 'true' && success()
run: |
curl -fsSL git.io/file-transfer | sh
./transfer wet -s -p 16 --no-progress ${IMAGES_PATH} 2>&1 | tee wetransfer.log
echo "::warning file=wetransfer.com::$(cat wetransfer.log | grep https)"