-
Notifications
You must be signed in to change notification settings - Fork 246
289 lines (269 loc) · 10.5 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
277
278
279
280
281
282
283
284
285
286
287
288
289
#
# 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
on:
repository_dispatch:
workflow_dispatch:
inputs:
branch:
description: 'branch:'
default: 'istoreos-23.05'
required: true
type: choice
options: [ istoreos-22.03, istoreos-23.05 ]
config_s:
description: 'config:'
default: 'Vip-Super'
required: true
type: choice
options: [ Vip-Super ]
cpu_s:
description: 'CPU:'
required: true
default: '8'
type: choice
options:
- '8'
- '8370C'
- '8272CL'
- '8171M'
target:
description: 'target:'
default: 'x86_64'
required: true
type: choice
options: [ x86_64 ]
date_s:
description: 'date'
default: 'default'
required: false
env:
REPO_URL: https://github.com/istoreos/istoreos
FEEDS_CONF: feeds.conf.default
DIY_P1_SH: diy
UPLOAD_BIN_DIR: false
UPLOAD_IPK_DIR: false
UPLOAD_FIRMWARE: true
UPLOAD_RELEASE: true
TZ: Asia/Shanghai
jobs:
build:
runs-on: ubuntu-22.04
if: github.event.repository.owner.id == github.event.sender.id
name: istoreos-${{github.event.inputs.config_s}}-${{github.event.inputs.target}}-${{github.event.inputs.branch}}-${{github.event.inputs.date_s}}
env:
CONFIG_S: ${{github.event.inputs.config_s}}
CPU_S: ${{github.event.inputs.cpu_s}}
DATE_S: ${{github.event.inputs.date_s}}
TARGET_DEVICE: ${{github.event.inputs.target}}
REPO_BRANCH: ${{github.event.inputs.branch}}
steps:
- name: Checkout
uses: actions/checkout@main
- name: install Go 1.21.1
uses: actions/setup-go@v5
with:
go-version: 'stable'
- name: Set time zone
run: sudo timedatectl set-timezone 'Asia/Shanghai'
- name: Show system
run: |
echo -e "Total CPU cores\t: $(nproc)"
cat /proc/cpuinfo | grep 'model name'
free -h
df -Th
cpu_name=$(cat /proc/cpuinfo | grep "model name" | head -n 1 | awk -F: '{print $2}' | sed 's/^[ \t]*//')
if [[ "$cpu_name" =~ "8370C" || "$cpu_name" =~ "7763" ]]; then
ulimit -a
fi
- name: Set release env
run: |
echo WORKDIR="/builder" >> "$GITHUB_ENV"
- name: Free disk space
run: |
sudo rm -rf /etc/apt/sources.list.d
sudo bash -c "curl -s https://us.cooluc.com/ubuntu-apt/sources-22.04.list > /etc/apt/sources.list"
sudo swapoff -a
sudo rm -f /swapfile /mnt/swapfile
sudo docker image prune -a -f
sudo systemctl stop docker
sudo snap set system refresh.retain=2
sudo apt-get -y purge firefox clang* ghc* google* llvm* mono* mongo* mysql* php*
sudo apt-get -y autoremove --purge
sudo apt-get clean
sudo rm -rf /etc/mysql /etc/php /usr/lib/jvm /usr/libexec/docker /usr/local /usr/src/* /var/lib/docker /var/lib/gems /var/lib/mysql /var/lib/snapd /etc/skel /opt/{microsoft,az,hostedtoolcache,cni,mssql-tools,pipx} /usr/share/{az*,dotnet,swift,miniconda,gradle*,java,kotlinc,ri,sbt} /root/{.sbt,.local,.npm}
sudo sed -i '/NVM_DIR/d;/skel/d' /root/{.bashrc,.profile}
rm -rf ~/{.cargo,.dotnet,.rustup}
df -Th
- name: Create VG & LV
run: |
mnt_size=$(expr $(df -h /mnt | tail -1 | awk '{print $4}' | sed 's/[[:alpha:]]//g' | sed 's/\..*//') - 1)
root_size=$(expr $(df -h / | tail -1 | awk '{print $4}' | sed 's/[[:alpha:]]//g' | sed 's/\..*//') - 4)
sudo truncate -s "$mnt_size"G /mnt/mnt.img
sudo truncate -s "$root_size"G /root.img
sudo losetup /dev/loop6 /mnt/mnt.img
sudo losetup /dev/loop7 /root.img
sudo pvcreate /dev/loop6
sudo pvcreate /dev/loop7
sudo vgcreate github /dev/loop6 /dev/loop7
sudo lvcreate -n runner -l 100%FREE github
sudo mkfs.xfs /dev/github/runner
- name: Mount LV
run: |
sudo mkdir -p /builder
sudo mount /dev/github/runner /builder
sudo chown -R runner.runner /builder
sudo chown $USER:$GROUPS /builder
- name: Build System Setup
env:
DEBIAN_FRONTEND: noninteractive
run: |
sudo sh -c 'echo "deb http://apt.llvm.org/focal/ llvm-toolchain-focal-17 main" >> /etc/apt/sources.list'
sudo sh -c 'echo "deb-src http://apt.llvm.org/focal/ llvm-toolchain-focal-17 main" >> /etc/apt/sources.list'
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
sudo apt-get update
sudo apt-get install -y build-essential flex bison clang-17 cmake g++ gawk gcc-multilib g++-multilib gettext git libfuse-dev libncurses5-dev libssl-dev python3 python3-pip python3-ply python3-distutils python3-pyelftools rsync unzip zlib1g-dev file wget subversion patch upx-ucl autoconf automake curl asciidoc binutils bzip2 lib32gcc-s1 libc6-dev-i386 uglifyjs msmtp texinfo libreadline-dev libglib2.0-dev xmlto libelf-dev libtool autopoint antlr3 gperf ccache swig coreutils haveged scons libpython3-dev rename
sudo apt-get clean
git config --global user.name 'GitHub Actions' && git config --global user.email 'noreply@github.com'
df -Th
sudo timedatectl set-timezone "$TZ"
sudo ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
- name: Clone source code
working-directory: /builder
run: |
df -hT $PWD
git clone $REPO_URL -b ${{env.REPO_BRANCH}} openwrt
git clone ${{ secrets.URL }} lede
cp -Rf ./lede/* openwrt
ln -sf /builder/openwrt $GITHUB_WORKSPACE/openwrt
- name: Update feeds
run: cd openwrt && ./scripts/feeds update -a
- name: Install feeds
run: cd openwrt && ./scripts/feeds install -a
- name: Load custom feeds
run: |
[ -e $FEEDS_CONF ] && mv $FEEDS_CONF openwrt/feeds.conf.default
df -h
chmod +x $DIY_P1_SH || true
cd openwrt
echo "OPENWRTROOT=$PWD" >> $GITHUB_ENV
echo "::set-output name=OPENWRTROOT::$(echo $PWD)"
chmod +x $DIY_P1_SH || true
[ -e $DIY_P1_SH ] && ./$DIY_P1_SH || ../$DIY_P1_SH
chmod -R 755 .
- name: Cache
id: cache
uses: stupidloud/cachewrtbuild@main
with:
ccache: 'true'
mixkey: ${{ env.TARGET_DEVICE }}-${{ env.REPO_BRANCH }}
skip_saving: 'true'
prefix: /builder/openwrt
- name: defconfig
run: |
cd openwrt
make defconfig
- name: Download package
id: package
run: |
cd openwrt
make download -j50
find dl -size -1024c -exec ls -l {} \;
find dl -size -1024c -exec rm -f {} \;
- name: Compile Packages
id: compileopenwrt
run: |
df -h
cd openwrt
echo -e "$(nproc) thread compile"
# make -j$(nproc) || make -j1 V=s
make tools/compile -j$(nproc) || make tools/compile -j72
make toolchain/compile -j$(nproc) || make toolchain/compile -j72
make target/compile -j$(nproc) || make target/compile -j72 IGNORE_ERRORS=1
make diffconfig
make package/compile -j$(nproc) IGNORE_ERRORS=1 || make package/compile -j72 IGNORE_ERRORS=1
make package/index
bash bakkmod.sh
echo "status=success" >> $GITHUB_OUTPUT
- name: Generate Firmware
id: compile
if: steps.compileopenwrt.outputs.status == 'success'
run: |
df -h
cd openwrt
rm -rf ./dl
make package/install -j$(nproc) || make package/install -j1 V=s
make target/install -j$(nproc) || make target/install -j1 V=s
make json_overview_image_info
make checksum
bash buildmd5.sh
echo "status=success" >> $GITHUB_OUTPUT
- name: Check space usage
if: (!cancelled())
run: df -hT
- name: Organize files
id: organize
if: env.UPLOAD_FIRMWARE == 'true' && steps.compile.outputs.status == 'success'
run: |
cd openwrt/bin/targets/*/*
rm -rf packages
df -h
echo "FIRMWARE=$PWD" >> $GITHUB_ENV
echo "status=success" >> $GITHUB_OUTPUT
- name: Generate release tag
id: tag
if: env.UPLOAD_RELEASE == 'true' && steps.compile.outputs.status == 'success'
run: |
echo "release_tag=$(cat openwrt/package/base-files/files/etc/ezopenwrt_version | cut -d _ -f 1)" >> $GITHUB_OUTPUT
echo "TAG=$(cat openwrt/package/base-files/files/etc/ezopenwrt_version | cut -d _ -f 1)" >>$GITHUB_ENV
echo -e "\n* The stable source code has been updated." >> release.txt
sed -i '1i ## Firmware Update Log' release.txt
touch release.txt
echo "status=success" >> $GITHUB_OUTPUT
- name: Upload firmware directory
uses: actions/upload-artifact@main
if: steps.organize.outputs.status == 'success' && env.UPLOAD_FIRMWARE == 'true'
with:
name: ${{ env.TAG }}-EzOpWrt-${{env.TARGET_DEVICE}}-${{env.REPO_BRANCH}}-Firmware
path: ${{ env.FIRMWARE }}
- name: Upload IPK directory
uses: actions/upload-artifact@main
if: env.UPLOAD_IPK_DIR == 'true' && steps.organize.outputs.status == 'success'
with:
name: ${{ env.TAG }}-EzOpWrt-${{env.TARGET_DEVICE}}-${{env.REPO_BRANCH}}-ipk
path: ./openwrt/bin/packages/
- name: Upload bin directory
uses: actions/upload-artifact@main
if: env.UPLOAD_BIN_DIR == 'true' && steps.organize.outputs.status == 'success'
with:
name: ${{ env.TAG }}-EzOpWrt-${{env.TARGET_DEVICE}}-${{env.REPO_BRANCH}}-bin
path: ./openwrt/bin/
- name: Upload firmware to release
uses: softprops/action-gh-release@v2
if: steps.tag.outputs.status == 'success' && !cancelled()
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.tag.outputs.release_tag }}
body_path: release.txt
files: ${{ env.FIRMWARE }}/*
- name: Delete workflow runs
uses: Mattraks/delete-workflow-runs@v2
with:
retain_days: 1
keep_minimum_runs: 5
- name: Remove old Releases
uses: dev-drprasad/delete-older-releases@v0.3.4
with:
keep_latest: 10
keep_min_download_counts: 1 # Optional parameters
delete_tags: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}