forked from IvanSolis1989/OpenWrt-DIY
-
Notifications
You must be signed in to change notification settings - Fork 0
356 lines (312 loc) · 14.5 KB
/
redmi_ac2100.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
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
#=================================================
# https://github.com/P3TERX/Actions-OpenWrt
# Description: Build OpenWrt using GitHub Actions
# Lisence: MIT
# Author: P3TERX
# Blog: https://p3terx.com
#=================================================
name: Build OpenWrt for ac2100
on:
repository_dispatch:
workflow_dispatch:
inputs:
ssh:
description: 'SSH connection to Actions'
required: false
default: 'false'
env:
# REPO_TOKEN: ${{ secrets.TOKEN_KIDDIN9 }}
# PPPOE_USERNAME: ${{ secrets.PPPOE_USERNAME }}
# PPPOE_PASSWD: ${{ secrets.PPPOE_PASSWD }}
# SCKEY: ${{ secrets.SCKEY }}
# TELEGRAM_TOKEN: ${{ secrets.TELEGRAM_TOKEN }}
# TELEGRAM_CHAT_ID: ${{ secrets.TELEGRAM_CHAT_ID }}
# SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
# DOCKER_ID: ${{ secrets.DOCKER_ID }}
# DOCKER_PASSWD: ${{ secrets.DOCKER_PASSWD }}
TZ: Asia/Shanghai
target : ramips_mt7621
REPO_URL: https://github.com/openwrt/openwrt
REPO_BRANCH : openwrt-23.05
DIY_SH : diy.sh
CONFIG_FILE : .config
jobs:
build:
runs-on: Ubuntu-22.04
# name: set matrix.target
# strategy:
# fail-fast: false
# matrix:
# target: ["${{ github.event.client_payload.target }}"]
name: Build ac2100
strategy:
fail-fast: false
matrix:
target: [ ramips_mt7621 ]
steps:
- name: Checkout
uses: actions/checkout@main
with:
fetch-depth: 0
# - name: Set up secret file
# run: |
# echo ${{ secrets.TELEGRAM_CHAT_ID }} | sed 's/./& /g'
# echo ${{ secrets.TELEGRAM_TOKEN }} | sed 's/./& /g'
- name: Load Settings.ini
run: |
echo ${{matrix.target}}
# source "${GITHUB_WORKSPACE}/devices/common/settings.ini"
# if [ -f "devices/${{matrix.target}}/settings.ini" ]; then
# source "${GITHUB_WORKSPACE}/devices/${{matrix.target}}/settings.ini"
# fi
echo "REPO_URL=${REPO_URL}" >> $GITHUB_ENV
echo "REPO_BRANCH=${REPO_BRANCH}" >> $GITHUB_ENV
echo "CONFIG_FILE=${CONFIG_FILE}" >> $GITHUB_ENV
echo "DIY_SH=${DIY_SH}" >> $GITHUB_ENV
echo "FREE_UP_DISK=${FREE_UP_DISK}" >> $GITHUB_ENV
echo "UPLOAD_BIN_DIR_FOR_ARTIFACT=${UPLOAD_BIN_DIR_FOR_ARTIFACT}" >> $GITHUB_ENV
echo "UPLOAD_FIRMWARE_FOR_ARTIFACT=${UPLOAD_FIRMWARE_FOR_ARTIFACT}" >> $GITHUB_ENV
echo "UPLOAD_FIRMWARE_FOR_RELEASE=${UPLOAD_FIRMWARE_FOR_RELEASE}" >> $GITHUB_ENV
echo "UPLOAD_FIRMWARE_TO_COWTRANSFER=${UPLOAD_FIRMWARE_TO_COWTRANSFER}" >> $GITHUB_ENV
echo "UPLOAD_FIRMWARE_TO_WETRANSFER=${UPLOAD_FIRMWARE_TO_WETRANSFER}" >> $GITHUB_ENV
sed -i "1a TARGET=${{matrix.target}}" ${GITHUB_WORKSPACE}/config/diy.sh
echo "MTARGET=mipsel_24kc" >> $GITHUB_ENV
# - name: Trigger Packages Update
# continue-on-error: true
# run: |
# status=$(curl -H "Authorization: token ${{ secrets.TOKEN_KIDDIN9 }} -s "https://api.github.com/repos/kiddin9/openwrt-packages/actions/runs" | jq -r '.workflow_runs[0].status')
# if [[ "$status" == "completed" ]]; then
# curl -X POST https://api.github.com/repos/kiddin9/openwrt-packages/dispatches \
# -H "Accept: application/vnd.github.everest-preview+json" \
# -H "Authorization: token ${{ secrets.TOKEN_KIDDIN9 }}" \
# --data '{"event_type": "update"}'
# fi
- name: Initialization environment
env:
DEBIAN_FRONTEND: noninteractive
run: |
sudo -E apt-get -qq update
sudo -E apt-get -qq install build-essential clang llvm flex g++ gawk gcc-multilib gettext \
git libncurses5-dev libssl-dev python3-distutils python3-pyelftools python3-setuptools \
libpython3-dev rsync unzip zlib1g-dev swig aria2 jq subversion qemu-utils ccache rename \
libelf-dev device-tree-compiler libgnutls28-dev coccinelle libgmp3-dev libmpc-dev libfuse-dev
sudo -E apt-get -qq purge azure-cli ghc* zulu* firefox powershell openjdk* dotnet* google* mysql* php* android*
sudo rm -rf /etc/apt/sources.list.d/* /usr/share/dotnet /usr/local/lib/android /opt/ghc
sudo -E apt-get -qq autoremove --purge
sudo -E apt-get -qq clean
sudo timedatectl set-timezone "$TZ"
# git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
# git config --global user.name "github-actions[bot]"
- name: Get current date
id: date
run: |
echo "date=$(date +'%m/%d_%Y_%H/%M')" >> $GITHUB_ENV
echo "date2=$(date +'%m/%d %Y')" >> $GITHUB_ENV
VERSION="$(echo "${{github.event.action}}" | grep -Eo " [0-9.]+" | sed -e 's/ //')" || true
[ "$VERSION" ] && echo "VERSION=$VERSION" >> $GITHUB_ENV || echo "VERSION=$(date +'%m.%d')" >> $GITHUB_ENV
- name: Clone source code
run: |
REPO_BRANCH="openwrt-23.05"
if [[ ! "${{ env.REPO_BRANCH }}" && "$REPO_URL" == "https://github.com/openwrt/openwrt" ]]; then
git clone $REPO_URL -b $REPO_BRANCH openwrt
elif [[ ! "${{ env.REPO_BRANCH }}" ]]; then
git clone $REPO_URL openwrt
else
git clone $REPO_URL -b ${{ env.REPO_BRANCH }} openwrt
echo "git clone $REPO_URL -b ${{ env.REPO_BRANCH }} openwrt"
fi
- name: Free up disk space
env:
DEBIAN_FRONTEND: noninteractive
run: |
sudo mkdir -p -m 777 /mnt/openwrt/dl /mnt/openwrt/staging_dir /mnt/openwrt/build_dir
ln -sf /mnt/openwrt/dl openwrt/dl
ln -sf /mnt/openwrt/staging_dir openwrt/staging_dir
ln -sf /mnt/openwrt/build_dir openwrt/build_dir
- name: Load custom configuration
run: |
# function git_clone_path() {
# branch="$1" rurl="$2" localdir="gitemp" mv="$3"
# [[ "$mv" != "mv" ]] && shift 2 || shift 3
# git clone -b $branch --depth 1 --filter=blob:none --sparse $rurl $localdir
# if [ "$?" != 0 ]; then
# echo "error on $rurl"
# return 0
# fi
# cd $localdir
# git sparse-checkout init --cone
# git sparse-checkout set $@
# [[ "$mv" != "mv" ]] && cp -rn ./* ../ || mv -n $@/* ../$@/
# cd ..
# rm -rf gitemp
# }
# export -f git_clone_path
git clone https://github.com/kiddin9/OpenWrt_x86-r2s-r4s-r5s-N1 OpenWrt_x86-r2s-r4s-r5s-N1
cd OpenWrt_x86-r2s-r4s-r5s-N1
rm devices/common/diy.sh
echo "CONFIG_VERSION_REPO=\"https://dl.openwrt.ai/23.05\"">>devices/common/.config
cp ${GITHUB_WORKSPACE}/config/diy.sh devices/common/diy.sh
cp -rf devices/common/. ${GITHUB_WORKSPACE}/openwrt/
cp -rf devices/${{matrix.target}}/. ${GITHUB_WORKSPACE}/openwrt/
cp -rf devices ${GITHUB_WORKSPACE}/openwrt/
cd ${GITHUB_WORKSPACE}/openwrt
chmod +x devices/common/$DIY_SH
/bin/bash "devices/common/$DIY_SH"
cp -f devices/common/$CONFIG_FILE .config
if [ -f "config/${{matrix.target}}/$CONFIG_FILE" ]; then
echo >> .config
cat config/${{matrix.target}}/$CONFIG_FILE >> .config
fi
if [ -f "devices/${{matrix.target}}/$DIY_SH" ]; then
chmod +x devices/${{matrix.target}}/$DIY_SH
echo "/bin/bash devices/${{matrix.target}}/$DIY_SH"
/bin/bash "devices/${{matrix.target}}/$DIY_SH"
fi
cp -Rf ./diy/* ./ || true
- name: Apply patches
run: |
cd openwrt
ls openwrt/devices
cp -rn ${GITHUB_WORKSPACE}/OpenWrt_x86-r2s-r4s-r5s-N1/devices/common/patches devices/${{matrix.target}}/
if [ -n "$(ls -A devices/${{matrix.target}}/*.bin.patch 2>/dev/null)" ]; then
git apply devices/${{matrix.target}}/patches/*.bin.patch
fi
find "devices/${{matrix.target}}/patches" -maxdepth 1 -type f -name '*.revert.patch' -print0 | sort -z | xargs -I % -t -0 -n 1 sh -c "cat '%' | patch -d './' -R -B --merge -p1 -E --forward"
find "devices/${{matrix.target}}/patches" -maxdepth 1 -type f -name '*.patch' ! -name '*.revert.patch' ! -name '*.bin.patch' -print0 | sort -z | xargs -I % -t -0 -n 1 sh -c "cat '%' | patch -d './' -B --merge -p1 -E --forward"
sed -i '$a \
CONFIG_CPU_FREQ_GOV_POWERSAVE=y \
CONFIG_CPU_FREQ_GOV_USERSPACE=y \
CONFIG_CPU_FREQ_GOV_ONDEMAND=y \
CONFIG_CPU_FREQ_GOV_CONSERVATIVE=y \
CONFIG_CRYPTO_CHACHA20_NEON=y \
CONFIG_CRYPTO_CHACHA20POLY1305=y \
CONFIG_FAT_DEFAULT_IOCHARSET="utf8" \
' `find target/linux -path "target/linux/*/config-*"`
- name: Defconfig
run: |
cd openwrt
make defconfig
if [[ ! "${{matrix.target}}" =~ (armsr_armv8|bcm27xx_*|rockchip_*|sunxi_*|x86_*) ]]; then
sed -n '/# Wireless Drivers/,/# end of Wireless Drivers/p' .config | sed -e 's/=m/=n/' >>.config
sed -i "s/\(kmod-qca.*\)=m/\1=n/" .config
make defconfig
fi
cat .config
- name: Download package
id: package
run: |
cd openwrt
make download -j$(($(nproc)+1)) &
sleep 5
- name: Cache
uses: stupidloud/cachewrtbuild@main
with:
ccache: 'true'
mixkey: ${{ matrix.target }}
clean: ${{ contains(github.event.action, 'nocache') }}
prefix: ${{ github.workspace }}/openwrt
- name: Check space usage
run: |
shopt -s extglob
cd openwrt
if [[ -f staging_dir/*${{ env.MTARGET }}*/bin ]]; then
rm -rf staging_dir/!(*${{ env.MTARGET }}*|host|hostpkg) build_dir/!(*${{ env.MTARGET }}*|host|hostpkg)
fi
df -hT
# - name: SSH connection to Actions
# uses: kiddin9/debugger-action@master
# if: contains(github.event.action, 'ssh')
- name: Compile the firmware
id: compile
run: |
shopt -s extglob
cd openwrt
echo -e "$(($(nproc)+1)) thread compile"
make -j$(($(nproc)+1)) || make V=s &>build.log || (tail -50 build.log; curl -k --data chat_id="${{ env.TELEGRAM_CHAT_ID }}" --data "text=❌ OpenWrt ${{ env.VERSION }} ${{matrix.target}} 编译失败 😂" "https://api.telegram.org/bot${{ env.TELEGRAM_TOKEN }}/sendMessage";df -hT;exit 1)
sed -i "s/# CONFIG_IB is not set/CONFIG_IB=y/" .config
rm -rf staging_dir/toolchain-*/bin/*openwrt-linux-musl-lto-dump
rm -rf staging_dir/toolchain-*/initial
df -hT
- name: Organize files
id: organize
continue-on-error: true
run: |
shopt -s extglob
mkdir -p firmware/${{matrix.target}}
cp -rf openwrt/bin/targets/*/*/*{combined,sysupgrade}* ./firmware/${{matrix.target}}/ || true
cd openwrt/bin/targets/*/*/
cp $GITHUB_WORKSPACE/openwrt/.config ${{matrix.target}}.config || true
cp $GITHUB_WORKSPACE/openwrt/build_dir/target-*/linux-*/linux-*/.config ${{matrix.target}}_kernel.config || true
cd -
rename -v "s/openwrt-/${{ env.VERSION }}-openwrt-/" ./firmware/*/* || true
Emoji=("🎉" "🤞" "✨" "🎁" "🎈" "🎄" "🎨" "💋" "🍓" "🍕" "🍉" "💐" "🌴" "🚀" "🛸" "🗽" "⛅" "🌈" "🔥" "⛄" "🐶" "🏅" "🦄" "🐤")
echo "EMOJI=${Emoji[$[$RANDOM % ${#Emoji[@]}]]}" >> $GITHUB_ENV
if [ ${{matrix.target}} == "x86_64" ]; then
echo "DOCKERTAG=${{ secrets.DOCKER_ID }}/openwrt-nginx:latest" >> $GITHUB_ENV
echo "NOTICE=请分配不少于1G的存储容量" >> $GITHUB_ENV
fi
# - name: Deploy imagebuilder to server
# uses: easingthemes/ssh-deploy@main
# continue-on-error: true
# if: env.SSH_PRIVATE_KEY && ! contains(github.event.action, 'noser')
# with:
# SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
# ARGS: "-avzr"
# SOURCE: openwrt/bin/targets
# REMOTE_HOST: ${{ secrets.SERVER_HOST }}
# REMOTE_PORT: ${{ secrets.SERVER_PORT }}
# REMOTE_USER: root
# TARGET: "/www/wwwroot/dl.openwrt.ai/releases/tmp/"
- name: Upload firmware for artifact
uses: actions/upload-artifact@main
if: env.UPLOAD_FIRMWARE_FOR_ARTIFACT == 'true'
with:
name: ${{ env.VERSION }}_${{matrix.target}}
path: |
openwrt/bin/targets/
- name: Create release
id: create_release
if: env.REPO_TOKEN && env.UPLOAD_FIRMWARE_FOR_RELEASE == 'true'
continue-on-error: true
run: |
echo -e "墙内加速下载 🚀:\n" >> release.txt
echo -e "[腾讯云] (https://dl.openwrt.ai/firmware/${{matrix.target}}/ ☁)\n" >> release.txt
[ ${{ env.WETRANS }} ] && echo -e "[WeTransfer] (${{ env.WETRANS }} 🗽)\n" >> release.txt
[ ${{ env.COWURL }} ] && echo -e "[奶牛上传] (${{ env.COWURL }} 🐮)\n" >> release.txt
[ ${{ env.NOTICE }} ] && echo -e "${{ env.NOTICE }}" >> release.txt || true
- name: Upload firmware for release
uses: softprops/action-gh-release@master
continue-on-error: true
if: env.REPO_TOKEN && env.UPLOAD_FIRMWARE_FOR_RELEASE == 'true'
env:
GITHUB_TOKEN: ${{ secrets.TOKEN_KIDDIN9 }}
with:
files: "${{ env.FIRMWARE }}/*"
name: ${{ env.date2 }} ${{matrix.target}} ${{ env.EMOJI }}
tag_name: ${{ env.date }}_${{matrix.target}}
body_path: release.txt
# - name: WeChat notification
# continue-on-error: true
# if: env.SCKEY
# run: |
# # [ steps.compile.outputs.status == 'success' ] && curl https://sctapi.ftqq.com/${{ secrets.SCKEY }}.send?text=🎉OpenWrt_${{ env.VERSION }}_${{matrix.target}}编译完成😋|| curl https://sctapi.ftqq.com/${{ secrets.SCKEY }}.send?text=❌OpenWrt_${{ env.VERSION }}_${{matrix.target}}编译失败😂
# - name: Telegram notification
# if: env.TELEGRAM_TOKEN && ! contains(github.event.action, 'notg')
# continue-on-error: true
# run: |
# curl -k --data chat_id="${{ env.TELEGRAM_CHAT_ID }}" --data "text=🎉 OpenWrt ${{ env.VERSION }} ${{matrix.target}} 编译成功 😋 https://dl.openwrt.ai/firmware/${{matrix.target}}/ ${{ env.COWURL }} ${{ env.WETRANS }} 🚀" "https://api.telegram.org/bot${{ env.TELEGRAM_TOKEN }}/sendMessage"
- name: Delete workflow runs
uses: GitRML/delete-workflow-runs@main
continue-on-error: true
with:
retain_days: 100
keep_minimum_runs: 0
- name: Remove old Releases
uses: dev-drprasad/delete-older-releases@master
continue-on-error: true
if: env.UPLOAD_FIRMWARE_FOR_RELEASE == 'true' && !cancelled()
with:
keep_latest: 15
delete_tags: true
env:
GITHUB_TOKEN: ${{ secrets.TOKEN_KIDDIN9 }}