generated from P3TERX/Actions-OpenWrt
-
Notifications
You must be signed in to change notification settings - Fork 1
executable file
·232 lines (203 loc) · 8.58 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
#
# 编译主程序,请勿修改文件名称(compile.yml)
#
name: 编译主程序
on:
workflow_dispatch:
push:
branches:
- auto
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.ACTIONS_TRIGGER_PAT }}
PUSH_PLUS_TOKEN: ${{ secrets.PUSH_PLUS_TOKEN }}
TELEGRAM_BOT_TOKEN: ${{ secrets.TELEGRAM_BOT_TOKEN }}
TELEGRAM_CHAT_ID: ${{ secrets.TELEGRAM_CHAT_ID }}
TZ: Asia/Shanghai
jobs:
build:
name: 编译 "${{matrix.target}}"
runs-on: ubuntu-22.04
if: ${{ github.event.repository.owner.id }} == ${{ github.event.sender.id }}
permissions:
actions: write
contents: write
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/clion007/openwrt-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: Free Disk Space
uses: endersonmenezes/free-disk-space@v2
with:
remove_android: true
remove_dotnet: true
remove_haskell: true
remove_tool_cache: true
remove_swap: true
remove_packages: "azure-cli google-cloud-cli microsoft-edge-stable google-chrome-stable firefox postgresql* temurin-* *llvm* mysql* dotnet-sdk-*"
remove_packages_one_command: true
remove_folders: "/usr/share/swift /usr/share/miniconda /usr/share/az* /usr/share/glade* /usr/local/lib/node_modules /usr/local/share/chromium /usr/local/share/powershell"
testing: false
- 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: 下载"${{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 -j8
- name: 开始编译固件
id: compile
run: |
cd openwrt
echo -e "$(nproc) thread compile"
make -j$(nproc) || 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
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@v1
with:
name: ${{ env.SOURCE }}-${{ env.PROMPT_TING }}
tag: a${{ env.date }}
allowUpdates: true
body: ${{ env.Tongzhi_Date }}
artifacts: "${{ env.FIRMWARE_PATH }}/*"
- name: 发送[在线更新固件]至云端1
id: autoup
if: steps.compile.outcome == 'success' && env.UPDATE_FIRMWARE_ONLINE == 'true' && env.REPO_TOKEN
uses: ncipollo/release-action@v1
with:
name: AutoUpdate
tag: ${{ env.Update_tag }}
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 ${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@v1
with:
name: AutoUpdate-${{ env.TARGET_BOARD }}
tag: ${{ env.Update_tag }}
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'
run: |
if [[ "${{ env.INFORMATION_NOTICE }}" == "TG" ]]; then
if [[ "${{steps.compile.outcome}}" == 'success' ]]; then
curl -k --data chat_id="${{ secrets.TELEGRAM_CHAT_ID }}" --data "text=我亲爱的✨主人✨:您使用【${{matrix.target}}】文件夹编译【${REPO_BRANCH}分支的${{env.TARGET_PROFILE}}】固件顺利编译完成了✌️💯💐(${{env.WAREHOUSE_MAN}}仓库的#${{env.RUN_NUMBER}}号)!($(date +%Y年%m月%d号%H时%M分))" "https://api.telegram.org/bot${{ secrets.TELEGRAM_BOT_TOKEN }}/sendMessage"
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=我亲爱的✨主人✨:您使用【${{matrix.target}}】文件夹编译【${REPO_BRANCH}分支的${{env.TARGET_PROFILE}}】固件顺利编译完成了✌️💯💐(${{env.WAREHOUSE_MAN}}仓库的#${{env.RUN_NUMBER}}号)!($(date +%Y年%m月%d号%H时%M分))" "http://www.pushplus.plus/send"
fi
fi