forked from sbwml/builder
-
Notifications
You must be signed in to change notification settings - Fork 0
289 lines (269 loc) · 14.6 KB
/
build-release.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
name: Build releases
on:
workflow_dispatch:
repository_dispatch:
types: [release]
jobs:
build:
name: Build ${{ matrix.model }}-${{ matrix.tag.version }}
runs-on: ubuntu-24.04
defaults:
run:
shell: bash
strategy:
fail-fast: false
matrix:
model:
- armv8
- nanopi-r4s
- nanopi-r5s
- x86_64
- netgear_r8500
tag:
- type: rc2
version: openwrt-24.10
steps:
- name: Setup variables
run: |
sudo timedatectl set-timezone 'Asia/Shanghai'
git config --global user.name 'actions'
git config --global user.email '[email protected]'
echo build_dir="/builder" >> "$GITHUB_ENV"
if [[ ${{ matrix.model }} != "nanopi-r4s" ]]; then
echo "release_kmod=true" >> "$GITHUB_ENV"
fi
if [ "${{ matrix.model }}" = "nanopi-r5s" ]; then
echo "kmod_repo=kmod-aarch64" >> "$GITHUB_ENV"
elif [ "${{ matrix.model }}" = "x86_64" ]; then
echo "kmod_repo=kmod-x86_64" >> "$GITHUB_ENV"
elif [ "${{ matrix.model }}" = "netgear_r8500" ]; then
echo "kmod_repo=kmod-bcm53xx" >> "$GITHUB_ENV"
elif [ "${{ matrix.model }}" = "armv8" ]; then
echo "kmod_repo=kmod-armsr-armv8" >> "$GITHUB_ENV"
fi
- name: Show system
run: |
echo -e "\n\e[1;32mCPU:\e[0m"
echo "$(grep 'model name' /proc/cpuinfo | head -1 | awk -F ': ' '{print $2}') ($(grep 'cpu MHz' /proc/cpuinfo | head -1 | awk -F ': ' '{print $2}')MHz) x $(grep processor /proc/cpuinfo | wc -l)"
echo -e "\n\e[1;32mMemory:\e[0m"
free -h
echo -e "\n\e[1;32mStorage:\e[0m"
df -Th / /mnt
echo -e "\n\e[1;32mSystem:\e[0m"
lsb_release -a
echo -e "\n\e[1;32mKernel:\e[0m"
uname -a
echo
- name: Free disk space
uses: sbwml/actions@free-disk
with:
build-mount-path: /builder
- name: Build System Setup
uses: sbwml/actions@openwrt-build-setup
- name: Install LLVM
uses: sbwml/actions@install-llvm
- name: Restore Cached
if: ${{ matrix.model != 'armv8' && matrix.model != 'nanopi-r4s' }}
uses: actions/cache/restore@v4
with:
path: /builder/.ccache
key: ${{ matrix.tag.version }}-${{ matrix.model }}
- name: Restore Cached (releases)
if: ${{ matrix.model == 'armv8' || matrix.model == 'nanopi-r4s' }}
continue-on-error: true
working-directory: /builder
run: |
wget -q https://github.com/${{ github.repository }}/releases/download/ccache/${{ matrix.model }}.tar.00 || true
wget -q https://github.com/${{ github.repository }}/releases/download/ccache/${{ matrix.model }}.tar.01 || true
cat ${{ matrix.model }}.tar.* | tar -xf - || true
rm -rf ${{ matrix.model }}.tar.* || true
cache_size=$(du -sb .ccache | awk '{print $1}')
cache_size_mb=$(echo "scale=0; ${cache_size} / (1024 * 1024)" | bc)
echo "Cache Size: ~${cache_size_mb} MB (${cache_size} B)"
echo "Cache restored successfully"
echo "Cache restored from key: ${{ matrix.model }}"
- name: Compile OpenWrt
id: compile
continue-on-error: true
working-directory: /builder
env:
git_password: ${{ secrets.ftp_password }}
private_url: ${{ secrets.private_url }}
run: |
[ "${{ matrix.model }}" != "netgear_r8500" ] && export KERNEL_CLANG_LTO=y
export BUILD_FAST=y ENABLE_CCACHE=y ENABLE_OTA=y ENABLE_BPF=y ENABLE_LTO=y ENABLE_LRNG=y USE_GCC15=y ENABLE_MOLD=y
bash <(curl -sS ${{ secrets.script_url_general }}) ${{ matrix.tag.type }} ${{ matrix.model }}
cd openwrt
tags=$(git describe --abbrev=0 --tags)
echo "latest_release=$tags" >>$GITHUB_ENV
- name: Extensive logs after a failed compilation
if: steps.compile.outcome == 'failure'
working-directory: /builder
run: |
cd openwrt
make V=s IGNORE_ERRORS="n m"
- name: Prepare Firmware Files
working-directory: /builder
run: |
mkdir -p rom info
if [ "${{ matrix.model }}" = "nanopi-r4s" ]; then
cp -a openwrt/bin/targets/rockchip/*/*.img.gz rom/
cp -a openwrt/bin/targets/rockchip/*/*-r4s.manifest info/manifest.txt
cp -a openwrt/bin/targets/rockchip/*/config.buildinfo info/config.buildinfo
cd rom && sha256sum * > ../info/sha256sums.txt
elif [ "${{ matrix.model }}" = "nanopi-r5s" ]; then
cp -a openwrt/bin/targets/rockchip/*/*.img.gz rom/
cp -a openwrt/bin/targets/rockchip/*/*.manifest info/manifest.txt
cp -a openwrt/bin/targets/rockchip/*/config.buildinfo info/config.buildinfo
cd rom && sha256sum * > ../info/sha256sums.txt
elif [ "${{ matrix.model }}" = "x86_64" ]; then
cp -a openwrt/bin/targets/x86/*/*-ext4-combined-efi.img.gz rom/
cp -a openwrt/bin/targets/x86/*/*-squashfs-combined-efi.img.gz rom/
cp -a openwrt/bin/targets/x86/*/*-generic-rootfs.tar.gz rom/
cp -a openwrt/bin/targets/x86/*/*-x86-64-generic.manifest info/manifest.txt
cp -a openwrt/bin/targets/x86/*/config.buildinfo info/config.buildinfo
cd rom && sha256sum * > ../info/sha256sums.txt
elif [ "${{ matrix.model }}" = "netgear_r8500" ]; then
cp -a openwrt/bin/targets/bcm53xx/generic/*-bcm53xx-generic-netgear_r8500-squashfs.chk rom/
cp -a openwrt/bin/targets/bcm53xx/generic/*.manifest info/manifest.txt
cp -a openwrt/bin/targets/bcm53xx/generic/config.buildinfo info/config.buildinfo
cd rom && sha256sum * > ../info/sha256sums.txt
elif [ "${{ matrix.model }}" = "armv8" ]; then
tar zcf rom/u-boot-qemu_armv8.tar.gz -C openwrt/bin/targets/armsr/armv8*/ ./u-boot-qemu_armv8
cp -a openwrt/bin/targets/armsr/armv8*/*-generic-initramfs-kernel.bin rom/
cp -a openwrt/bin/targets/armsr/armv8*/*-generic-kernel.bin rom/
cp -a openwrt/bin/targets/armsr/armv8*/*-generic-ext4-combined-efi.img.gz rom/
cp -a openwrt/bin/targets/armsr/armv8*/*-generic-squashfs-combined-efi.img.gz rom/
cp -a openwrt/bin/targets/armsr/armv8*/*-rootfs.tar.gz rom/
cp -a openwrt/bin/targets/armsr/armv8*/*.manifest info/manifest.txt
cp -a openwrt/bin/targets/armsr/armv8*/config.buildinfo info/config.buildinfo
cd rom && sha256sum * > ../info/sha256sums.txt
fi
cd ..
tar zcf rom/buildinfo_${{ matrix.model }}.tar.gz info
- name: Create virtual machine images
if: ${{ matrix.model == 'x86_64' }}
working-directory: /builder
run: |
mkdir -p virtual_images
cp -a openwrt/bin/targets/x86/*/*-generic-squashfs-combined-efi.img.gz virtual_images/
gzip -dq virtual_images/*-generic-squashfs-combined-efi.img.gz || true
cd virtual_images
image_name=$(basename -s .img *.img)
qemu-img convert -f raw -O qcow2 *.img $image_name.qcow2
qemu-img convert -f raw -O vpc *.img $image_name.vhd
qemu-img convert -f raw -O vmdk *.img $image_name.vmdk
rm -f *.img
sha256sum * > sha256sums.txt
echo "<center><h1>x86_64 虚拟机平台镜像</h1></center>" > README.md
- name: Create release
uses: ncipollo/[email protected]
with:
name: OpenWrt-${{ env.latest_release }}
allowUpdates: true
tag: ${{ env.latest_release }}
commit: main
replacesArtifacts: true
token: ${{ secrets.workflow_token }}
artifacts: |
${{ env.build_dir }}/rom/*
- name: Release kernel modules
if: ${{ matrix.model != 'nanopi-r4s' }}
uses: ncipollo/[email protected]
with:
name: OpenWrt-${{ env.latest_release }}
allowUpdates: true
tag: ${{ env.latest_release }}
commit: main
replacesArtifacts: true
token: ${{ secrets.workflow_token }}
artifacts: |
${{ env.build_dir }}/openwrt/*-*.tar.gz
- name: Sync kernel modules
if: env.release_kmod == 'true'
uses: peter-evans/repository-dispatch@v3
with:
token: ${{ secrets.workflow_token }}
repository: sbwml/${{ env.kmod_repo }}
event-type: sync
- name: Install aliyunpan & login
if: ${{ matrix.model != 'armv8' }}
continue-on-error: true
working-directory: /builder
timeout-minutes: 1
run: |
if [ "${{ matrix.model }}" = "nanopi-r4s" ]; then
device_id=${{ secrets.device_id_r4s }}
elif [ "${{ matrix.model }}" = "nanopi-r5s" ]; then
device_id=${{ secrets.device_id_r5s }}
elif [ "${{ matrix.model }}" = "x86_64" ]; then
device_id=${{ secrets.device_id_x86 }}
elif [ "${{ matrix.model }}" = "netgear_r8500" ]; then
device_id=${{ secrets.device_id_netgear }}
fi
sudo wget -q ${{ secrets.aliyunpan_go }} -O /bin/aliyunpan
sudo chmod 0755 /bin/aliyunpan
sudo sh -c 'echo "${{ secrets.aliyunpan_us_node }} api.alipan.com auth.alipan.com www.alipan.com" >> /etc/hosts'
export ALIYUNPAN_CONFIG_DIR="$(pwd)/.aliyunpan"
aliyun_token=`curl -s ${{ secrets.aliyun_token }} | openssl enc -aes-256-cfb -pbkdf2 -a -d -k ${{ secrets.token_dec }}`
aliyunpan config set -device_id=$device_id >/dev/null 2>&1
echo
echo $aliyun_token | aliyunpan login
- name: Upload Firmware - releases
if: ${{ matrix.model != 'armv8' }}
id: upload
continue-on-error: true
working-directory: /builder
timeout-minutes: 40
run: |
export ALIYUNPAN_CONFIG_DIR="$(pwd)/.aliyunpan"
version=$(cat openwrt/version.txt)
if [ "${{ matrix.model }}" = "nanopi-r4s" ]; then
aliyunpan upload --timeout 20 --retry 10 --ow info/config.buildinfo openwrt/nanopi-r4s/releases/${{ matrix.tag.version }}/$version/
aliyunpan upload --timeout 20 --retry 10 --ow info/manifest.txt openwrt/nanopi-r4s/releases/${{ matrix.tag.version }}/$version/
aliyunpan upload --timeout 20 --retry 10 --ow info/sha256sums.txt openwrt/nanopi-r4s/releases/${{ matrix.tag.version }}/$version/
aliyunpan upload --timeout 20 --retry 10 --ow rom/*-r4s-ext4-sysupgrade.img.gz openwrt/nanopi-r4s/releases/${{ matrix.tag.version }}/$version/
aliyunpan upload --timeout 20 --retry 10 --ow rom/*-r4s-squashfs-sysupgrade.img.gz openwrt/nanopi-r4s/releases/${{ matrix.tag.version }}/$version/
elif [ "${{ matrix.model }}" = "nanopi-r5s" ]; then
aliyunpan upload --timeout 20 --retry 10 --ow info/config.buildinfo openwrt/nanopi-r5s/releases/${{ matrix.tag.version }}/$version/
aliyunpan upload --timeout 20 --retry 10 --ow info/manifest.txt openwrt/nanopi-r5s/releases/${{ matrix.tag.version }}/$version/
aliyunpan upload --timeout 20 --retry 10 --ow info/sha256sums.txt openwrt/nanopi-r5s/releases/${{ matrix.tag.version }}/$version/
aliyunpan upload --timeout 20 --retry 10 --ow rom/*-r5c-ext4-sysupgrade.img.gz openwrt/nanopi-r5s/releases/${{ matrix.tag.version }}/$version/
aliyunpan upload --timeout 20 --retry 10 --ow rom/*-r5c-squashfs-sysupgrade.img.gz openwrt/nanopi-r5s/releases/${{ matrix.tag.version }}/$version/
aliyunpan upload --timeout 20 --retry 10 --ow rom/*-r5s-ext4-sysupgrade.img.gz openwrt/nanopi-r5s/releases/${{ matrix.tag.version }}/$version/
aliyunpan upload --timeout 20 --retry 10 --ow rom/*-r5s-squashfs-sysupgrade.img.gz openwrt/nanopi-r5s/releases/${{ matrix.tag.version }}/$version/
elif [ "${{ matrix.model }}" = "x86_64" ]; then
aliyunpan upload --timeout 30 --retry 10 --ow info/config.buildinfo openwrt/x86_64/releases/${{ matrix.tag.version }}/$version/
aliyunpan upload --timeout 30 --retry 10 --ow info/manifest.txt openwrt/x86_64/releases/${{ matrix.tag.version }}/$version/
aliyunpan upload --timeout 30 --retry 10 --ow info/sha256sums.txt openwrt/x86_64/releases/${{ matrix.tag.version }}/$version/
aliyunpan upload --timeout 30 --retry 10 --ow rom/*-generic-rootfs.tar.gz openwrt/x86_64/releases/${{ matrix.tag.version }}/$version/
aliyunpan upload --timeout 30 --retry 10 --ow rom/*-ext4-combined-efi.img.gz openwrt/x86_64/releases/${{ matrix.tag.version }}/$version/
aliyunpan upload --timeout 30 --retry 10 --ow rom/*-squashfs-combined-efi.img.gz openwrt/x86_64/releases/${{ matrix.tag.version }}/$version/
# virtual machine images
aliyunpan upload --timeout 30 --retry 10 --ow virtual_images/README.md openwrt/x86_64/releases/${{ matrix.tag.version }}/$version/virtual_machine_images/
aliyunpan upload --timeout 30 --retry 10 --ow virtual_images/sha256sums.txt openwrt/x86_64/releases/${{ matrix.tag.version }}/$version/virtual_machine_images/
aliyunpan upload --timeout 30 --retry 10 --ow virtual_images/*.vmdk openwrt/x86_64/releases/${{ matrix.tag.version }}/$version/virtual_machine_images/
aliyunpan upload --timeout 30 --retry 10 --ow virtual_images/*.vhd openwrt/x86_64/releases/${{ matrix.tag.version }}/$version/virtual_machine_images/
aliyunpan upload --timeout 30 --retry 10 --ow virtual_images/*.qcow2 openwrt/x86_64/releases/${{ matrix.tag.version }}/$version/virtual_machine_images/
elif [ "${{ matrix.model }}" = "netgear_r8500" ]; then
aliyunpan upload --timeout 20 --retry 10 --ow info/config.buildinfo openwrt/netgear-r8500/releases/${{ matrix.tag.version }}/$version/
aliyunpan upload --timeout 20 --retry 10 --ow info/manifest.txt openwrt/netgear-r8500/releases/${{ matrix.tag.version }}/$version/
aliyunpan upload --timeout 20 --retry 10 --ow info/sha256sums.txt openwrt/netgear-r8500/releases/${{ matrix.tag.version }}/$version/
aliyunpan upload --timeout 20 --retry 10 --ow rom/*.chk openwrt/netgear-r8500/releases/${{ matrix.tag.version }}/$version/
fi
aliyunpan recycle delete -all
echo y | aliyunpan logout
- name: Retry Upload Firmware - releases
if: steps.upload.outcome == 'failure'
run: |
sshpass -p ${{ secrets.user_password }} ssh -o StrictHostKeyChecking=no root@${{ secrets.ftp_address }} >/dev/null 2>&1
sshpass -p ${{ secrets.user_password }} ssh root@${{ secrets.ftp_address }} "/opt/sbin/fw-upload ${{ matrix.model }}"
- name: Release OTA
uses: SamKirkland/[email protected]
with:
username: openwrt
server: ${{ secrets.ftp_address }}
password: ${{ secrets.ftp_password }}
server-dir: release/${{ matrix.model }}/
local-dir: ${{ env.build_dir }}/openwrt/ota/
dangerous-clean-slate: true