-
Notifications
You must be signed in to change notification settings - Fork 0
278 lines (233 loc) · 11.7 KB
/
build-openwrt.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
#
#
# 感谢p3terx大神的一键编译脚本
#
# Copyright (C) 2019 P3TERX <https://p3terx.com>
# <https://github.com/P3TERX/Actions-OpenWrt.git>
#
name: 编译OpenWrt固件
on:
workflow_dispatch:
inputs:
ssh:
description: 'SSH远程'
required: false
default: 'ssh-actions'
wxtz:
description: '微信通知'
required: false
default: 'wxtz-actions'
release:
description: '发布固件'
required: false
default: 'release-actions'
#定时触发开始编译(开启定时编译请先确认SSH处在关闭状态,要不然SSH没人管,会卡SSH编译失败)
# schedule:
# - cron: 0 8 */5 * *
#点☆Star触发开始编译
# watch:
# types: started
env:
REPO_TOKEN: ${{ secrets.REPO_TOKEN }}
SCKEY: ${{ secrets.SCKEY }}
TZ: Asia/Shanghai
GITHUB_RELEASE: https://github.com/281677160/build-openwrt/releases
jobs:
build:
runs-on: Ubuntu-20.04
if: github.event.repository.owner.id == github.event.sender.id
name: 编译 ${{matrix.target}}
strategy:
fail-fast: false
matrix:
target: [Lede_x86_64]
# [Lede_nanopi_r2s,Lede_newifi_d2,Lede_phicomm_k2p,Lede_phicomm_n1,Lede_redmi_ac2100,Lede_x86_64,Lede_xiaomi_r3pro,Lede_xiaoyu_c5]
# [Lienol_phicomm_k2p,Lienol_phicomm_k3,Lienol_x86_64]
# [Project_nanopi_r2s,Project_newifi_d2,Project_phicomm_k3,Project_phicomm_n1,Project_x86_64,Project_xiaomi_ac2100,Project_xiaomi_mir3g,Project_xiaoyu_c5]
steps:
- name: 准备结束
uses: actions/checkout@v2
- name: 检测脚本设置
run: |
source "${GITHUB_WORKSPACE}/build/${{matrix.target}}/settings.ini"
echo "REPO_URL=${REPO_URL}" >> $GITHUB_ENV
echo "REPO_BRANCH=${REPO_BRANCH}" >> $GITHUB_ENV
echo "CONFIG_FILE=${CONFIG_FILE}" >> $GITHUB_ENV
echo "WXFB_MESSAGE=${WXFB_MESSAGE}" >> $GITHUB_ENV
echo "DIY_P1_SH=${DIY_P1_SH}" >> $GITHUB_ENV
echo "DIY_P2_SH=${DIY_P2_SH}" >> $GITHUB_ENV
echo "SSH_ACTIONS=${SSH_ACTIONS}" >> $GITHUB_ENV
echo "UPLOAD_BIN_DIR=${UPLOAD_BIN_DIR}" >> $GITHUB_ENV
echo "UPLOAD_CONFIG=${UPLOAD_CONFIG}" >> $GITHUB_ENV
echo "UPLOAD_FIRMWARE=${UPLOAD_FIRMWARE}" >> $GITHUB_ENV
echo "UPLOAD_COWTRANSFER=${UPLOAD_COWTRANSFER}" >> $GITHUB_ENV
echo "UPLOAD_RELEASE=${UPLOAD_RELEASE}" >> $GITHUB_ENV
echo "SERVERCHAN_SCKEY=${SERVERCHAN_SCKEY}" >> $GITHUB_ENV
- name: 微信通知
uses: emon100/Action-Serverchan@v2
if: env.SERVERCHAN_SCKEY == 'true' || (github.event.inputs.wxtz == 'wxtz' && github.event.inputs.wxtz != 'false')
with:
SCKEY: ${{ secrets.SCKEY }}
text: 主人${{matrix.target}}编译开始啦
desp: 主人您要编译的[${{ env.WXFB_MESSAGE }}]固件正在努力耕耘中,请耐心等待......
- 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 -y
sudo -E apt-get -qq install -y build-essential asciidoc binutils bzip2 gawk gettext git libc6-dev libncurses5 libtinfo-dev libtinfo5 ncurses-doc libncurses5-dev libz-dev patch python3 python2.7 unzip zlib1g-dev lib32gcc1 subversion flex uglifyjs git-core gcc-multilib p7zip p7zip-full msmtp libssl-dev texinfo libglib2.0-dev xmlto qemu-utils upx libelf-dev autoconf automake libtool autopoint device-tree-compiler g++-multilib antlr3 gperf wget curl swig rsync
sudo -E apt-get -qq autoremove -y --purge
sudo -E apt-get -qq clean -y
sudo timedatectl set-timezone "$TZ"
sudo mkdir -p /workdir
sudo chown $USER:$GROUPS /workdir
- name: 下载${{matrix.target}}源码
working-directory: /workdir
run: |
df -hT $PWD
git clone -b $REPO_BRANCH --single-branch $REPO_URL openwrt
ln -sf /workdir/openwrt $GITHUB_WORKSPACE/openwrt
cd openwrt
rm -rf package/ctcgfw/luci-app-argon-config
rm -rf package/lienol/luci-app-timecontrol
rm -rf package/ctcgfw/luci-theme-argonv3
rm -rf package/lean/luci-app-netdata
rm -rf package/lean/luci-theme-argon
rm -rf package/lean/k3screenctrl
- name: 加载源,patch补丁和自定义设置
run: |
cp -Rf `find ./ -maxdepth 1 -type d ! -path './openwrt' ! -path './'` openwrt
cd openwrt
if [ -f "build/${{matrix.target}}/$DIY_P1_SH" ]; then
chmod +x build/${{matrix.target}}/$DIY_P1_SH
/bin/bash "build/${{matrix.target}}/$DIY_P1_SH"
fi
git clone -b $REPO_BRANCH --single-branch https://github.com/281677160/openwrt-package package/danshui
./scripts/feeds clean && ./scripts/feeds update -a && ./scripts/feeds install -a && ./scripts/feeds install -a
if [ -f "build/${{matrix.target}}/$DIY_P2_SH" ]; then
chmod +x build/${{matrix.target}}/$DIY_P2_SH
/bin/bash "build/${{matrix.target}}/$DIY_P2_SH"
fi
if [ -n "$(ls -A "build/${{matrix.target}}/patches" 2>/dev/null)" ]; then
find "build/${{matrix.target}}/patches" -type f -name '*.patch' -print0 | sort -z | xargs -I % -t -0 -n 1 sh -c "cat '%' | patch -d './' -p1 --forward --no-backup-if-mismatch"
fi
if [ -n "$(ls -A "build/${{matrix.target}}/files" 2>/dev/null)" ]; then
cp -rf build/${{matrix.target}}/files files
chmod -R 755 build/${{matrix.target}}/files/* ./
fi
if [ -n "$(ls -A "build/${{matrix.target}}/diy" 2>/dev/null)" ]; then
cp -Rf build/${{matrix.target}}/diy/* ./
fi
[ -e build/${{matrix.target}}/$CONFIG_FILE ]
mv build/${{matrix.target}}/$CONFIG_FILE .config
make defconfig
git clone https://github.com/openwrt-dev/po2lmo.git
pushd po2lmo
make && sudo make install
popd
- name: SSH远程连接服务器配置固件
uses: P3TERX/[email protected]
if: env.SSH_ACTIONS == 'true' || (github.event.inputs.ssh == 'ssh' && github.event.inputs.ssh != 'false')
- name: 下载软件包
id: package
run: |
cd openwrt
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)+1)) thread compile"
make -j$(($(nproc)+1)) || make -j1 V=s
echo "::set-output name=status::success"
echo "date=$(date "+%Y-%m-%d %H.%M")" >> $GITHUB_ENV
echo "date1=$(date "+%Y年%m月%d号-%H点%M分")" >> $GITHUB_ENV
echo "date2=$(date "+%Y%m%d-%H%M")" >> $GITHUB_ENV
- name: 上传bin文件夹(固件+ipk)在github空间
uses: actions/upload-artifact@v2
if: steps.compile.outputs.status == 'success' && env.UPLOAD_BIN_DIR == 'true'
with:
name: OpenWrt_bin_${{matrix.target}}_${{ env.date }}
path: openwrt/bin
- name: 整理固件文件夹
id: organizer
run: |
mkdir config
find openwrt/bin/targets/ -name "*config.buildinfo*" | xargs -i mv -f {} config
cd openwrt/bin/targets/*/*
rm -rf packages && mkdir packages
find -name "*buildinfo*" | xargs -i mv -f {} packages
find -name "*sha256sums*" | xargs -i mv -f {} packages
find -name "*kernel.bin*" | xargs -i mv -f {} packages
find -name "*kernel1.bin*" | xargs -i mv -f {} packages
find -name "*manifest*" | xargs -i mv -f {} packages
find -name "*vmlinuz*" | xargs -i mv -f {} packages
find -name "*esxi.vmdk*" | xargs -i mv -f {} packages
find -name "*Image*" | xargs -i mv -f {} packages
find -name "*rootfs-squashfs*" | xargs -i mv -f {} packages
find -name "*squashfs-rootfs*" | xargs -i mv -f {} packages
rm -rf packages
echo "FIRMWARE=$PWD" >> $GITHUB_ENV
echo "::set-output name=status::success"
- name: 上传.config配置文件在github空间
uses: actions/upload-artifact@v2
if: steps.organizer.outputs.status == 'success' && env.UPLOAD_CONFIG == 'true'
with:
name: .config_${{matrix.target}}_${{ env.date }}
path: ./config
- name: 上传固件在github空间
uses: actions/upload-artifact@v2
if: steps.organizer.outputs.status == 'success' && env.UPLOAD_FIRMWARE == 'true'
with:
name: OpenWrt_firmware_${{matrix.target}}_${{ env.date }}
path: ${{ env.FIRMWARE }}
- name: 上传固件到「奶牛快传」和「WeTransfer」
if: steps.organizer.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=奶牛快传(${{matrix.target}})::$(cat cowtransfer.log | grep https)"
curl -fsSL git.io/file-transfer | sh
./transfer wet -s -p 16 --no-progress ${FIRMWARE} 2>&1 | tee wetransfer.log
echo "::warning file=WeTransfer(${{matrix.target}})::$(cat wetransfer.log | grep https)"
- name: 提取发布用的「奶牛快传」跟「WeTransfer」的链接
if: steps.organizer.outputs.status == 'success' && env.UPLOAD_RELEASE == 'true' || (github.event.inputs.release == 'release' && github.event.inputs.release != 'false')
run: |
curl -fsSL git.io/file-transfer | sh
./transfer cow --block 2621440 -s -p 64 --no-progress ${FIRMWARE} 2>&1 | tee cowtransfer.log
echo "COWTRANSFER_URL=$(cat cowtransfer.log | grep https | cut -f3 -d" ")" >> $GITHUB_ENV
curl -fsSL git.io/file-transfer | sh
./transfer wet -s -p 16 --no-progress ${FIRMWARE} 2>&1 | tee wetransfer.log
echo "WETRANSFER_URL=$(cat wetransfer.log | grep https | cut -f3 -d" ")" >> $GITHUB_ENV
- name: 自动发布固件
uses: softprops/action-gh-release@v1
if: steps.organizer.outputs.status == 'success' && env.UPLOAD_RELEASE == 'true' || (github.event.inputs.release == 'release' && github.event.inputs.release != 'false')
env:
GITHUB_TOKEN: ${{ secrets.REPO_TOKEN }}
with:
name: ${{ env.date1 }} 「 ${{ env.WXFB_MESSAGE }} 」固件
tag_name: ${{ env.date2 }}
body: |
☆ 源码 : ${{ env.REPO_URL }}
☆ 分支 : ${{ env.REPO_BRANCH }}
☆ 感谢源码作者无私分享!
🎉 [ ${{ env.WXFB_MESSAGE }} ]固件下载 ✨
💐 奶牛快传(国内高速🚀下载): ${{ env.COWTRANSFER_URL }}
⛄ WeTransfer(国外高速🚀下载): ${{ env.WETRANSFER_URL }}
🌴 链接有效期为7天,无需注册直接下载 🐤
files: ${{ env.FIRMWARE }}/*
- name: 微信通知
uses: emon100/Action-Serverchan@v2
if: steps.organizer.outputs.status == 'success' && env.SERVERCHAN_SCKEY == 'true' || (github.event.inputs.wxtz == 'wxtz' && github.event.inputs.wxtz != 'false')
with:
SCKEY: ${{ secrets.SCKEY }}
text: 恭喜主人${{matrix.target}}固件编译成功!
desp: 我亲爱的主人您要编译的${{ env.WXFB_MESSAGE }}固件成功编译完成了!
完成时间:${{ env.date1 }}
发布地址:${{ env.GITHUB_RELEASE }}
奶牛快传:${{ env.COWTRANSFER_URL }}
WeTransfer:${{ env.WETRANSFER_URL }}
祝小主人见人爱,花见花开,车见车载,天天好心情🎈!!!