-
Notifications
You must be signed in to change notification settings - Fork 2
300 lines (263 loc) · 11.5 KB
/
Build arm64.mini OpenWrt v23.05.3.yaml
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
300
#
# Copyright (c) 2019-2020 P3TERX <https://p3terx.com>
#
# This is free software, licensed under the MIT License.
# See /LICENSE for more information.
#
# https://github.com/P3TERX/Actions-OpenWrt
# Description: Build OpenWrt using GitHub Actions
#
name: Build Arm64.mini OpenWrt v23.05.3
permissions: write-all
#开启写权限,防止无法上传到release
on:
repository_dispatch:
workflow_dispatch:
inputs:
ssh:
description: 'SSH connection to Actions'
required: false
default: 'false'
schedule:
- cron: '0 18 * * 5'
env:
REPO_URL: https://github.com/openwrt/openwrt
REPO_BRANCH: openwrt-23.05
FEEDS_CONF: feeds.conf.default.none
CONFIG_FILE: OpenWRT/v23.arm64.mini.config
DIY_P1_SH: OpenWRT/diy-part1.sh
DIY_P2_SH: OpenWRT/diy-part2.sh
UPLOAD_BIN_DIR: false
UPLOAD_FIRMWARE: true
UPLOAD_COWTRANSFER: false
UPLOAD_WETRANSFER: false
UPLOAD_RELEASE: true
TZ: Asia/Shanghai
FILE_NAME: OP2305_ARM_ROOTFS_mini
PRODUCT_NAME: OP2305_ARM_ROOTFS_mini
GITHUB_RELEASE: https://github.com/518512/My-ROOTFS
DISTRIB_REVISION: OpenWRT Main
KERNEL_PATCHVER: 无内核,纯LXC ROOTFS
jobs:
build:
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@main
- name: Check server configuration
run: |
echo "警告⚠"
echo "若分配的服务器性能不足,务必及时取消,重新运行!"
echo "已知编译成功CPU型号:8370C,8171M"
echo "已知性能不足CPU型号:8272CL"
echo -e "-------------- ------------CPU信息------------------------------------------\n"
echo "CPU物理数量:$(cat /proc/cpuinfo| grep "physical id"| sort| uniq| wc -l)"
echo -e "CPU核心及版本信息:$(cat /proc/cpuinfo | grep name | cut -f2 -d: | uniq -c) \n"
echo "-------------------------------内存信息-------------------------------------------"
echo "已安装内存详细信息:"
sudo lshw -short -C memory | grep GiB
echo -e "\n"
echo "-----------------------------硬盘信息---------------------------------------------"
echo -e "硬盘数量:$(ls /dev/sd* | grep -v [1-9] | wc -l) \n"
echo "硬盘详情:"
df -Th
- name: Initialization environment
env:
DEBIAN_FRONTEND: noninteractive
run: |
docker rmi `docker images -q`
sudo -E rm -rf /usr/share/dotnet /etc/mysql /etc/php /etc/apt/sources.list.d /usr/local/lib/android
sudo -E apt -y purge azure-cli* docker* ghc* zulu* llvm* firefox google* dotnet* powershell* openjdk* mysql* php* mongodb* dotnet* snap* aspnetcore*
[ -n "$AGENT_TOOLSDIRECTORY" ] && sudo rm -rf "$AGENT_TOOLSDIRECTORY"
sudo -E apt update
sudo -E apt -y install $(curl -fsSL https://is.gd/depends_ubuntu_2204)
sudo -E apt -y autoremove --purge
sudo -E systemctl daemon-reload
sudo -E apt clean
sudo timedatectl set-timezone "$TZ"
sudo mkdir -p /workdir
sudo chown $USER:$GROUPS /workdir
echo "status=success" >> ${GITHUB_OUTPUT}
df -Th
- name: 缓存加速
uses: stupidloud/cachewrtbuild@main
if: env.CACHE_BUILD == 'true' || (github.event.inputs.CACHE_BUILD == 'true')
with:
ccache: 'true'
prefix: ${{ github.workspace }}/openwrt
- name: 更新时区、编译时间
id: date
run: |
sudo timedatectl set-timezone "$TZ"
echo "FILE_TIME=$(date +"%m-%d %H.%M")" >> $GITHUB_ENV
echo "FILE_TIME1=$(date "+%Y年%m月%d日-%H点%M分")" >> $GITHUB_ENV
echo "FILE_TIME2=$(date "+%Y%m%d-%H%M")" >> $GITHUB_ENV
echo "编译开始时间..."
START_TIME=`date +'%Y-%m-%d %H:%M:%S'`
echo "START_SECONDS=$(date --date="$START_TIME" +%s)" >> $GITHUB_ENV
- name: Clone source code
working-directory: /workdir
run: |
df -hT $PWD
git clone $REPO_URL -b $REPO_BRANCH openwrt
ln -sf /workdir/openwrt $GITHUB_WORKSPACE/openwrt
cd openwrt
useVersionInfo=$(git show -s --date=short --format="Author: %an<br/>date: %cd<br/>commit: %s<br/>commit hash: %H")
echo "useVersionInfo=$useVersionInfo" >> $GITHUB_ENV
echo "DATE=$(date "+%Y-%m-%d %H")" >> $GITHUB_ENV
echo "DATE1=$(date "+%Y-%m-%d")" >> $GITHUB_ENV
- name: Load custom feeds
run: |
[ -e $FEEDS_CONF ] && mv $FEEDS_CONF openwrt/feeds.conf.default
chmod +x $DIY_P1_SH
cd openwrt
$GITHUB_WORKSPACE/$DIY_P1_SH
- name: Update feeds
run: cd openwrt && ./scripts/feeds update -a
- name: Install feeds
run: cd openwrt && ./scripts/feeds install -a
- name: Load custom configuration
run: |
[ -e files ] && mv files openwrt/files
[ -e $CONFIG_FILE ] && mv $CONFIG_FILE openwrt/.config
cat openwrt/.config # 确认 .config 文件内容
chmod +x $DIY_P2_SH
cd openwrt
$GITHUB_WORKSPACE/$DIY_P2_SH
- name: SSH connection to Actions
uses: P3TERX/[email protected]
if: (github.event.inputs.ssh == 'true' && github.event.inputs.ssh != 'false') || contains(github.event.action, 'ssh')
env:
TELEGRAM_CHAT_ID: ${{ secrets.TELEGRAM_CHAT_ID }}
TELEGRAM_BOT_TOKEN: ${{ secrets.TELEGRAM_BOT_TOKEN }}
- name: Download package
id: package
run: |
cd openwrt
make defconfig
cat .config # 输出配置文件内容
make download -j8
find dl -size -1024c -exec ls -l {} \;
find dl -size -1024c -exec rm -f {} \;
- name: Compile the firmware
id: compile
run: |
cd openwrt
echo -e "$(nproc) thread compile"
make -j$(nproc) || make -j1 || make -j1 V=s
# echo "::set-output name=status::success"
echo "status=success" >> $GITHUB_OUTPUT
grep '^CONFIG_TARGET.*DEVICE.*=y' .config | sed -r 's/.*DEVICE_(.*)=y/\1/' > DEVICE_NAME
[ -s DEVICE_NAME ] && echo "DEVICE_NAME=_$(cat DEVICE_NAME)" >> $GITHUB_ENV
echo "FILE_DATE=_$(date +"%Y%m%d%H%M")" >> $GITHUB_ENV
echo "编译完成时间..."
START_SECONDS=${{ env.START_SECONDS }}
END_TIME=`date +'%Y-%m-%d %H:%M:%S'`
END_SECONDS=$(date --date="$END_TIME" +%s)
SECONDS=$((END_SECONDS-START_SECONDS))
HOUR=$(( $SECONDS/3600 )) && MIN=$(( ($SECONDS-${HOUR}*3600)/60 )) && SEC=$(( $SECONDS-${HOUR}*3600-${MIN}*60 ))
echo "BUILD_TIME=${HOUR}时${MIN}分${SEC}秒" >> $GITHUB_ENV
echo "FILE_DATE=_$(date +"%Y%m%d%H%M")" >> $GITHUB_ENV
echo "FILE_DATE2=$(date +"%Y%m%d%H%M")" >> $GITHUB_ENV
- name: Clean up server space
if: steps.compile.outputs.status == 'success' && !cancelled()
run: |
cd openwrt/
rm -rf $(ls . | grep -v "^bin$" | xargs) 2>/dev/null
df -hT ${PWD}
- name: Upload bin directory
uses: actions/upload-artifact@main
if: steps.compile.outputs.status == 'success' && env.UPLOAD_BIN_DIR == 'true'
with:
name: OpenWrt_bin${{ env.DEVICE_NAME }}${{ env.FILE_DATE }}
path: openwrt/bin
- name: Organize files
id: organize
if: env.UPLOAD_FIRMWARE == 'true' && !cancelled()
run: |
cd openwrt/bin/targets/*/*
rm -rf packages
rm -rf *.buildinfo
rm -rf profiles.json
rm -rf sha256sums
rm -rf openwrt-armsr-armv8-generic-kernel.bin
rm -rf openwrt-armsr-armv8-generic.manifest
mv openwrt-armsr-armv8-generic-rootfs.tar.gz openwrt-23.05-${{ env.VERSION }}-armsr-armv8-generic-rootfs-${{ env.FILE_DATE2 }}.tar.gz
echo "FIRMWARE=$PWD" >> $GITHUB_ENV
# echo "::set-output name=status::success"
echo "status=success" >> $GITHUB_OUTPUT
- name: Upload firmware directory
uses: actions/upload-artifact@main
if: steps.organize.outputs.status == 'success' && !cancelled()
with:
name: OpenWrt_firmware${{ env.DEVICE_NAME }}${{ env.FILE_DATE }}
path: ${{ env.FIRMWARE }}
#- name: Generate release tag
#id: tag
#if: env.UPLOAD_RELEASE == 'true' && !cancelled()
#run: |
## echo "::set-output name=release_tag::$(date +"%Y.%m.%d-%H%M")"
#echo "release_tag=${{ env.FILE_NAME }}" >> $GITHUB_OUTPUT
#touch release.txt
#[ $UPLOAD_COWTRANSFER = true ] && echo "🔗 [Cowtransfer](${{ steps.cowtransfer.outputs.url }})" >> release.txt
#[ $UPLOAD_WETRANSFER = true ] && echo "🔗 [WeTransfer](${{ steps.wetransfer.outputs.url }})" >> release.txt
## echo "::set-output name=status::success"
#echo "status=success" >> $GITHUB_OUTPUT
- name: Create release
id: release
uses: ncipollo/release-action@v1
with:
name: R${{ env.DATE }} for ${{ env.PRODUCT_NAME }}
allowUpdates: true
tag: ${{ env.FILE_NAME }} # 确保 tag 名称有效,去除非法字符和空格
commit: ${{ github.sha }} # 使用有效的 commit SHA 值
token: ${{ secrets.TOKEN3 }}
body: |
**OpenWRT official Mini Firmware for Armvirt/Armsr 64**
### 📒 固件信息
- 🚀 每日:OpenWRT 作者固件 ➦ [xYx-c](https://github.com/xYx-c/build-openwrt/releases) ➦ [Zane-E](https://github.com/Zane-E/ROOTFS/releases) ➦ [217heidai](https://github.com/217heidai/OpenWrt-Builder/releases)
- 🚀 随缘:LXC MINI ROOTFS ➦ [OpenWRT](https://github.com/518512/xYx-openwrt/releases) ➦ [LEDE](https://github.com/518512/ROOTFS/releases) ➦ [ImmortalWrt](https://github.com/518512/ROOTFS/releases)即可下载
- 💻 平台架构: Armvirt/Armsr 64 , 🌐 默认地址: 10.5.2.1 , 🔑 默认密码: password
- ⚽ 固件源码: ${{ env.REPO_URL }} , 💝 源码分支: ${{ env.REPO_BRANCH }}(23.05.4)
### 🧊 固件版本
- LXC Mini底包,非完整固件,每周五18点自动编译
- 固件编译前最后一次➦[主源码](${{ env.REPO_URL }})更新记录
${{ env.useVersionInfo }}
artifacts: ${{ env.FIRMWARE }}/*
#- name: Upload firmware to release
# uses: softprops/action-gh-release@v1
# if: steps.tag.outputs.status == 'success' && !cancelled()
# env:
# GITHUB_TOKEN: ${{ secrets.TOKEN3 }}
# with:
# tag_name: ${{ steps.tag.outputs.release_tag }}
# body_path: release.txt
# files: ${{ env.FIRMWARE }}/*
- name: Delete workflow runs
uses: Mattraks/delete-workflow-runs@main
with:
token: ${{ secrets.TOKEN3 }}
repository: ${{ github.repository }}
retain_days: 3
keep_minimum_runs: 3
- name: Remove old Releases
uses: dev-drprasad/delete-older-releases@master
if: env.UPLOAD_RELEASE == 'true' && !cancelled()
with:
repo:
keep_latest: 10
delete_tag_pattern:
delete_tags: true
env:
GITHUB_TOKEN: ${{ secrets.TOKEN3 }}
- name: Telegram notification
run: |
curl "https://api.telegram.org/bot${{ secrets.TELEGRAM_BOT_TOKEN }}/sendMessage" -d "chat_id=${{ secrets.TELEGRAM_CHAT_ID }}&text=
您的${{ env.PRODUCT_NAME }}固件成功编译完成了!
🛠 编译版本:${{ env.DISTRIB_REVISION }}
🖥 内核版本:${{ env.KERNEL_PATCHVER }}
🎈 编译时间:${{ env.FILE_TIME1 }}
⏰ 编译用时:${{ env.BUILD_TIME }}
🎉 发布地址:${{ env.GITHUB_RELEASE }}
🌴 固件已经编译完成 🎈!!!
" >/dev/null 2>&1 && echo "ok..."