-
Notifications
You must be signed in to change notification settings - Fork 0
230 lines (199 loc) · 8.01 KB
/
lede-builder.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
name: Lede Builder
on:
repository_dispatch:
workflow_dispatch:
schedule:
- cron: '0 0 1 * *'
env:
REPO_URL: https://github.com/coolsnowwolf/lede
REPO_BRANCH: master
FEEDS_CONF: feeds.conf.default
CONFIG_FILE: lede.config
DIY_P1_SH: scripts/diy-part1.sh
DIY_P2_SH: scripts/diy-part2.sh
UPLOAD_TO_TG_SH: scripts/upload-to-telegram.sh
ENV_SH: scripts/environment.sh
FREE_DISK_SH: scripts/free_disk_space.sh
PATCHES_DIR: patches
UPLOAD_FIRMWARE: false
UPLOAD_RELEASE: true
TZ: Asia/Shanghai
jobs:
prepare_release:
runs-on: ubuntu-22.04
if: github.event.repository.owner.id == github.event.sender.id || github.event_name == 'schedule'
outputs:
release_tag: ${{ steps.release_tag.outputs.release_tag }}
steps:
- name: Get release tag
id: release_tag
run: |
release_tag="Lede-Rockchip-$(date +%Y-%m-%d)"
echo "release_tag=$release_tag" >> $GITHUB_OUTPUT
build_openwrt:
needs: prepare_release
runs-on: ubuntu-22.04
strategy:
matrix:
KERNEL_VERSION: ['5.15', 'latest']
FREQUENCY: ['1.5', '1.6']
SET: ['docker', 'non-docker']
continue-on-error: true
steps:
- name: Checkout source code
uses: actions/checkout@v4
- name: Set environment variables
run: |
echo "KERNEL_VERSION=${{ matrix.KERNEL_VERSION }}" >> $GITHUB_ENV
echo "FREQUENCY=${{ matrix.FREQUENCY }}" >> $GITHUB_ENV
echo "SET=${{ matrix.SET }}" >> $GITHUB_ENV
- name: Initialize environment
env:
DEBIAN_FRONTEND: noninteractive
run: |
chmod +x ${{ env.FREE_DISK_SH }} && ${{ env.FREE_DISK_SH }}
sudo rm -rf /usr/share/dotnet /usr/local/lib/android /opt/ghc
sudo apt-get -qq update -y && sudo apt-get -qq full-upgrade -y
chmod +x ${{ env.ENV_SH }} && ${{ env.ENV_SH }}
sudo -E apt-get -qq autoremove --purge && sudo -E apt-get -qq clean
sudo mkdir -p /workdir && sudo chown $USER:$GROUPS /workdir
- name: Clone source code
working-directory: /workdir
run: |
df -hT $PWD
git clone ${{ env.REPO_URL }} -b ${{ env.REPO_BRANCH }} openwrt
ln -sf /workdir/openwrt $GITHUB_WORKSPACE/openwrt
- name: Cache build
uses: klever1988/cachewrtbuild@main
with:
ccache: 'true'
mixkey: 'armv8_${{ env.KERNEL_VERSION }}'
prefix: ${{ github.workspace }}/openwrt
- name: Apply patches
run: |
if [ "${{ env.KERNEL_VERSION }}" == "5.15" ]; then
echo "Applying 5.15 patches..."
cp -f lede/armv8.mk openwrt/target/linux/rockchip/image/armv8.mk
cp -f lede/uboot-rockchip-Makefile openwrt/package/boot/uboot-rockchip/Makefile
rm -rf openwrt/target/linux/rockchip/files/arch/arm64/boot/dts/rockchip
cp -rf lede/rockchip/files/arch/arm64/boot/dts/rockchip/. openwrt/target/linux/rockchip/files/arch/arm64/boot/dts/rockchip
rm -rf openwrt/target/linux/rockchip/patches-5.15
cp -rf lede/rockchip/patches-5.15/. openwrt/target/linux/rockchip/patches-5.15
sed -i 's/KERNEL_PATCHVER:=.*/KERNEL_PATCHVER:=5.15/g' openwrt/target/linux/rockchip/Makefile
fi
if [ -d "$PATCHES_DIR" ]; then
echo "Applying custom patches from $PATCHES_DIR..."
if [ "${{ env.FREQUENCY }}" == "1.6" ]; then
echo "Removing frequency-specific patch for 1.6..."
rm -f "$PATCHES_DIR"/*999-rk3328-orangepi-r1-plus-lts-patch.patch
fi
mv "$PATCHES_DIR" openwrt/patches
cd openwrt && git apply --ignore-whitespace patches/*.patch && rm -rf patches
fi
- name: Load custom feeds and update packages
run: |
if [ -e $FEEDS_CONF ]; then
echo "Using custom feeds configuration from $FEEDS_CONF..."
mv $FEEDS_CONF openwrt/feeds.conf.default
fi
chmod +x $DIY_P1_SH
cd openwrt && $GITHUB_WORKSPACE/$DIY_P1_SH
./scripts/feeds update -a
echo "Removing unnecessary packages..."
rm -rf feeds/luci/applications/luci-app-mosdns feeds/packages/net/{alist,adguardhome,mosdns,xray*,v2ray*,sing*,smartdns} feeds/packages/utils/v2dat feeds/packages/lang/golang
git clone https://github.com/kenzok8/golang feeds/packages/lang/golang
./scripts/feeds install -a
- name: Load custom configuration
run: |
if [ -e files ]; then
echo "Moving custom files to openwrt..."
mv files openwrt/files
fi
if [ -e $CONFIG_FILE ]; then
echo "Loading custom configuration from $CONFIG_FILE..."
cp $CONFIG_FILE openwrt/.config
fi
if [ "${{ env.FREQUENCY }}" == "1.5" ]; then
echo "Applying frequency-specific configuration for 1.5..."
# sed -i '/^CONFIG_TARGET_MULTI_PROFILE=y/d' openwrt/.config
sed -i '/^CONFIG_TARGET_rockchip_armv8_/ { /_xunlong_orangepi-r1-plus-lts/!d; }' openwrt/.config
sed -i '/^CONFIG_TARGET_DEVICE_rockchip_armv8_/ { /_xunlong_orangepi-r1-plus-lts/!d; }' openwrt/.config
fi
chmod +x $DIY_P2_SH
cd openwrt && $GITHUB_WORKSPACE/$DIY_P2_SH
- name: Download packages and update defconfig
run: |
cd openwrt
if [ "${{ env.SET }}" == "docker" ]; then
echo "Enabling Docker support in the configuration..."
echo "CONFIG_PACKAGE_luci-app-dockerman=y" >> .config
fi
cat .config
make defconfig
cat .config
make download -j8
find dl -size -1024c -exec rm -f {} \;
- name: Get Kernel Patchver
run: |
cd openwrt
grep "^KERNEL_PATCHVER:=" target/linux/rockchip/Makefile | sed 's/KERNEL_PATCHVER:=//' |
awk '{print "KERNEL_PATCHVER=" $0}' >> $GITHUB_ENV
- name: Compile firmware
run: |
cd openwrt
echo "Compiling firmware with $(nproc) threads..."
make -j$(nproc) || make -j1 || make -j1 V=s
- name: Organize files and set firmware output
if: success()
run: |
echo -e "✅ rockchip平台.\n🔔 长时间无法启动请尝试重启或重刷.\n⏰只有 R1 Plus LTS 版本的频率为 1.5GHz,其他版本的频率为 1.6GHz.\n⚠️ 如出现不稳定可尝试cpu降频." >> release.txt
echo "Organizing firmware files..."
cd openwrt/bin/targets/*/*
rm -rf packages
#rm -rf *.buildinfo
#rm -rf *.json
rm -rf *.manifest
ls
SUFFIX="${{ env.KERNEL_PATCHVER }}-${{ env.FREQUENCY }}"
[ "${{ env.SET }}" == "docker" ] && SUFFIX="${SUFFIX}-docker"
for file in *.img.gz; do
drive=$(echo "$file" | sed -E 's/^(openwrt-rockchip-armv8-)(.*)(-(ext4|squashfs)-sysupgrade\.img\.gz)$/\2-\4/')
new_filename="${drive}-${SUFFIX}.img.gz"
echo "Renaming $file to $new_filename"
mv "$file" "$new_filename"
done
echo "SUFFIX=$SUFFIX" >> $GITHUB_ENV
echo "FIRMWARE=$PWD" >> $GITHUB_ENV
- name: Upload firmware to release
if: success() && env.UPLOAD_FIRMWARE == 'true'
uses: actions/upload-artifact@main
with:
name: OpenWrt_firmware_${{ env.SUFFIX }}
path: ${{ env.FIRMWARE }}
- name: Upload firmware to release
uses: softprops/action-gh-release@master
if: success() && env.UPLOAD_RELEASE == 'true'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ needs.prepare_release.outputs.release_tag }}
body_path: release.txt
files: ${{ env.FIRMWARE }}/*
notice_and_cleanup:
needs: build_openwrt
runs-on: ubuntu-22.04
steps:
- name: Delete workflow runs
uses: Mattraks/delete-workflow-runs@main
with:
retain_days: 0
keep_minimum_runs: 2
- name: Remove old releases
if: env.UPLOAD_RELEASE == 'true'
uses: dev-drprasad/delete-older-releases@master
with:
keep_latest: 10
delete_tags: true
delete_tag_pattern: Lede-Rockchip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}