forked from SuLingGG/OpenWrt-Rpi
-
Notifications
You must be signed in to change notification settings - Fork 0
271 lines (246 loc) · 11.2 KB
/
build-rpi4-lean-openwrt.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
#=================================================
# https://github.com/P3TERX/Actions-OpenWrt
# Description: Build OpenWrt using GitHub Actions
# Lisence: MIT
# Author: P3TERX
# Blog: https://p3terx.com
#=================================================
name: Build Raspberry Pi 4 Lean's OpenWrt
on:
repository_dispatch:
types: [lean, rpi4]
workflow_dispatch:
schedule:
- cron: 0 18 * * *
# watch:
# types: started
env:
REPO_URL: https://github.com/coolsnowwolf/lede
REPO_BRANCH: master
CONFIG_FILE: config/bcm27xx/rpi4-lean-target.config
DIY_SH: scripts/lean-openwrt.sh
IPV6MOD_IN_FIRMWARE: true
KMODS_IN_FIRMWARE: true
WEBROOT: /data/dnmp/www/openwrt.cc
UPLOAD_RCLONE: true
UPLOAD_WETRANSFER: true
TZ: Asia/Shanghai
jobs:
Build:
runs-on: ubuntu-18.04
outputs:
OPENWRTROOT: ${{ steps.update.outputs.OPENWRTROOT }}
PLATFORM: ${{ steps.compile.outputs.PLATFORM }}
TARGET: ${{ steps.compile.outputs.TARGET }}
SUBTARGET: ${{ steps.compile.outputs.SUBTARGET }}
FIRMWARE: ${{ steps.compile.outputs.FIRMWARE }}
GENERATE_STATUS: ${{ steps.generate.outputs.GENERATE_STATUS }}
steps:
- name: Checkout
uses: actions/checkout@main
- name: Initialization Environment
env:
DEBIAN_FRONTEND: noninteractive
run: |
sudo rm -rf /etc/apt/sources.list.d/* /usr/share/dotnet /usr/local/lib/android /opt/ghc
sudo -E apt-get -qq update
sudo -E apt-get -qq install $(curl -fsSL git.io/depends-ubuntu-1804) tree
sudo -E apt-get -qq autoremove --purge
sudo -E apt-get -qq clean
sudo ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
- name: Clone Source Code
run: |
df -hT $PWD
git clone --depth 1 $REPO_URL -b $REPO_BRANCH openwrt
- name: Update Feeds
id: update
run: |
cd openwrt
echo "OPENWRTROOT=$PWD" >> $GITHUB_ENV
echo "::set-output name=OPENWRTROOT::$(echo $PWD)"
mkdir customfeeds
git clone --depth=1 https://github.com/coolsnowwolf/packages customfeeds/packages
git clone --depth=1 https://github.com/coolsnowwolf/luci customfeeds/luci
chmod +x ../scripts/*.sh
../scripts/hook-feeds.sh
- name: Install Feeds
run: |
cd $OPENWRTROOT
./scripts/feeds install -a
- name: Load Custom Configuration
run: |
[ -e files ] && mv files $OPENWRTROOT/files
[ -e $CONFIG_FILE ] && mv $CONFIG_FILE $OPENWRTROOT/.config
cat config/bcm27xx/rpi-lean-extra.config >> $OPENWRTROOT/.config
cd $OPENWRTROOT
../$DIY_SH
../scripts/preset-clash-core.sh armv8
../scripts/preset-terminal-tools.sh
../scripts/enable-rpi4-wifi.sh
- name: Download Package
id: package
run: |
cd $OPENWRTROOT
if "$KMODS_IN_FIRMWARE" = 'true'
then
echo "CONFIG_ALL_NONSHARED=y" >> .config
fi
make defconfig
make download -j8
find dl -size -1024c -exec ls -l {} \;
find dl -size -1024c -exec rm -f {} \;
- name: Compile Packages
id: compile
run: |
cd $OPENWRTROOT
echo -e "$(nproc) thread compile"
make tools/compile -j$(nproc) || make tools/compile -j1 V=s
make toolchain/compile -j$(nproc) || make toolchain/compile -j1 V=s
make target/compile -j$(nproc) || make target/compile -j1 V=s IGNORE_ERRORS=1
make diffconfig
make package/compile -j$(nproc) IGNORE_ERRORS=1 || make package/compile -j1 V=s IGNORE_ERRORS=1
make package/index
cd $OPENWRTROOT/bin/packages/*
PLATFORM=$(basename `pwd`)
echo "PLATFORM=$PLATFORM" >> $GITHUB_ENV
echo "::set-output name=PLATFORM::$(echo $PLATFORM)"
cd $OPENWRTROOT/bin/targets/*
TARGET=$(basename `pwd`)
echo "TARGET=$TARGET" >> $GITHUB_ENV
echo "::set-output name=TARGET::$(echo $TARGET)"
cd *
SUBTARGET=$(basename `pwd`)
echo "SUBTARGET=$SUBTARGET" >> $GITHUB_ENV
echo "::set-output name=SUBTARGET::$(echo $SUBTARGET)"
echo "FIRMWARE=$PWD" >> $GITHUB_ENV
echo "::set-output name=FIRMWARE::$(echo $PWD)"
echo "::set-output name=COMPILE_STATUS::success"
- name: Generate Firmware
if: steps.compile.outputs.COMPILE_STATUS == 'success'
id: generate
run: |
cd data/opkg
sed -i "s/subtarget/$SUBTARGET/g" distfeeds*.conf
sed -i "s/target\//$TARGET\//g" distfeeds*.conf
sed -i "s/platform/$PLATFORM/g" distfeeds*.conf
cd $OPENWRTROOT
echo "dtparam=i2c_arm=on,audio=on" >> target/linux/bcm27xx/image/config.txt
mkdir -p files/etc/uci-defaults/
cp ../scripts/init-settings.sh files/etc/uci-defaults/99-init-settings
mkdir -p files/etc/opkg
cp ../data/opkg/distfeeds-packages-server.conf files/etc/opkg/distfeeds.conf.server
if "$KMODS_IN_FIRMWARE" = 'true'
then
mkdir -p files/www/snapshots
cp -r bin/targets files/www/snapshots
cp ../data/opkg/distfeeds-18.06-local.conf files/etc/opkg/distfeeds.conf
else
cp ../data/opkg/distfeeds-18.06-remote.conf files/etc/opkg/distfeeds.conf
fi
cp files/etc/opkg/distfeeds.conf.server files/etc/opkg/distfeeds.conf.mirror
sed -i "s/http:\/\/192.168.123.100:2345\/snapshots/https:\/\/openwrt.cc\/snapshots\/$(date +"%Y-%m-%d")\/lean/g" files/etc/opkg/distfeeds.conf.mirror
if "$IPV6MOD_IN_FIRMWARE" = 'true'
then
mkdir -p files/www/ipv6-modules
cp bin/packages/$PLATFORM/luci/luci-proto-ipv6* files/www/ipv6-modules
cp bin/packages/$PLATFORM/base/{ipv6helper*,odhcpd-ipv6only*,odhcp6c*,6in4*} "files/www/ipv6-modules"
cp bin/targets/$TARGET/$SUBTARGET/packages/{ip6tables*,kmod-nf-nat6*,kmod-ipt-nat6*,kmod-sit*,kmod-ip6tables-extra*} "files/www/ipv6-modules"
mkdir -p files/bin
cp ../scripts/ipv6-helper.sh files/bin/ipv6-helper
fi
make package/install -j$(nproc) || make package/install -j1 V=s
make target/install -j$(nproc) || make target/install -j1 V=s
make checksum
echo "::set-output name=GENERATE_STATUS::success"
- name: Upload Bin Folder
uses: actions/upload-artifact@main
if: steps.generate.outputs.GENERATE_STATUS == 'success'
with:
name: bin-archive
path: openwrt/bin
Upload:
needs: [Build]
runs-on: ubuntu-18.04
steps:
- name: Checkout
uses: actions/checkout@main
- name: Restore Variables
run: |
echo "OPENWRTROOT=$(echo '${{needs.Build.outputs.OPENWRTROOT}}')" >> $GITHUB_ENV
echo "PLATFORM=$(echo '${{needs.Build.outputs.PLATFORM}}')" >> $GITHUB_ENV
echo "TARGET=$(echo '${{needs.Build.outputs.TARGET}}')" >> $GITHUB_ENV
echo "SUBTARGET=$(echo '${{needs.Build.outputs.SUBTARGET}}')" >> $GITHUB_ENV
echo "FIRMWARE=$(echo '${{needs.Build.outputs.FIRMWARE}}')" >> $GITHUB_ENV
echo "GENERATE_STATUS=$(echo '${{needs.Build.outputs.GENERATE_STATUS}}')" >> $GITHUB_ENV
- name: Download Bin Folder
uses: actions/download-artifact@v2
if: env.GENERATE_STATUS == 'success'
with:
name: bin-archive
path: openwrt/bin
- name: Deploy Packages-Server
if: env.GENERATE_STATUS == 'success'
run: |
sudo ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
mkdir -p server/web/snapshots/targets/$TARGET/$SUBTARGET
cp -r $OPENWRTROOT/bin/packages server/web/snapshots
cp -r $OPENWRTROOT/bin/targets/$TARGET/$SUBTARGET/packages server/web/snapshots/targets/$TARGET/$SUBTARGET
mv server packages-server
zip -qrm packages-server.zip packages-server
mv packages-server.zip $OPENWRTROOT/bin/targets/$TARGET/$SUBTARGET
- name: Rclone Upload
env:
RCLONE_PACKAGE: ${{ secrets.RCLONE_PACKAGE }}
RCLONE_FIRMWARE: ${{ secrets.RCLONE_FIRMWARE }}
if: env.GENERATE_STATUS == 'success' && env.UPLOAD_RCLONE == 'true' && env.RCLONE_PACKAGE != ''
run: |
cd $OPENWRTROOT
curl https://rclone.org/install.sh | sudo bash
mkdir -p ~/.config/rclone/
cat << EOF > ~/.config/rclone/rclone.conf
${{ secrets.RCLONE_CONFIG }}
EOF
rclone copy bin $RCLONE_PACKAGE:$(date +"%Y-%m-%d")/lean --filter-from ../data/rclone/upload-rule.txt
rclone copy bin/targets $RCLONE_FIRMWARE:$(date +"%Y-%m-%d")/lean --exclude "packages/"
echo "::warning file=Firmware-GoogleDrive::Download Link: https://drive.google.com/drive/folders/1_P2RoPbguY99qJxmCU4SKUgP8Kg0Xr03"
- name: Deploy Files To Server
env:
HOST: "${{ secrets.REMOTE_USER }}@${{ secrets.REMOTE_IP }}"
SOURCE_TARGETS: "openwrt/bin/targets/${{ env.TARGET }}/${{ env.SUBTARGET }}/"
DEST_TARGETS: "${{ env.WEBROOT }}/releases/targets/${{ env.TARGET }}/${{ env.SUBTARGET }}/"
REMOTE_PRIVATEKEY: "${{secrets.REMOTE_PRIVATEKEY}}"
if: env.GENERATE_STATUS == 'success' && env.REMOTE_PRIVATEKEY != null
run: |
mkdir -p ~/.ssh/
install -m 600 /dev/null ~/.ssh/id_rsa
echo "${{secrets.REMOTE_PRIVATEKEY}}" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
ssh -q -t -i ~/.ssh/id_rsa -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no $HOST \
bash -c "'mkdir -p $WEBROOT/releases/targets/$TARGET/$SUBTARGET'"
rsync -chav --delete -e 'ssh -i ~/.ssh/id_rsa -o StrictHostKeyChecking=no' $SOURCE_TARGETS $HOST:$DEST_TARGETS
ssh -q -t -i ~/.ssh/id_rsa -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no $HOST \
bash -c "'mkdir -p $WEBROOT/archive/$(date +%Y)/$(date +%m)/$(date +%d)/releases/targets/$TARGET && \
cp -rf $WEBROOT/releases/targets/$TARGET/$SUBTARGET $WEBROOT/archive/$(date +%Y)/$(date +%m)/$(date +%d)/releases/targets/$TARGET'"
echo "::warning file=Firmware-OpenWrt.cc::Download Link: https://openwrt.cc/releases/targets/$TARGET/$SUBTARGET"
- name: Organize Files
id: organize
if: env.GENERATE_STATUS == 'success'
run: |
cd ${FIRMWARE}
rm -rf packages
cd $OPENWRTROOT/bin/targets/$TARGET/
curl -sL https://git.io/file-transfer | bash -s beta
sudo mv transfer /usr/bin
sudo chmod +x /usr/bin/transfer
df -hT $PWD
echo "::set-output name=ORGANIZE_STATUS::success"
- name: Upload Firmware To WeTransfer
if: steps.organize.outputs.ORGANIZE_STATUS == 'success' && env.UPLOAD_WETRANSFER == 'true'
run: |
transfer wet -s -p 16 --no-progress ${FIRMWARE} 2>&1 | tee wetransfer.log
echo "::warning file=Firmware-Wetransfer.com::$(cat wetransfer.log | grep https)"
- name: Delete Artifacts
uses: geekyeggo/delete-artifact@v1
with:
name: |
bin-archive