forked from hugcabbage/shared-lede
-
Notifications
You must be signed in to change notification settings - Fork 0
160 lines (160 loc) · 6.32 KB
/
固件编译CI.yml
File metadata and controls
160 lines (160 loc) · 6.32 KB
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
#
# Copyright (C) 2020 KFERMercer <KFER.Mercer@gmail.com>
# Copyright (c) 2022 hugcabbage <fengsongtianxia@gmail.com>
#
# This is free software, licensed under the MIT License.
#
#<https://github.com/hugcabbage/shared-lede>
#
# 源码采用lean lede或者lienol openwrt master分支
#
name: 固件编译
on:
workflow_dispatch:
inputs:
build:
description: '若要编译固件,请输入true'
required: true
default: 'true'
model:
description: '选择机型'
required: true
default: 'xiaomi-4a-gigabit'
type: choice
options:
- mi-router-4a-gigabit
- mi-router-3g-v2
- mi-router-ac2100
- redmi-router-ac2100
- mi-router-cr6606
- mi-router-cr6608
- mi-router-cr6609
- mi-router-3g
- mi-router-4
- mi-router-3-pro
- phicomm_k2p
version_description:
description: '输入版本描述'
required: true
default: '升级内容:内核升级,更新应用版本'
cpu_overclock:
description: '超频到1100Mhz(仅适用于5.10内核)'
required: false
default: 'false'
type: boolean
kernel_5_15:
description: '使用5.15内核'
required: false
default: 'false'
type: boolean
release:
description: '上传到release'
required: false
default: 'true'
type: boolean
artifact:
description: '上传到artifact'
required: false
default: 'false'
type: boolean
jobs:
build_openwrt:
name: 固件编译
runs-on: ubuntu-latest
if: github.event.inputs.build == 'true'
steps:
- name: Checkout
uses: actions/checkout@v3
- name: 环境准备
run: |
#sudo rm -rf /usr/share/dotnet /etc/mysql /etc/apt/sources.list.d /usr/local/lib/android /opt/ghc
#sudo -E apt-get -y purge ghc* zulu* hhvm llvm* firefox google* dotnet* powershell openjdk* php* android*
sudo -E apt-get update
sudo -E apt-get -y install build-essential asciidoc binutils bzip2 gawk gettext git libncurses5-dev libz-dev patch python3 zip 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 libtinfo5
sudo -E apt-get -y autoremove --purge
sudo -E apt-get clean
df -h
- name: 机型选择
run: |
cd preset-models ; NUMBER=$(python3 target_select.py ${{ github.event.inputs.model }}) ; cd ..
echo "你选择了:${{ github.event.inputs.model }}"
echo "CLONE_SH=preset-models/${NUMBER}clone.sh" >> $GITHUB_ENV
echo "MODIFY_SH=preset-models/${NUMBER}modify.sh" >> $GITHUB_ENV
echo "CONFIG_PA=preset-models/${NUMBER}.config" >> $GITHUB_ENV
echo "RELEASE_TITLE=$(sed -n "/start of ${NUMBER} model/,/end of ${NUMBER} model/p" preset-models/release_content.txt | grep 'release_title' | cut -d = -f 2)" >> $GITHUB_ENV
echo "ZH_TITLE=$(sed -n "/start of ${NUMBER} model/,/end of ${NUMBER} model/p" preset-models/release_content.txt | grep 'zh_title' | cut -d = -f 2)" >> $GITHUB_ENV
echo "KEY_INFO<<EOF" >> $GITHUB_ENV
sed -n "/start of ${NUMBER} model/,/end of ${NUMBER} model/p" preset-models/release_content.txt | grep -E -v '#|=' >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
- name: 下载源码与插件
run: |
chmod +x $CLONE_SH
$CLONE_SH
- name: 升级feeds
run: |
./scripts/feeds update -a
./scripts/feeds install -a
- name: 修改配置
run: |
[ ${{ github.event.inputs.cpu_overclock }} == true ] && sed -i '/322-mt7621-fix-cpu-clk-add-clkdev.patch/ s/#//' $MODIFY_SH
[ ${{ github.event.inputs.kernel_5_15 }} == true ] && sed -i '/KERNEL_PATCHVER:=5.15/ s/#//' $MODIFY_SH
chmod +x $MODIFY_SH
$MODIFY_SH
- name: 生成.config文件
run: |
mv -f $CONFIG_PA ./.config
sed -i 's/^[ \t]*//g' ./.config
make defconfig
- name: Make download
run: |
make download -j8 || make download -j1 V=s
rm -rf $(find ./dl/ -size -1024c)
df -h
- name: 编译
run: |
make -j$(nproc) || make -j1 V=s
echo "======================="
echo "Space usage:"
echo "======================="
df -h
echo "======================="
du -h ./ --max-depth=1
- name: 整理固件目录
run: |
mkdir -p ./collected_firmware/packages
rm -rf $(find ./bin/targets/ -type d -name "packages")
cp -rf $(find ./bin/targets/ -type f) ./collected_firmware
cp -rf $(find ./bin/packages/ -type f -name "*.ipk") ./collected_firmware/packages
cd collected_firmware
zip -r ./allfiles.zip ./*
cd packages
zip -r ../packages.zip ./*
- name: 获取当前日期
run: |
CURRENT_TIME=$(TZ=Asia/Shanghai date +'%y.%-m.%-d.%H%M%S')
CURRENT_TIME=${CURRENT_TIME:1}
echo "TAG_NAME=${CURRENT_TIME}" >> $GITHUB_ENV
echo "RELEASE_PRE=${CURRENT_TIME%.*}" >> $GITHUB_ENV
- name: 上传固件到release
id: upload-release
if: github.event.inputs.release == 'true' && env.RELEASE_FIRMWARE_VALUE != ''
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.RELEASE_FIRMWARE }}
file: collected_firmware/*
tag: ${{ env.TAG_NAME }}
release_name: "${{ env.RELEASE_PRE }} ${{ env.RELEASE_TITLE }}"
overwrite: true
prerelease: false
body: "${{ env.ZH_TITLE }}<br/>${{ env.KEY_INFO }}<br/>${{ github.event.inputs.version_description }}"
file_glob: true
env:
RELEASE_FIRMWARE_VALUE: ${{ secrets.RELEASE_FIRMWARE }}
- name: 上传固件到artifact
if: github.event.inputs.artifact == 'true' || steps.upload-release.conclusion == 'skipped'
uses: actions/upload-artifact@v3
with:
name: collected_firmware
path: |
collected_firmware/
!collected_firmware/*.zip