-
-
Notifications
You must be signed in to change notification settings - Fork 8
245 lines (220 loc) · 9.1 KB
/
OpenWrt-R7800-Lean.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
#=================================================
# https://github.com/ClayMoreBoy/OpenWrt-Actions-R7800
# Description: Build OpenWrt using GitHub Actions
# Lisence: MIT
# Author: ClayMoreBoy
# Github: https://github.com/ClayMoreBoy
#=================================================
name: OpenWrt-R7800-Lean
on:
# 定时触发
schedule:
- cron: 0 1 * * *
# Release 发布触发
# release:
# types: [published]
# 点赞触发
# watch:
# types: [started]
# 编辑触发
push:
branches:
- master
env:
# 源
REPO_URL: https://github.com/coolsnowwolf/lede
# 分支
REPO_BRANCH: master
# PassWall插件包
EX_PKG: false
# 脚本
DIY_SH: OpenWrt-R7800-Lean.sh
# 开启SSH连接
SSH_ACTIONS: false
# 上传分支
UPLOAD_BRANCH: true
# 分支
BRANCH: R7800-Lean
# Github 用户名
GITHUB_USER_NAME: ClayMoreBoy
# Github 邮箱
GITHUB_USER_EMAIL: ${{ secrets.EMAIL }}
# Github
GITHUB: github.com/OpenWrt-Actions/R7800.git
# 上传固件
UPLOAD_FIRMWARE: true
# 上传到奶牛快传
UPLOAD_COWTRANSFER: true
# 创建+上传发布
CREATE_RELEASE: true
# 编译者
BUILD_USER: ClayMoreBoy
# 微信通知
SEND_WECHAT_MSG: false
jobs:
build:
if: github.event.repository.owner.id == github.event.sender.id
runs-on: ubuntu-latest
steps:
# 校验本地文件
- name: Checkout
uses: actions/checkout@main
# 初始化编译环境
# sudo -E apt-get install -y 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-8 gcc++-8 gcc-8-multilib g++-8-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 ecj fastjar re2c
- name: Initialization environment
env:
DEBIAN_FRONTEND: noninteractive
run: |
docker rmi $(docker images -q)
sudo -E rm -rf /usr/share/dotnet /usr/local/lib/android /opt/ghc
sudo -E apt-get -y purge azure-cli ghc* zulu* hhvm llvm* firefox google* dotnet* powershell openjdk* mysql* php* android* mssql-tools msodbcsql17
sudo -E apt-get update -y
sudo -E apt-get full-upgrade -y
sudo -E apt-get -y install build-essential asciidoc binutils bzip2 gawk gettext git libncurses5-dev libz-dev patch python3 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 swig
sudo -E ln -sf /usr/bin/gcc-8 /usr/bin/gcc
sudo -E ln -sf /usr/bin/g++-8 /usr/bin/g++
sudo -E ln -sf /usr/bin/gcc-ar-8 /usr/bin/gcc-ar
sudo -E ln -sf /usr/bin/gcc-nm-8 /usr/bin/gcc-nm
sudo -E ln -sf /usr/bin/gcc-ranlib-8 /usr/bin/gcc-ranlib
sudo -E apt-get autoremove -y --purge
sudo -E apt-get clean -y
sudo -E rm -rf /usr/share/dotnet /etc/mysql /etc/php
# 克隆源代码 By bobotoy
- name: Clone source code
run: |
git clone --depth 1 $REPO_URL -b $REPO_BRANCH openwrt
cd openwrt
useVersionInfo=$(git show -s --date=short --format="Author: %an<br/>Date: %cd<br/>Commit: %s")
echo "useVersionInfo=$useVersionInfo" >> $GITHUB_ENV
echo "DATE=$(TZ=UTC-8 date "+%Y%m%d")" >> $GITHUB_ENV
echo "RELEASE_DATE=$(TZ=UTC-8 date "+%Y-%m-%d")" >> $GITHUB_ENV
# 增加 PassWall 插件源 By rohu168
- name: Update and install feeds passwall
if: env.EX_PKG == 'true'
run: |
chmod +x ssr-plus_passwall.sh && cp ssr-plus_passwall.sh ./openwrt && cd openwrt && ./ssr-plus_passwall.sh
# 更新源 sed -i 's/\"#src-git\"/\"src-git\"/g' ./feeds.conf.default
- name: Update Feeds
if: env.REPO_URL != 'https://github.com/coolsnowwolf/lede'
working-directory: ./openwrt
run: |
./scripts/feeds clean
./scripts/feeds update -a
# 安装源
- name: Install Feeds
if: env.REPO_URL != 'https://github.com/coolsnowwolf/lede'
working-directory: ./openwrt
run: ./scripts/feeds install -a
# 加载自定义配置文件
- name: Load Custom Configuration
run: |
[ -e files ] && mv files openwrt/files
chmod +x $DIY_SH
cd openwrt
../$DIY_SH
make defconfig
# SSH连接
# - name: SSH connection to Actions
# uses: P3TERX/debugger-action@master
# if: env.SSH_ACTIONS == 'true'
# 下载软件包
- name: Make Download
working-directory: ./openwrt
id: package
run: |
make download -j8
find dl -size -1024c -exec ls -l {} \;
find dl -size -1024c -exec rm -f {} \;
# 编译固件
- name: Compile Firmware
working-directory: ./openwrt
id: compile
run: |
echo -e "$(nproc) thread compile"
make -j$(nproc) || make -j1 V=s
echo "::set-output name=status::success"
# 上传到分支 By yfdoor
- name: Upload Branch
env:
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}
run: |
cd openwrt/bin
git init
git config user.name $GITHUB_USER_NAME
git config user.email $GITHUB_USER_EMAIL
git add .
git commit -m "Update OpenWrt_"$BRANCH
git push --force --quiet https://${{ secrets.RELEASE_TOKEN }}@$GITHUB HEAD:OpenWrt-$BRANCH
# 整理文件
- name: Organize Files
id: organize
if: steps.compile.outputs.status == 'success' && env.UPLOAD_FIRMWARE == 'true' && !cancelled()
run: |
mv openwrt/.config openwrt/bin/targets/*/*
cd openwrt/bin/targets/*/*
rm -rf packages
rm -rf *uImage
rm -rf *.manifest
rm -rf *.seed
rm -rf *.buildinfo
echo "FIRMWARE=$PWD" >> $GITHUB_ENV
echo "::set-output name=status::success"
# 上传固件
#- name: Upload Firmware Directory
# uses: actions/upload-artifact@main
# if: steps.organize.outputs.status == 'success' && !cancelled()
# with:
# name: ${{ env.BUILD_USER }}-${{ env.DATE }}-OpenWrt-${{ env.BRANCH }}-Firmware
# path: ${{ env.FIRMWARE }}
# 上传固件到奶牛快传
- name: Upload Firmware To CowTransfer
if: steps.organize.outputs.status == 'success' && env.UPLOAD_COWTRANSFER == 'true' && !cancelled()
run: |
curl -fsSL git.io/file-transfer | sh
./transfer cow --block 2621440 -s -p 99 -t 3 --hash --no-progress ${FIRMWARE} 2>&1 | tee cowtransfer.log
echo "::warning file=cowtransfer.com::$(cat cowtransfer.log | grep https)"
echo "::set-env name=COWTRANSFER_URL::$(cat cowtransfer.log | grep https | cut -f3 -d" ")" >> $GITHUB_ENV
- name: Upload firmware to WeTransfer
if: steps.organize.outputs.status == 'success' && env.UPLOAD_COWTRANSFER == 'true' && !cancelled()
run: |
curl -fsSL git.io/file-transfer | sh
./transfer wet -s -p 16 --no-progress ${FIRMWARE} 2>&1 | tee wetransfer.log
echo "::warning file=wetransfer.com::$(cat wetransfer.log | grep https)"
echo "::set-env name=WETRANSFER_URL::$(cat wetransfer.log | grep https | cut -f3 -d" ")" >> $GITHUB_ENV
# 生成标签
- name: Generate Tag
id: tag
if: steps.compile.outputs.status == 'success' && env.CREATE_RELEASE == 'true' && !cancelled()
run: |
echo "RELEASE_TAG=$(TZ=UTC-8 date +"%Y-%m-%d")" >> $GITHUB_ENV
echo "::set-output name=status::success"
# 发行固件
- name: Upload Firmware To Release
uses: softprops/action-gh-release@v1
if: steps.tag.outputs.status == 'success' && !cancelled()
env:
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}
with:
name: Netgear ${{ env.BRANCH }} 🚀 | 自动编译 / ${{ env.RELEASE_TAG }}
tag_name: ${{ env.RELEASE_TAG }}
body: |
1、本固件为自动编译
2、发行版中只提供完整的固件
3、需要单独IPK请到分支下载
4、固件源码:${{ env.REPO_URL }}
-- Build by ${{ env.BUILD_USER }} @ with Github Action on ${{ env.RELEASE_TAG }}
🚀 Auto build | 自动编译
🔗 国内[Cowtransfer | 奶牛快传](${{ env.COWTRANSFER_URL }})
🔗 国外[WeTransfer](${{ env.WETRANSFER_URL }})
当前使用版本:(编译前的最后一次大雕源码更新记录)
${{ env.useVersionInfo }}
${{ github.event.commits[0].message }}
files: ${{ env.FIRMWARE }}/*
# 微信通知
- name: WeChat Notification
if: steps.compile.outputs.status == 'success' && env.SEND_WECHAT_MSG == 'true' && !cancelled()
uses: emon100/Action-Serverchan@master
with:
SCKEY: ${{ secrets.SCKEY }}
text: ${{ env.BRANCH }}固件编译完成!
desp: 源码:${{ env.REPO_URL }} 分支:${{ env.REPO_BRANCH }}