generated from carrot93/Actions-Lean-OpenWrt
-
Notifications
You must be signed in to change notification settings - Fork 6
278 lines (252 loc) · 11.2 KB
/
build-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
272
273
274
275
276
277
278
#=================================================
# https://github.com/Lancenas/Actions-Lean-OpenWrt
# Description: Build OpenWrt using GitHub Actions
# Lisence: MIT
# Author: P3TERX
# Blog: https://P3TERX.com
#=================================================
name: Build OpenWrt
on:
repository_dispatch:
workflow_dispatch:
inputs:
ssh:
description: 'SSH connection to Actions'
required: false
default: 'false'
release:
types: published
push:
branches:
- master
paths:
- 'wndr4300.config'
# schedule:
# - cron: 0 8 * * 5
watch:
types: started
env:
# REPO_URL: https://github.com/coolsnowwolf/lede
# REPO_BRANCH: master
# REPO_URL: https://github.com/coolsnowwolf/openwrt
# REPO_BRANCH: lede-17.01
REPO_URL: https://github.com/openwrt/openwrt
REPO_BRANCH: master
# REPO_URL: https://github.com/lede-project/source
# REPO_BRANCH: openwrt-19.07
# REPO_URL: https://github.com/carrot93/openwrt
# REPO_BRANCH: master
FEEDS_CONF: feeds.conf.default
CONFIG_FILE: wndr4300.config
DIY_P1_SH: diy-part1.sh
DIY_P2_SH: diy-part2.sh
SSH_ACTIONS: false
UPLOAD_BIN_DIR: true
UPLOAD_FIRMWARE: true
UPLOAD_CATTRANSFER: true
UPLOAD_ANONTRANSFER: true
UPLOAD_RELEASE: true
TZ: Asia/Shanghai
jobs:
build:
runs-on: ubuntu-latest
if: github.event.repository.owner.id == github.event.sender.id
steps:
- name: Checkout
uses: actions/checkout@v3
- name: cli env
uses: volta-cli/action@v4
- name: wait 60s
uses: GuillaumeFalourd/wait-sleep-action@v1
with:
time: '60'
- name: Node LTS versions
uses: msimerson/[email protected]
with:
node-version: 16
- name: setup node version
uses: actions/setup-node@v1
with:
node-version: 16
# - name: Set the value
# id: step_one
# run: |
# # echo "{environment_variable_name}={value}" >> $GITHUB_ENV
# # echo "{name}={value}" >> $GITHUB_OUTPUT
# echo '::set-output name=action_echo::disabled'
- 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 build-essential asciidoc binutils bzip2 gawk gettext git libncurses5-dev libz-dev patch unzip zlib1g-dev lib32gcc1 libc6-dev-i386 subversion flex uglifyjs gcc-multilib g++-multilib p7zip p7zip-full msmtp libssl-dev texinfo libglib2.0-dev xmlto qemu-utils upx libelf-dev autoconf automake libtool autopoint device-tree-compiler antlr3 gperf
sudo -E apt-get -qq install ack antlr3 asciidoc autoconf automake autopoint binutils bison build-essential bzip2 ccache cmake cpio curl device-tree-compiler fastjar flex gawk gettext gcc-multilib g++-multilib git gperf haveged help2man intltool libc6-dev-i386 libelf-dev libglib2.0-dev libgmp3-dev libltdl-dev libmpc-dev libmpfr-dev libncurses5-dev libncursesw5-dev libreadline-dev libssl-dev libtool lrzsz mkisofs msmtp nano ninja-build p7zip p7zip-full patch pkgconf python2.7 python3 python3-pip libpython3-dev qemu-utils rsync scons squashfs-tools subversion swig texinfo uglifyjs upx upx-ucl unzip vim wget xmlto xxd zlib1g-dev
sudo -E apt-get -qq autoremove --purge
sudo -E apt-get -qq clean
sudo timedatectl set-timezone "$TZ"
- name: Clone source code
run: |
git clone --depth 1 $REPO_URL -b $REPO_BRANCH openwrt
- name: Load custom feeds
run: |
[ -e $FEEDS_CONF ] && mv $FEEDS_CONF openwrt/feeds.conf.default
chmod +x $DIY_P1_SH
cd openwrt
# custom package source
# cat >> feeds.conf.default <<EOF
# src-git packages_1 https://github.com/openwrt/packages
# src-git luci_1 https://github.com/openwrt/luci
# EOF
# git clone https://github.com/CPqD/openflow-openwrt.git package/openflow-openwrt
# git clone https://github.com/sunkai2012sky/mwan3-zh-cn.git package/luci-i18n-mwan3
# git clone https://github.com/chenhw2/openwrt-dnsmasq-extra.git package/openwrt-dnsmasq-extra
# git clone https://github.com/honwen/openwrt-shadowsocks-rust.git package/openwrt-shadowsocks-rust
# git clone https://github.com/honwen/luci-app-shadowsocks-rust.git package/luci-app-shadowsocks-rust
# pushd package/luci-app-shadowsocks-rust/tools/po2lmo
# make && sudo make install
# popd
# git clone --branch lede https://github.com/Romaluo/luci-app-smartdns.git package/luci-app-smartdns
# git clone https://github.com/pymumu/smartdns.git package/smartdns
# git clone https://github.com/kankankankankankan/luci-app-adguardhome package/luci-app-adguardhome
# git clone https://github.com/AdguardTeam/AdGuardHome package/AdGuardHome
# git clone https://github.com/AlexZhuo/luci-app-pdnsd.git package/luci-app-pdnsd
# git clone https://github.com/mengskysama/openwrt-pdnsd.git package/openwrt-pdnsd
git clone https://github.com/chandelures/openwrt-clash clash
git clone https://github.com/chandelures/luci-app-simple-clash luci-app-simple-clash
../$DIY_P1_SH
# rm -rf feeds/luci/applications/luci-app-turboacc
# git clone https://github.com/AutoCONFIG/luci-app-turboacc.git feeds/luci/applications/luci-app-turboacc
- name: Update feeds
run: cd openwrt && ./scripts/feeds update -a
- name: Install feeds
run: cd openwrt && ./scripts/feeds install -a
- name: Load custom configuration
run: |
[ -e files ] && mv files openwrt/files
[ -e $CONFIG_FILE ] && mv -f $CONFIG_FILE openwrt/.config
chmod +x $DIY_P2_SH
cd openwrt
../$DIY_P2_SH
- name: SSH connection to Actions
uses: P3TERX/[email protected]
if: env.SSH_ACTIONS == 'true' || contains(github.event.action, 'ssh')
- name: Download package
id: package
run: |
cd openwrt
# sed -i 's/KERNEL_PATCHVER:=5.10/KERNEL_PATCHVER:=6.1/g' ./target/linux/ath79/Makefile
# sed -i 's/KERNEL_PATCHVER:=5.10/KERNEL_PATCHVER:=5.19/g' ./target/linux/ath79/Makefile
make clean
# make savedefconfig
# ./scripts/diffconfig.sh > defconfig
# cat defconfig >> .config
sed -i 's/^[ \t]*//g' ./.config
# cp .config config.uniq
# sort .config.uniq | uniq > .config
# cat >> .config <<EOF
# CONFIG_PACKAGE_pdnsd=y
# EOF
# CONFIG_PACKAGE_luci-app-mwan3=y
# CONFIG_PACKAGE_mwan3=y
# CONFIG_PACKAGE_luci-app-p910nd=y
# CONFIG_PACKAGE_luci-i18n-p910nd-zh-cn=y
# CONFIG_PACKAGE_p910nd=y
# CONFIG_PACKAGE_luci-app-ssr-plus_INCLUDE_V2ray_Plugin=y
# CONFIG_BUSYBOX_DEFAULT_KLOGD=y
# CONFIG_PACKAGE_luci-app-mwan3helper=y
# CONFIG_BUSYBOX_DEFAULT_FEATURE_KLOGD_KLOGCTL=y
# CONFIG_BUSYBOX_DEFAULT_LOGGER=y
# CONFIG_PACKAGE_shadowsocks-rust-sslocal=y
# CONFIG_PACKAGE_shadowsocks-rust-ssserver=y
# CONFIG_PACKAGE_luci-app-ssr-plus_INCLUDE_Shadowsocks_Rust_Client=y
# CONFIG_PACKAGE_luci-app-ssr-plus_INCLUDE_Shadowsocks_Rust_Server=y
# CONFIG_PACKAGE_v2ray-plugin=y
# CONFIG_PACKAGE_v2ray-core=y
# CONFIG_PACKAGE_openflow=y
# CONFIG_PACKAGE_luci-i18n-mwan3-zh-cn=y
make defconfig
./scripts/diffconfig.sh > seed.config
cp /usr/bin/upx staging_dir/host/bin/
cp /usr/bin/upx-ucl staging_dir/host/bin/
make download -j8
# V=s
find dl -size -1024c -exec ls -l {} \;
find dl -size -1024c -exec rm -f {} \;
- name: Compile the firmware
id: compile
run: |
cd openwrt
echo -e "$(nproc) thread compile"
# make -j$(nproc) V=s || make -j1 V=s || make -j1 V=sc
make -j$(nproc) || make -j1 || make -j1 V=sc
# PKG_HASH=skip
echo "status=success" >>$GITHUB_OUTPUT
- name: Upload bin directory
uses: actions/upload-artifact@main
if: steps.compile.outputs.status == 'success' && env.UPLOAD_BIN_DIR == 'true'
with:
name: OpenWrt_bin_${{ steps.compile.outputs.DEVICE_NAME }}_${{ steps.compile.outputs.FILE_DATE }}
path: openwrt/bin
- name: Organize files
id: organize
if: env.UPLOAD_FIRMWARE == 'true' && !cancelled()
run: |
cd openwrt/bin/targets/*/*
rm -rf packages
echo "FIRMWARE=$PWD" >>$GITHUB_OUTPUT
echo "status=success" >>$GITHUB_OUTPUT
- name: Upload firmware directory
uses: actions/upload-artifact@main
if: steps.organize.outputs.status == 'success' && !cancelled()
with:
name: OpenWrt_firmware_${{ steps.compile.outputs.DEVICE_NAME }}_${{ steps.compile.outputs.FILE_DATE }}
path: ${{ steps.organize.outputs.FIRMWARE }}
- name: Upload firmware to cattransfer
id: cattransfer
if: steps.organize.outputs.status == 'success' && env.UPLOAD_CATTRANSFER == 'true' && !cancelled()
run: |
curl -fsSL git.io/file-transfer | bash -s beta
./transfer cat --block 2621440 -s -p 64 --no-progress ${{ steps.organize.outputs.FIRMWARE }} 2>&1 | tee cattransfer.log
echo "::warning file=cattransfer.com::$(cat cattransfer.log | grep https)"
echo "url=$(cat cattransfer.log | grep https | cut -f3 -d" ")" >>$GITHUB_OUTPUT
- name: Upload firmware to anonTransfer
id: anontransfer
if: steps.organize.outputs.status == 'success' && env.UPLOAD_ANONTRANSFER == 'true' && !cancelled()
run: |
curl -fsSL git.io/file-transfer | bash -s beta
./transfer anon -s -p 16 --no-progress ${{ steps.organize.outputs.FIRMWARE }} 2>&1 | tee anontransfer.log
echo "::warning file=anontransfer.com::$(cat anontransfer.log | grep https)"
echo "url=$(cat anontransfer.log | grep https | cut -f3 -d" ")" >>$GITHUB_OUTPUT
- name: Generate release tag
id: tag
if: env.UPLOAD_RELEASE == 'true' && !cancelled()
run: |
# echo "name=release_tag::$(date +"%Y.%m.%d-%H%M")" >>$GITHUB_OUTPUT
echo "::set-output name=release_tag::$(date +"%Y.%m.%d-%H%M")"
touch release.txt
[ $UPLOAD_CATTRANSFER = true ] && echo "🔗 [Cattransfer](${{ steps.cattransfer.outputs.url }})" >> release.txt
[ $UPLOAD_ANONTRANSFER = true ] && echo "🔗 [AnonTransfer](${{ steps.anontransfer.outputs.url }})" >> release.txt
echo "status=success" >>$GITHUB_OUTPUT
- name: Upload firmware to release
uses: softprops/[email protected]
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: GitRML/delete-workflow-runs@main
with:
retain_days: 1
keep_minimum_runs: 3
- name: Remove old Releases
uses: dev-drprasad/[email protected]
if: env.UPLOAD_RELEASE == 'true' && !cancelled()
with:
keep_latest: 3
delete_tags: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}