forked from friendlyarm/Actions-FriendlyWrt
-
Notifications
You must be signed in to change notification settings - Fork 0
277 lines (250 loc) · 9.63 KB
/
build.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
on:
repository_dispatch:
workflow_dispatch:
jobs:
prepare_release:
runs-on: ubuntu-20.04
if: github.event.repository.owner.id == github.event.sender.id
steps:
- name: Get release tag
id: release_tag
run: |
release_tag="FriendlyWrt-$(date +%Y-%m-%d)"
echo "##[set-output name=release_tag;]$release_tag"
- name: Create empty release
id: release
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.release_tag.outputs.release_tag }}
draft: false
prerelease: false
outputs:
release_tag: ${{ steps.release_tag.outputs.release_tag }}
upload_url: ${{ steps.release.outputs.upload_url }}
build_friendlywrt:
needs: prepare_release
runs-on: ubuntu-20.04
if: github.event.repository.owner.id == github.event.sender.id
strategy:
matrix:
VERSION: [23.05]
SET: [non-docker]
steps:
- name: Checkout
uses: actions/checkout@main
- name: Initialization environment
env:
DEBIAN_FRONTEND: noninteractive
run: |
sudo rm -rf /etc/apt/sources.list.d
wget https://raw.githubusercontent.com/friendlyarm/build-env-on-ubuntu-bionic/master/install.sh
sed -i -e 's/^apt-get -y install openjdk-8-jdk/# apt-get -y install openjdk-8-jdk/g' install.sh
sed -i -e 's/^\[ -d fa-toolchain \]/# [ -d fa-toolchain ]/g' install.sh
sed -i -e 's/^(cat fa-toolchain/# (cat fa-toolchain/g' install.sh
sed -i -e 's/^(tar xf fa-toolchain/# (tar xf fa-toolchain/g' install.sh
sudo -E bash ./install.sh
sudo -E update-alternatives --install $(which python) python /usr/bin/python2.7 20
sudo -E git config --global user.name 'GitHub Actions'
sudo -E git config --global user.email 'noreply@github.com'
git clone https://github.com/friendlyarm/repo
sudo -E cp repo/repo /usr/bin/
mkdir -p ./artifact
sudo swapoff -a
sudo rm -rf /usr/share/dotnet /usr/local/lib/android/sdk /usr/local/share/boost /opt/ghc
echo "cores: $(nproc)"
- name: Download source
run: |
mkdir project
cd project
repo init --depth=1 -u https://github.com/friendlyarm/friendlywrt_manifests -b master-v${{ matrix.VERSION }} \
-m rk3399.xml --repo-url=https://github.com/friendlyarm/repo --no-clone-bundle
repo sync -c friendlywrt --no-clone-bundle
repo sync -c configs --no-clone-bundle
repo sync -c device/common --no-clone-bundle
repo sync -c device/friendlyelec --no-clone-bundle
repo sync -c scripts --no-clone-bundle
repo sync -c scripts/sd-fuse --no-clone-bundle
repo sync -c toolchain --no-clone-bundle
- name: Apply customizations
run: |
cd project
source ../scripts/add_packages.sh
source ../scripts/custome_config.sh
source ../scripts/wifi/add_rtl8852be.sh
- name: Prepare dot config and feeds
run: |
cd project
[ "${{ matrix.SET }}" == "docker" ] && SUFFIX="-docker"
DIRNAME=friendlywrt$(echo ${{ matrix.VERSION }}|awk -F . '{print $1}')${SUFFIX}
CONFIG=rockchip${SUFFIX}
cat > .current_config.mk <<EOL
. device/friendlyelec/rk3399/base.mk
TARGET_IMAGE_DIRNAME=${DIRNAME}
TARGET_FRIENDLYWRT_CONFIG=${CONFIG}
EOL
DEBUG_DOT_CONFIG=1 ./build.sh friendlywrt
- name: Download package
run: |
cd project/friendlywrt
make download -j8
find dl -size -1024c -exec ls -l {} \;
find dl -size -1024c -exec rm -f {} \;
- name: Compile friendlyWrt
id: compile
continue-on-error: true
run: |
cd project/friendlywrt
make -j$(nproc) || make -j1 V=s
echo $?
- name: Check the result and try again
if: steps.compile.outcome == 'failure'
run: |
cd project/friendlywrt
make -j1 V=s
- name: Create rootfs package
id: create_rootfs_package
run: |
cd project
source .current_config.mk
[ "${{ matrix.SET }}" == "docker" ] && SUFFIX="-docker"
rootfs_filename="rootfs-friendlywrt-${{ matrix.VERSION }}${SUFFIX}.tgz"
tar cvzf ../artifact/${rootfs_filename} ${FRIENDLYWRT_SRC}/${FRIENDLYWRT_ROOTFS} \
${FRIENDLYWRT_SRC}/${FRIENDLYWRT_PACKAGE_DIR}
echo "##[set-output name=rootfs_filename;]$rootfs_filename"
- name: Upload rootfs package
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ./artifact/${{ steps.create_rootfs_package.outputs.rootfs_filename }}
asset_name: ${{ steps.create_rootfs_package.outputs.rootfs_filename }}
tag: ${{ needs.prepare_release.outputs.release_tag }}
overwrite: true
build_img:
needs: [prepare_release,build_friendlywrt]
runs-on: ubuntu-20.04
if: github.event.repository.owner.id == github.event.sender.id
strategy:
matrix:
VERSION: [23.05]
CPU: [rk3399]
SET: [non-docker]
steps:
- name: Checkout
uses: actions/checkout@main
- name: Initialization environment
env:
DEBIAN_FRONTEND: noninteractive
run: |
sudo rm -rf /etc/apt/sources.list.d
wget https://raw.githubusercontent.com/friendlyarm/build-env-on-ubuntu-bionic/master/install.sh
sed -i -e 's/^apt-get -y install openjdk-8-jdk/# apt-get -y install openjdk-8-jdk/g' install.sh
sed -i -e 's/^\[ -d fa-toolchain \]/# [ -d fa-toolchain ]/g' install.sh
sed -i -e 's/^(cat fa-toolchain/# (cat fa-toolchain/g' install.sh
sed -i -e 's/^(tar xf fa-toolchain/# (tar xf fa-toolchain/g' install.sh
sudo -E bash ./install.sh
sudo -E update-alternatives --install $(which python) python /usr/bin/python2.7 20
sudo -E git config --global user.name 'GitHub Actions'
sudo -E git config --global user.email 'noreply@github.com'
git clone https://github.com/friendlyarm/repo
sudo -E cp repo/repo /usr/bin/
mkdir -p ./artifact
sudo swapoff -a
sudo rm -rf /usr/share/dotnet /usr/local/lib/android/sdk /usr/local/share/boost /opt/ghc
echo "cores: $(nproc)"
- name: Download source
run: |
mkdir project
cd project
repo init --depth=1 -u https://github.com/friendlyarm/friendlywrt_manifests -b master-v${{ matrix.VERSION }} \
-m ${{ matrix.CPU }}.xml --repo-url=https://github.com/friendlyarm/repo --no-clone-bundle
repo sync -c kernel --no-clone-bundle
repo sync -c u-boot --no-clone-bundle
repo sync -c rkbin --no-clone-bundle
repo sync -c configs --no-clone-bundle
repo sync -c device/common --no-clone-bundle
repo sync -c device/friendlyelec --no-clone-bundle
repo sync -c scripts --no-clone-bundle
repo sync -c scripts/sd-fuse --no-clone-bundle
repo sync -c toolchain --no-clone-bundle
- name: Download friendlywrt rootfs (non-docker)
if: matrix.SET == 'non-docker'
uses: robinraju/release-downloader@v1.6
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
repository: ${{ github.repository }}
tag: ${{ needs.prepare_release.outputs.release_tag }}
fileName: "rootfs-friendlywrt-${{ matrix.VERSION }}.tgz"
- name: Download friendlywrt rootfs (docker)
if: matrix.SET == 'docker'
uses: robinraju/release-downloader@v1.6
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
repository: ${{ github.repository }}
tag: ${{ needs.prepare_release.outputs.release_tag }}
fileName: "rootfs-friendlywrt-${{ matrix.VERSION }}-docker.tgz"
- name: Prepare config
id: config
run: |
cd project
case ${{ matrix.CPU }} in
rk3328)
MODEL=R2S-R2C-Series
;;
rk3399)
MODEL=R4S-Series
;;
rk3568)
MODEL=R5S-R5C-Series
;;
rk3566)
MODEL=R3S-Series
;;
rk3588)
MODEL=T6-R6S-R6C-M6-Series
;;
*)
echo "unknow cpu"
exit 1
;;
esac
[ "${{ matrix.SET }}" == "docker" ] && SUFFIX="-docker"
FILENAME=${MODEL}-FriendlyWrt-${{ matrix.VERSION }}${SUFFIX}.img
DIRNAME=friendlywrt$(echo ${{ matrix.VERSION }}|awk -F . '{print $1}')${SUFFIX}
CONFIG=rockchip${SUFFIX}
cat > .current_config.mk <<EOL
. device/friendlyelec/${{ matrix.CPU }}/base.mk
TARGET_IMAGE_DIRNAME=${DIRNAME}
TARGET_FRIENDLYWRT_CONFIG=${CONFIG}
TARGET_SD_RAW_FILENAME=${FILENAME}
EOL
echo "##[set-output name=img_filename;]$FILENAME"
- name: Unpack friendlywrt rootfs
run: |
cd project
[ "${{ matrix.SET }}" == "docker" ] && SUFFIX="-docker"
tar xvzf "../rootfs-friendlywrt-${{ matrix.VERSION }}${SUFFIX}.tgz"
- name: Compile uboot and kernel
run: |
cd project
./build.sh uboot
./build.sh kernel
- name: Build sd image
id: build_sd_image
run: |
cd project
./build.sh sd-img
mv out/${{ steps.config.outputs.img_filename }} ../artifact/
cd ../artifact/
gzip *.img
- name: Upload image to release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ./artifact/${{ steps.config.outputs.img_filename }}.gz
asset_name: ${{ steps.config.outputs.img_filename }}.gz
tag: ${{ needs.prepare_release.outputs.release_tag }}
overwrite: true