generated from P3TERX/Actions-OpenWrt
-
Notifications
You must be signed in to change notification settings - Fork 25
226 lines (199 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
#
#
# 此文件为编译文件,一般情况下不使用这个来启动,运行build-openwrt.yml会自动触发编译
#
# 如果自动触发挂了的情况下,可以在这里选择好机型,选择 compile 启动编译
#
# REPO_TOKEN密匙制作教程:https://git.io/jm.md
#
#
name: compile
on:
workflow_dispatch:
push:
branches:
- main
paths:
- 'build/X86/start-up/start'
env:
Github: https://github.com/${{github.repository}}
Author: ${{github.actor}}
Warehouse: ${{github.repository}}
Run_number: ${{github.run_number}}
Run_workflow: ${{github.workflow}}
REPO_TOKEN: ${{ secrets.REPO_TOKEN }}
SCKEY: ${{ secrets.SCKEY }}
PUSH_PLUS_TOKEN: ${{ secrets.PUSH_PLUS_TOKEN }}
TELEGRAM_CHAT_ID: ${{ secrets.TELEGRAM_CHAT_ID }}
TELEGRAM_BOT_TOKEN: ${{ secrets.TELEGRAM_BOT_TOKEN }}
TZ: Asia/Shanghai
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: [X86]
# [Lede_source,Lienol_source,Mortal_source,Tianling_source,openwrt_amlogic]
steps:
- name: 准备结束
uses: actions/checkout@v2
- name: 读取脚本设置
run: |
export matrixtarget="${{ matrix.target }}"
git clone --depth 1 -b main https://github.com/281677160/common ${GITHUB_WORKSPACE}/build/common
mv -f ${GITHUB_WORKSPACE}/build/common/*.sh ${GITHUB_WORKSPACE}/build/${{matrix.target}}/
chmod -R +x ${GITHUB_WORKSPACE}/build
source $GITHUB_WORKSPACE/build/${{matrix.target}}/common.sh && Diy_repo_url
source $GITHUB_WORKSPACE/build/${{matrix.target}}/common.sh && Diy_settings
- name: 部署编译环境
env:
DEBIAN_FRONTEND: noninteractive
run: |
source $GITHUB_WORKSPACE/build/${{matrix.target}}/common.sh && Diy_update
- name: 下载"${{matrix.target}}"源码
working-directory: /${{matrix.target}}
run: |
git clone -b "$REPO_BRANCH" --single-branch "$REPO_URL" openwrt
ln -sf /${{matrix.target}}/openwrt $GITHUB_WORKSPACE/openwrt
- name: 公 告
run: |
echo
source $GITHUB_WORKSPACE/build/${{matrix.target}}/common.sh && Diy_variable
source $GITHUB_WORKSPACE/build/${{matrix.target}}/common.sh && Diy_Notice
- name: 加载源,补丁和自定义设置
run: |
cd openwrt
source $BUILD_PATH/common.sh && Diy_menu
- name: 缓存加速(7天内对应源码相同机型二次编译有效,每次只保留一个源码的缓存)
if: env.USE_CACHEWRTBUILD == 'true'
uses: klever1988/cachewrtbuild@test
with:
ccache: 'true'
prefix: ${{ github.workspace }}/openwrt
- name: 生成配置文件
run: |
cd openwrt
source $BUILD_PATH/common.sh && Diy_menu2
- name: 启用在线更新
continue-on-error: true
if: env.REGULAR_UPDATE == 'true' && env.REPO_TOKEN
run: |
cd openwrt
source $BUILD_PATH/upgrade.sh && Diy_Part2
cat $BASE_PATH/bin/openwrt_info
- name: 编译信息
continue-on-error: true
if: env.BY_INFORMATION == 'true'
run: |
cd openwrt
source $BUILD_PATH/upgrade.sh && GET_TARGET_INFO
source $BUILD_PATH/common.sh && Diy_xinxi
- 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) thread compile"
make -j$(($(nproc) + 1)) || make -j1 V=s
echo "date=$(date "+%Y%m%d%H%M%S")" >> $GITHUB_ENV
- name: 打包晶晨系列固件
continue-on-error: true
if: steps.compile.outcome == 'success' && env.AUTOMATIC_AMLOGIC == 'true'
run: |
cd $GITHUB_WORKSPACE
source $BUILD_PATH/common.sh && Package_amlogic
- name: 整理固件文件夹(需配合diy-part.sh设定使用)
continue-on-error: true
id: organizer
run: |
cd openwrt
source $BUILD_PATH/common.sh && Diy_firmware
- name: 上传固件在 github actions
continue-on-error: true
if: steps.compile.outcome == 'success' && env.UPLOAD_FIRMWARE == 'true'
uses: actions/upload-artifact@v2
with:
name: ${{ env.SOURCE }}-${{ env.TARGET_PROFILE }}-firmware-${{ env.Firmware_Date }}
path: ${{ env.FIRMWARE }}
- name: 上传固件到「WeTransfer」
continue-on-error: true
if: steps.compile.outcome == 'success' && env.UPLOAD_WETRANSFER == 'true'
run: |
curl -fsSL git.io/file-transfer | sh
./transfer wet -s -p 16 --no-progress ${FIRMWARE} 2>&1 | tee wetransfer.log
echo "##### WETRANSFER:$(cat wetransfer.log | grep https | cut -f3 -d" ")" >> update_log.txt
sed -i "s/Download Link/WETRANSFER/g" wetransfer.log
echo "::warning file=wetransfer.com::$(cat wetransfer.log | grep https)"
- name: 发布固件
continue-on-error: true
if: steps.compile.outcome == 'success' && env.UPLOAD_RELEASE == 'true' && env.REPO_TOKEN
uses: ncipollo/release-action@v1
with:
name: ${{ env.SOURCE }}-${{ env.TARGET_PROFILE }}
tag: ${{ env.date }}
token: ${{ secrets.REPO_TOKEN }}
bodyFile: "update_log.txt"
artifacts: "${{ env.FIRMWARE }}/*"
- name: 发送[在线更新固件]至云端1
id: regular
continue-on-error: true
if: steps.compile.outcome == 'success' && env.REGULAR_UPDATE == 'true' && env.REPO_TOKEN
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.REPO_TOKEN }}
file: openwrt/bin/Firmware/*
tag: AutoUpdate
overwrite: true
file_glob: true
- name: 发送[在线更新固件]至云端2
continue-on-error: true
if: steps.regular.outcome == 'success' && env.REGULAR_UPDATE == 'true' && env.REPO_TOKEN
run: |
mkdir -p Github_Tags
cd Github_Tags
wget -q --no-cookie --no-check-certificate https://api.github.com/repos/${{github.repository}}/releases/tags/AutoUpdate -O Github_Tags
- name: 发送[在线更新固件]至云端3
continue-on-error: true
if: steps.regular.outcome == 'success' && env.REGULAR_UPDATE == 'true' && env.REPO_TOKEN
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.REPO_TOKEN }}
file: Github_Tags/*
tag: AutoUpdate
overwrite: true
file_glob: true
- name: 电报机器人或pushplus信息通知
continue-on-error: true
if: env.PUSH_PLUS_TOKEN && env.SERVERCHAN_SCKEY == 'PUSH' || env.TELEGRAM_BOT_TOKEN && env.SERVERCHAN_SCKEY == 'TG'
run: |
if [[ "${SERVERCHAN_SCKEY}" == "TG" ]]; then
if [[ "${{steps.compile.outcome}}" == 'failure' ]]; then
curl -k --data chat_id="${{ secrets.TELEGRAM_CHAT_ID }}" --data "text=我亲爱的❌主人❌:您使用【${{matrix.target}}】文件夹编译的[${{ env.SOURCE }}-${{ env.TARGET_PROFILE }}]固件(${{env.Library}}仓库的#${{env.Run_number}}号)编译失败😴!(${{env.Tongzhi_Date}})" "https://api.telegram.org/bot${{ secrets.TELEGRAM_BOT_TOKEN }}/sendMessage"
elif [[ "${{steps.compile.outcome}}" == 'success' ]] && [[ "${{steps.regular.outcome}}" == 'success' ]]; then
curl -k --data chat_id="${{ secrets.TELEGRAM_CHAT_ID }}" --data "text=我亲爱的✨主人✈️:您使用【${{matrix.target}}】文件夹编译的[${{ env.SOURCE }}-${{ env.TARGET_PROFILE }}]固件(${{env.Library}}仓库的#${{env.Run_number}}号)顺利编译成功,发布云端在线更新使用的固件成功!🎈(${{env.Tongzhi_Date}})" "https://api.telegram.org/bot${{ secrets.TELEGRAM_BOT_TOKEN }}/sendMessage"
elif [[ "${{steps.compile.outcome}}" == 'success' ]] && [[ "${{steps.regular.outcome}}" == 'skipped' ]]; then
curl -k --data chat_id="${{ secrets.TELEGRAM_CHAT_ID }}" --data "text=我亲爱的✨主人✨:您使用【${{matrix.target}}】文件夹编译的[${{ env.SOURCE }}-${{ env.TARGET_PROFILE }}]固件💐(${{env.Library}}仓库的#${{env.Run_number}}号)顺利编译完成了✌️💯!(${{env.Tongzhi_Date}})" "https://api.telegram.org/bot${{ secrets.TELEGRAM_BOT_TOKEN }}/sendMessage"
elif [[ "${{steps.compile.outcome}}" == 'success' ]] && [[ "${{steps.regular.outcome}}" == 'failure' ]]; then
curl -k --data chat_id="${{ secrets.TELEGRAM_CHAT_ID }}" --data "text=我亲爱的✨主人❌:您使用【${{matrix.target}}】文件夹编译的[${{ env.SOURCE }}-${{ env.TARGET_PROFILE }}]固件(${{env.Library}}仓库的#${{env.Run_number}}号)顺利编译成功✌️,💥但是发布云端在线更新使用的固件失败了💥!(${{env.Tongzhi_Date}})" "https://api.telegram.org/bot${{ secrets.TELEGRAM_BOT_TOKEN }}/sendMessage"
fi
fi
if [[ "${SERVERCHAN_SCKEY}" == "PUSH" ]]; then
if [[ "${{steps.compile.outcome}}" == 'failure' ]]; then
curl -k --data token="${{ secrets.PUSH_PLUS_TOKEN }}" --data title="[${{ env.SOURCE }}-${{ env.TARGET_PROFILE }}]编译失败" --data "content=我亲爱的❌主人❌:您使用【${{matrix.target}}】文件夹编译的[${{ env.SOURCE }}-${{ env.TARGET_PROFILE }}]固件(${{env.Library}}仓库的#${{env.Run_number}}号)编译失败😴!(${{env.Tongzhi_Date}})" "http://www.pushplus.plus/send"
elif [[ "${{steps.compile.outcome}}" == 'success' ]] && [[ "${{steps.regular.outcome}}" == 'success' ]]; then
curl -k --data token="${{ secrets.PUSH_PLUS_TOKEN }}" --data title="[${{ env.SOURCE }}-${{ env.TARGET_PROFILE }}]编译成功,发布成功" --data "content=我亲爱的✨主人✈️:您使用【${{matrix.target}}】文件夹编译的[${{ env.SOURCE }}-${{ env.TARGET_PROFILE }}]固件(${{env.Library}}仓库的#${{env.Run_number}}号)顺利编译成功,发布云端在线更新使用的固件成功!🎈(${{env.Tongzhi_Date}})" "http://www.pushplus.plus/send"
elif [[ "${{steps.compile.outcome}}" == 'success' ]] && [[ "${{steps.regular.outcome}}" == 'skipped' ]]; then
curl -k --data token="${{ secrets.PUSH_PLUS_TOKEN }}" --data title="[${{ env.SOURCE }}-${{ env.TARGET_PROFILE }}]编译成功" --data "content=我亲爱的✨主人✨:您使用【${{matrix.target}}】文件夹编译的[${{ env.SOURCE }}-${{ env.TARGET_PROFILE }}]固件💐(${{env.Library}}仓库的#${{env.Run_number}}号)顺利编译完成了✌️💯!(${{env.Tongzhi_Date}})" "http://www.pushplus.plus/send"
elif [[ "${{steps.compile.outcome}}" == 'success' ]] && [[ "${{steps.regular.outcome}}" == 'failure' ]]; then
curl -k --data token="${{ secrets.PUSH_PLUS_TOKEN }}" --data title="[${{ env.SOURCE }}-${{ env.TARGET_PROFILE }}]编译成功,发布失败" --data "content=我亲爱的✨主人❌:您使用【${{matrix.target}}】文件夹编译的[${{ env.SOURCE }}-${{ env.TARGET_PROFILE }}]固件(${{env.Library}}仓库的#${{env.Run_number}}号)顺利编译成功✌️,💥但是发布云端在线更新使用的固件失败了💥!(${{env.Tongzhi_Date}})" "http://www.pushplus.plus/send"
fi
fi