forked from stupidloud/nanopi-openwrt
-
Notifications
You must be signed in to change notification settings - Fork 0
154 lines (134 loc) · 5.87 KB
/
lo-test.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
name: build
on:
repository_dispatch:
workflow_dispatch:
inputs:
device:
description: 'select device to build'
default: 'r2s'
required: false
jobs:
build:
name: ${{ github.event.client_payload.device }}
runs-on: ubuntu-latest
if: github.event.repository.owner.id == github.event.sender.id
steps:
- name: Space cleanup
env:
DEBIAN_FRONTEND: noninteractive
run: |
sudo rm -rf /usr/share/dotnet & #/usr/local/lib/android/sdk
sudo -E apt update
sudo -E apt -y install secure-delete zstd build-essential asciidoc binutils bzip2 gawk gettext git libncurses5-dev libz-dev patch unzip zlib1g-dev lib32gcc1 libc6-dev-i386 subversion flex uglifyjs git-core gcc-multilib g++-multilib p7zip p7zip-full msmtp libssl-dev texinfo libreadline-dev libglib2.0-dev xmlto qemu-utils upx libelf-dev autoconf automake libtool autopoint ccache curl wget vim nano python python3 python-pip python3-pip python-ply python3-ply haveged lrzsz device-tree-compiler scons antlr3 gperf intltool rsync swig
sudo -E apt -y autoremove --purge
sudo -E apt clean
df -h
- uses: actions/checkout@v2
with:
fetch-depth: 1
- name: Checkout
run: |
for i in {0..5}
do
curl -s -L --fail https://github.com/${{ github.repository }}/releases/download/cache/lede.${{ github.event.client_payload.device }}.img.zst.0$i || break
done | zstdmt -d -o lede.img || (truncate -s 25g lede.img && mkfs.xfs lede.img)
LOOP_DEVICE=$(losetup -f) && echo $LOOP_DEVICE > LOOP_DEVICE
sudo losetup -P --direct-io $LOOP_DEVICE lede.img
mkdir lede && sudo mount $LOOP_DEVICE lede && sudo chown $USER:$USER lede
[ ! -e lede/.git ] && (cd lede && git init && git remote add -t openwrt-18.06-k5.4 -f origin https://github.com/immortalwrt/immortalwrt && git checkout openwrt-18.06-k5.4)
cd lede && git config --local user.email "[email protected]" && git config --local user.name "GitHub Action" && git pull -X theirs
- name: Update feeds and packages
run: |
cd lede/
git clone --depth=1 https://github.com/destan19/OpenAppFilter.git && mv OpenAppFilter package/
git clone --depth=1 -b 18.06 https://github.com/jerrykuku/luci-theme-argon.git && rm -rf package/lean/luci-theme-argon && mv luci-theme-argon package/lean/
./scripts/feeds update -a
./scripts/feeds install -a
- name: Custom configure file
run: |
cd lede
rm -f .config*
cp ../${{ github.event.client_payload.device }}.config.seed .config
sed -i 's/^[ \t]*//g' .config
echo '
# CONFIG_v2ray-plugin_INCLUDE_GOPROXY is not set
# CONFIG_XRAY_CORE_COMPRESS_GOPROXY is not set
# CONFIG_UnblockNeteaseMusicGo_INCLUDE_GOPROXY is not set
' >> .config
make defconfig && cat .config
- name: Compile firmware
run: |
cd lede
while true; do make download -j8 && break || true; done
make -j$(($(nproc) + 1)) -s || (make clean && make -j1 V=sc)
echo "======================="
echo "Space usage:"
echo "======================="
df -h
echo "======================="
du -h --max-depth=1 ./ --exclude=build_dir --exclude=bin
du -h --max-depth=1 ./build_dir
du -h --max-depth=1 ./bin
- name: Prepare artifact
run: |
mkdir -p ./artifact/firmware
mkdir -p ./artifact/package
mkdir -p ./artifact/buildinfo
cd lede
rm -rf $(find ./bin/targets/ -type d -name "packages")
cp -rf $(find ./bin/targets/ -type f) ../artifact/firmware/
cp -rf $(find ./bin/packages/ -type f -name "*.ipk") ../artifact/package/
cp -rf $(find ./bin/targets/ -type f -name "*.buildinfo" -o -name "*.manifest") ../artifact/buildinfo/
rm -rf bin/ tmp/
cd ..
rm -f *zst*
sudo umount lede
LOOP_DEVICE=$(cat LOOP_DEVICE)
sudo losetup -d $LOOP_DEVICE
zstdmt -c -1 lede.img | split -d -b 2000m - lede.${{ github.event.client_payload.device }}.img.zst.
ls -l *zst*
- name: Deliver buildinfo
uses: actions/upload-artifact@v2
with:
name: OpenWrt_buildinfo
path: ./artifact/buildinfo/
- name: Deliver package
uses: actions/upload-artifact@v2
with:
name: OpenWrt_package
path: ./artifact/package/
- name: Deliver firmware
uses: actions/upload-artifact@v2
with:
name: OpenWrt_firmware
path: ./artifact/firmware/
- name: Upload cache asset
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ./lede.${{ github.event.client_payload.device }}*zst*
tag: cache
file_glob: true
overwrite: true
prerelease: true
- name: Upload release asset
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ./artifact/firmware/*img*
tag: ${{ github.event.client_payload.device }}-$(date +%Y-%m-%d)
file_glob: true
overwrite: true
- name: Debug via tmate
uses: P3TERX/ssh2actions@main
if: ${{ failure() }}
env:
TELEGRAM_BOT_TOKEN: ${{ secrets.TELEGRAM_BOT_TOKEN }}
TELEGRAM_CHAT_ID: ${{ secrets.TELEGRAM_CHAT_ID }}
- name: Send tg notification
uses: appleboy/telegram-action@master
#if: always()
with:
to: ${{ secrets.TELEGRAM_TO }}
token: ${{ secrets.TELEGRAM_TOKEN }}
args: The ${{ github.event.client_payload.device }} build ran completed at ${{ job.status }}.