-
-
Notifications
You must be signed in to change notification settings - Fork 25
216 lines (193 loc) · 6.73 KB
/
build-x86_64-lean-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
#=================================================
# https://github.com/danxiaonuo/AutoBuild-OpenWrt
# Description: Build OpenWrt using GitHub Actions
# Lisence: MIT
# Author: danxiaonuo
# Blog: https://www.danxiaonuo.com
#=================================================
# 编译的名称
name: 编译x86_64 Lean's的OpenWrt固件
on:
# release触发
# release:
# types: [published]
# 编辑文件触发
# push:
# branches:
# - master
# 路径
# paths:
# - 'config/x86_64-openwrt.config'
# - 'scripts/lean-plugin-openwrt.sh'
# - '.github/workflows/build-x86_64-lean-openwrt.yml'
# 每周三的晚上3点钟编译
schedule:
- cron: '0 3 * * 3'
# 点击★开始触发编译固件
#watch:
# types: [started]
# 环境变量
env:
# 源码仓库地址
REPO_URL: https://github.com/coolsnowwolf/lede
# 源码分支
REPO_BRANCH: master
# 自定义feeds.conf.default文件名
#FEEDS_CONF: feeds.conf.default
# 自定义.config文件名
CONFIG_FILE: config/x86_64-openwrt.config
# 自定义执行脚本名称
DIY_P1_SH: scripts/common-extra-openwrt.sh
DIY_P2_SH: scripts/lean-plugin-openwrt.sh
# 时区设置
TZ: Asia/Shanghai
# 固件标签
TARGET: x86
# 固件版本
SUBTARGET: 64
# 固件名称
DEVICE: openwrt-x86-64
# SSH 连接Actions功能
SSH_ACTIONS: false
# 临时文件名称
DOWNLOAD_URL_FILE: Tmp-Link-Url.txt
# 上传临时文件
UPLOAD_TMP_LINK: true
# 上传 bin 目录
UPLOAD_BIN_DIR: false
# 上传固件目录
UPLOAD_FIRMWARE: true
# 上传固件到奶牛快传
UPLOAD_COWTRANSFER: true
# 上传固件到 WeTransfer
UPLOAD_WETRANSFER: true
# 上传分支
UPLOAD_BRANCH: false
# 分支
BRANCH: x86-64-Lean
# Github 用户名
GITHUB_USER_NAME: danxiaonuo
# Github 邮箱
GITHUB_USER_EMAIL: ${{ secrets.EMAIL }}
# Github
GITHUB: github.com/danxiaonuo/AutoBuild-OpenWrt.git
# 创建+上传发布
CREATE_RELEASE: true
# 编译者
BUILD_USER: danxiaonuo
# 微信通知
SEND_WECHAT_MSG: true
# 发行固件地址
GITHUB_RELEASE: https://github.com/danxiaonuo/AutoBuild-OpenWrt/releases
# 任务集
jobs:
build:
# 选择虚拟环境
runs-on: ubuntu-latest
if: github.event.repository.owner.id == github.event.sender.id
# 运行步骤
steps:
# 检出master分支
- name: 检出master分支
uses: actions/checkout@master
# 初始化系统环境
- name: 初始化系统环境
env:
DEBIAN_FRONTEND: noninteractive
run: |
docker rmi `docker images -q`
# sudo swapoff /swapfile
# sudo rm -rf /swapfile /etc/apt/sources.list.d/* /usr/share/dotnet /usr/local/lib/android /opt/ghc
sudo rm -rf /etc/apt/sources.list.d/* /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*
sudo -E apt-get -qq update
sudo -E apt-get -y full-upgrade
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 git-core antlr3 gperf libreadline-dev ccache curl wget vim nano python python3 python3.5 python-pip python3-pip python-ply python3-ply haveged lrzsz scons ecj fastjar mkisofs
sudo -E apt-get -qq autoremove --purge
sudo -E apt-get -qq clean
curl -fsSL https://raw.githubusercontent.com/danxiaonuo/AutoBuild-OpenWrt/master/server/etc/.bashrc > ~/.bashrc
# 克隆源码
- name: 克隆源码
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 "::set-env name=useVersionInfo::$useVersionInfo"
echo "::set-env name=DATE::$(TZ=CST-8 date "+%Y%m%d%H%M%S")"
echo "::set-env name=RELEASE_DATE::$(TZ=CST-8 date +"%Y.%m.%d-%H")"
# 加载自定义脚本
- name: 加载自定义脚本
run: |
chmod +x $DIY_P1_SH $DIY_P2_SH
cd openwrt
../$DIY_P1_SH
../$DIY_P2_SH
# 更新源
- name: 更新源
working-directory: ./openwrt
run: |
sed -i 's/^#\(src-git .*\)$/\1/' ./feeds.conf.default
./scripts/feeds clean
./scripts/feeds update -a
# 安装源
- name: 安装源
working-directory: ./openwrt
run: |
sed -i 's/^#\(src-git .*\)$/\1/' ./feeds.conf.default
./scripts/feeds install -a
# 加载自定义配置文件
- name: 加载自定义配置文件
run: |
[ -e files ] && mv files openwrt/files
[ -e $CONFIG_FILE ] && mv $CONFIG_FILE openwrt/.config
# 生成配置文件
- name: 生成配置文件
working-directory: ./openwrt
run: |
make defconfig
# 连接SSH
- name: 连接SSH
uses: P3TERX/debugger-action@master
if: env.SSH_ACTIONS == 'true'
# 下载固件包
- name: 下载固件包
working-directory: ./openwrt
id: package
run: |
make download -j8
find dl -size -1024c -exec ls -l {} \;
find dl -size -1024c -exec rm -f {} \;
# 编译固件
- name: 编译固件
working-directory: ./openwrt
id: compile
run: |
echo -e "$(nproc) thread compile"
make -j$(nproc) || make -j1 V=s
echo "::set-output name=status::success"
# 整理文件
- name: 整理文件
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
echo "::set-env name=FIRMWARE::$PWD"
echo "::set-output name=status::success"
# 上传固件
- name: 上传固件
uses: actions/upload-artifact@master
if: steps.organize.outputs.status == 'success' && !cancelled()
with:
name: ${{ env.BUILD_USER }}-${{ env.DATE }}-OpenWrt-${{ env.BRANCH }}-Firmware
path: ${{ env.FIRMWARE }}
# 微信通知
- name: 微信通知
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.BRANCH }}