-
Notifications
You must be signed in to change notification settings - Fork 105
executable file
·299 lines (262 loc) · 11.2 KB
/
compile.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
#
# 编译主程序,请勿修改文件名称(compile.yml)
#
name: 编译主程序
on:
push:
branches:
- main
paths:
- 'build/Lede/relevance/start'
env:
GITHUB_LINK: https://github.com/${{github.repository}}
GIT_ACTOR: ${{github.actor}}
GIT_REPOSITORY: ${{github.repository}}
RUN_NUMBER: ${{github.run_number}}
RUN_WORKFLOW: ${{github.workflow}}
REPO_TOKEN: ${{ secrets.REPO_TOKEN }}
PUSH_PLUS_TOKEN: ${{ secrets.PUSH_PLUS_TOKEN }}
TELEGRAM_BOT_TOKEN: ${{ secrets.TELEGRAM_BOT_TOKEN }}
TELEGRAM_CHAT_ID: ${{ secrets.TELEGRAM_CHAT_ID }}
WX_TOKEN: ${{ secrets.WX_TOKEN }}
CURL: ${{ secrets.CURL }}
TZ: Asia/Shanghai
jobs:
build:
name: 编译 "${{matrix.target}}"
runs-on: ubuntu-22.04
if: ${{ github.event.repository.owner.id }} == ${{ github.event.sender.id }}
env:
FOLDER_NAME: ${{ matrix.target }}
strategy:
fail-fast: false
matrix:
target: [Lede]
steps:
- name: 准备结束
uses: actions/checkout@v4
- name: 检测文件和对比上游版本
run: |
cd ${GITHUB_WORKSPACE}
bash <(curl -fsSL https://raw.githubusercontent.com/shidahuilang/common/main/custom/first.sh)
if [[ -n "${{ github.event.workflow }}" ]] || [[ -n "${{ github.event.schedule }}" ]]; then
source ${GITHUB_WORKSPACE}/build/${FOLDER_NAME}/settings.ini
else
source ${GITHUB_WORKSPACE}/build/${FOLDER_NAME}/relevance/settings.ini
fi
source ${GITHUB_WORKSPACE}/build/${{ env.FOLDER_NAME }}/common.sh && Diy_menu1
- name: 清理因转换CPU而停止的工作流程
run: |
cd ${GITHUB_WORKSPACE}
source build/${FOLDER_NAME}/common.sh && Diy_delruns
- name: CPU检测
run: |
cd ${GITHUB_WORKSPACE}
source build/${FOLDER_NAME}/common.sh && CPU_Priority
- name: 清理空间
uses: jlumbroso/free-disk-space@main
with:
# 这可能会移除实际需要的工具
# 如果设置为“true”,但释放约6 GB
tool-cache: true
# 所有这些都默认为true
# "false" 可以随时关闭
android: true
dotnet: true
haskell: true
large-packages: true
swap-storage: true
- name: 部署编译环境
env:
DEBIAN_FRONTEND: noninteractive
run: |
source ${GITHUB_WORKSPACE}/build/${{matrix.target}}/common.sh && Diy_update
sudo timedatectl set-timezone "$TZ"
sudo mkdir -p /${{ env.DIY_WORK }}
sudo chown ${USER}:${GROUPS} /${{ env.DIY_WORK }}
#- name: 升级rustc到1.70.0
#run: |
#curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain 1.70.0
#source $HOME/.cargo/env
- name: 下载"${{matrix.target}}"源码
working-directory: /${{ env.DIY_WORK }}
run: |
git clone -b "${REPO_BRANCH}" --single-branch "${REPO_URL}" openwrt
ln -sf /${{ env.DIY_WORK }}/openwrt ${GITHUB_WORKSPACE}/openwrt
cp -Rf ${GITHUB_WORKSPACE}/build ${GITHUB_WORKSPACE}/openwrt/build
chmod -R +x ${GITHUB_WORKSPACE}/openwrt/build
- name: 公 告
run: |
cd openwrt
source ${BUILD_PATH}/common.sh && Diy_menu2
- name: 更新插件源
run: |
cd openwrt
source ${BUILD_PATH}/common.sh && Diy_menu3
- name: 加载自定义设置
run: |
cd openwrt
source ${BUILD_PATH}/common.sh && Diy_menu4
- name: 安装插件源
run: |
cd openwrt
source ${BUILD_PATH}/common.sh && Diy_menu5
- name: 生成"${{matrix.target}}"配置文件
run: |
cd openwrt
source ${BUILD_PATH}/common.sh && Diy_menu6
- name: 编译信息
continue-on-error: true
if: env.COMPILATION_INFORMATION == 'true'
run: |
cd openwrt
source ${BUILD_PATH}/common.sh && Diy_xinxi
- name: 缓存加速
if: env.CACHEWRTBUILD_SWITCH == 'true'
uses: stupidloud/cachewrtbuild@main
with:
ccache: 'true'
mixkey: "${{ env.TARGET_PROFILE }}"
prefix: ${{ github.workspace }}/openwrt
- name: 下载软件包
id: package
run: |
cd openwrt
make defconfig
make download -j16
- name: 开始编译固件
id: compile
run: |
cd openwrt
echo -e "$(nproc) thread compile"
make -j$(($(nproc) + 1)) || make -j1 V=s
echo "date=$(date "+%Y%m%d%H%M%S")" >> ${GITHUB_ENV}
source ${BUILD_PATH}/common.sh && firmware_jiance
- name: 自动打包Amlogic_Rockchip系列固件
if: steps.compile.outcome == 'success' && env.PACKAGING_FIRMWARE == 'true'
uses: ncipollo/release-action@main
with:
name: rootfs.tar.gz
tag: targz
token: ${{ secrets.REPO_TOKEN }}
allowUpdates: true
replacesArtifacts: true
artifacts: openwrt/targz/*rootfs.tar.gz
- name: 整理固件文件夹(需配合diy-part.sh设定使用)
continue-on-error: true
if: steps.compile.outcome == 'success'
id: organizer
run: |
cd openwrt
source ${BUILD_PATH}/common.sh && Diy_firmware
- name: 上传固件在 github Artifacts
if: steps.compile.outcome == 'success' && env.UPLOAD_FIRMWARE == 'true'
uses: actions/upload-artifact@main
with:
name: ${{ env.SOURCE }}-${{ env.LUCI_EDITION }}-${{ env.TARGET_PROFILE }}-firmware-${{ env.Firmware_Date }}
path: ${{ env.FIRMWARE_PATH }}
- name: 发布固件
if: steps.compile.outcome == 'success' && env.UPLOAD_RELEASE == 'true' && env.ING_FIRMWAR == 'true' && env.REPO_TOKEN
uses: ncipollo/release-action@main
with:
name: ${{ env.SOURCE }}-${{ env.PROMPT_TING }}
tag: a${{ env.date }}
token: ${{ secrets.REPO_TOKEN }}
allowUpdates: true
artifacts: "${{ env.FIRMWARE_PATH }}/*"
body: |
🎁 编译仓库:${{ env.WAREHOUSE_MAN }}
🌴 源码分支:${{ env.REPO_BRANCH }}
🔥 编译版本:${{ env.Openwrt_Version }}
🛸 LUCI版本:${{ env.LUCI_EDITION }}
✨ 内核版本:${{ env.LINUX_KERNEL }}
⏰ 编译时间:${{ env.Compte_Date }}
- name: 发送[在线更新固件]至云端1
id: autoup
if: steps.compile.outcome == 'success' && env.UPDATE_FIRMWARE_ONLINE == 'true' && env.REPO_TOKEN
uses: ncipollo/release-action@main
with:
name: AutoUpdate
tag: ${{ env.Update_tag }}
token: ${{ secrets.REPO_TOKEN }}
allowUpdates: true
body: ${{ env.Tongzhi_Date }}
artifacts: "${{ env.BIN_PATH }}/*"
- name: 发送[在线更新固件]至云端2
if: steps.autoup.outcome == 'success' && env.UPDATE_FIRMWARE_ONLINE == 'true' && env.REPO_TOKEN
run: |
mkdir -p Github_Api
cd Github_Api
curl -H "Authorization: Bearer ${{ secrets.REPO_TOKEN }}" https://api.github.com/repos/${{ github.repository }}/releases/tags/${{ env.Update_tag }} -o zzz_api
if [[ $? -ne 0 ]]; then
curl -H "Authorization: Bearer ${REPO_TOKEN}" https://api.github.com/repos/${GIT_REPOSITORY}/releases/tags/${Update_tag} > zzz_api
fi
- name: 发送[在线更新固件]至云端3
if: steps.autoup.outcome == 'success' && env.UPDATE_FIRMWARE_ONLINE == 'true' && env.REPO_TOKEN
uses: ncipollo/release-action@main
with:
name: AutoUpdate-${{ env.TARGET_BOARD }}
tag: ${{ env.Update_tag }}
token: ${{ secrets.REPO_TOKEN }}
artifacts: "Github_Api/*"
allowUpdates: true
body: ${{ env.Tongzhi_Date }}
- name: Telegram或pushplus信息通知
if: env.PUSH_PLUS_TOKEN && env.INFORMATION_NOTICE == 'PUSH' || env.TELEGRAM_BOT_TOKEN && env.INFORMATION_NOTICE == 'TG' || env.WX_TOKEN && env.INFORMATION_NOTICE == 'WX'
run: |
if [[ "${{ env.INFORMATION_NOTICE }}" == "TG" ]]; then
if [[ "${{steps.compile.outcome}}" == 'success' ]]; then
curl -k --data chat_id="${{ secrets.TELEGRAM_CHAT_ID }}" \
--data text="🎉 主人您的${{ env.TARGET_PROFILE }}固件成功编译完成了!
🎁 编译仓库:${{ env.WAREHOUSE_MAN }}
🌴 源码分支:${{ env.REPO_BRANCH }}
🔥 编译版本:${{ env.Openwrt_Version }}
🛸 LUCI版本:${{ env.LUCI_EDITION }}
✨ 内核版本:${{ env.LINUX_KERNEL }}
⏰ 编译时间:${{ env.Compte_Date }}
⏰ 累计编译:${{ env.RUN_NUMBER }}
🎉 发布地址:${{ env.Github_Release }}
🏅 固件已经编译完成 🎈!!!" \
"https://api.telegram.org/bot${{ secrets.TELEGRAM_BOT_TOKEN }}/sendMessage" >/dev/null 2>&1 && echo "Telegram通知成功"
fi
fi
if [[ "${{ env.INFORMATION_NOTICE }}" == "PUSH" ]]; then
if [[ "${{steps.compile.outcome}}" == 'success' ]]; then
curl -k --data token="${{ secrets.PUSH_PLUS_TOKEN }}" \
--data title="[${{ env.SOURCE }}-${{ env.TARGET_PROFILE }}]编译成功" \
--data content="🎉 主人您的${{ env.FIRMWARE_MESSAGE }}固件成功编译完成了!
🎁 编译仓库:${{ env.WAREHOUSE_MAN }}
🌴 源码分支:${{ env.REPO_BRANCH }}
🔥 编译版本:${{ env.Openwrt_Version }}
🛸 LUCI版本:${{ env.LUCI_EDITION }}
✨ 内核版本:${{ env.LINUX_KERNEL }}
⏰ 编译时间:${{ env.Compte_Date }}
⏰ 累计编译:${{ env.RUN_NUMBER }}
🎉 发布地址:${{ env.Github_Release }}
🏅 固件已经编译完成 🎈!!!" \
"http://www.pushplus.plus/send" >/dev/null 2>&1 && echo "PUSH通知成功"
fi
fi
if [[ "${{ env.INFORMATION_NOTICE }}" == "WX" ]]; then
if [[ "${{steps.gitpush.outcome}}" == 'success' ]] && [[ "${{steps.compile.outcome}}" == 'success' ]]; then
curl -k --data token="${{ secrets.WX_TOKEN }}" \
--data title="编译成功" \
--data message="🎉 主人您的${{ env.FIRMWARE_MESSAGE }}固件成功编译完成了!
🎁 编译仓库:${{ env.WAREHOUSE_MAN }}
🌴 源码分支:${{ env.REPO_BRANCH }}
🔥 编译版本:${{ env.Openwrt_Version }}
🛸 LUCI版本:${{ env.LUCI_EDITION }}
✨ 内核版本:${{ env.LINUX_KERNEL }}
⏰ 编译时间:${{ env.Compte_Date }}
⏰ 累计编译:${{ env.RUN_NUMBER }}
🎉 发布地址:${{ env.Github_Release }}
🏅 固件已经编译完成 🎈!!!" \
"http://${{ secrets.CURL }}/push?token=${{ secrets.WX_TOKEN }}&" >/dev/null 2>&1 && echo "WX通知成功"
else
curl -k --data token="${{ secrets.WX_TOKEN }}" \
--data title="触发启动失败" \
--data message="💥 主人❌ :上游扩展错误或者脚本错误, 触发启动【${{ env.FOLDER_NAME }}】失败, 请点击触发脚本步骤查看详情!(${{env.Tongzhi_Date}})" \
"http://${{ secrets.CURL }}/push?token=${{ secrets.WX_TOKEN }}&" >/dev/null 2>&1 && echo "WX通知失败"
exit 1
fi
fi