-
Notifications
You must be signed in to change notification settings - Fork 9
208 lines (181 loc) · 6.84 KB
/
Build x86_64_5.15.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
name: Build x86_64_5.15
on:
repository_dispatch:
workflow_dispatch:
# schedule:
# - cron: '0 18 * * 5'
# watch:
# types: started
env:
REPO_URL: https://github.com/coolsnowwolf/lede
REPO_BRANCH: master
FEEDS_CONF: feeds.conf.default
CONFIG_FILE: x86_64.config
DIY_P1_SH: diy-part1.sh
DIY_P2_SH: diy-part2_5.15.sh
REVERT_COMMIT: false
UPLOAD_FIRMWARE: false
UPLOAD_RELEASE: true
TZ: Asia/Shanghai
jobs:
build:
runs-on: ubuntu-latest
timeout-minutes: 360
name: Build ${{ matrix.target.arch }}_${{ matrix.target.kernel }}
strategy:
fail-fast: false
matrix:
target:
- arch: "x86_64"
target: "x86"
kernel: "5.15"
steps:
- name: 检查
uses: actions/checkout@main
- name: 释放磁盘空间
uses: jlumbroso/free-disk-space@main
with:
tool-cache: false
android: true
dotnet: true
haskell: true
large-packages: true
docker-images: true
swap-storage: true
- name: 初始化环境
env:
DEBIAN_FRONTEND: noninteractive
run: |
sudo -E rm -rf "$AGENT_TOOLSDIRECTORY" || true
sudo -E apt -yqq update
sudo -E apt -yqq full-upgrade
sudo -E apt -yqq install $(curl -fsSL https://raw.githubusercontent.com/ywt114/diy/main/depends | tr '\n' ' ') || true
sudo -E apt -yqq autoremove --purge
sudo -E apt -yqq autoclean
sudo -E systemctl daemon-reload
df -hT
- name: 设置当前的日期
id: date
run: |
sudo timedatectl set-timezone "$TZ"
echo "date1=$(date +'%Y%m%d')" >> $GITHUB_ENV
- name: 克隆源代码
run: |
git clone -b $REPO_BRANCH $REPO_URL openwrt
sed -i "s/KERNEL_PATCHVER:=*.*/KERNEL_PATCHVER:=${{ matrix.target.kernel }}/g" openwrt/target/linux/${{ matrix.target.target }}/Makefile
sed -i "s/KERNEL_TESTING_PATCHVER:=*.*/KERNEL_TESTING_PATCHVER:=${{ matrix.target.kernel }}/g" openwrt/target/linux/${{ matrix.target.target }}/Makefile
- name: 自定义配置feeds
run: |
[ -e $FEEDS_CONF ] && mv $FEEDS_CONF openwrt/feeds.conf.default
chmod +x $DIY_P1_SH
cd openwrt
$GITHUB_WORKSPACE/$DIY_P1_SH
- name: 更新 feeds
working-directory: ./openwrt
run: |
./scripts/feeds update -a
- name: 执行回滚
if: env.REVERT_COMMIT == 'true' && !cancelled()
run: |
cd $(curl -fsSL https://raw.githubusercontent.com/ywt114/diy/main/directory | tr '\n' ' ')
git reset --hard $(curl -fsSL https://raw.githubusercontent.com/ywt114/diy/main/commit | tr '\n' ' ')
- name: 安装 feeds
working-directory: ./openwrt
run: |
./scripts/feeds install -a
- name: 自定义配置
run: |
[ -e $CONFIG_FILE ] && mv $CONFIG_FILE openwrt/.config
chmod +x $DIY_P2_SH
cd openwrt
$GITHUB_WORKSPACE/$DIY_P2_SH
- name: 下载包文件
id: package
working-directory: ./openwrt
run: |
make defconfig
make download -j$(($(nproc)+1))
find dl -size -1024c -exec ls -l {} \;
find dl -size -1024c -exec rm -f {} \;
- name: 缓存
uses: stupidloud/cachewrtbuild@main
with:
ccache: 'true'
prefix: 'openwrt'
- name: 编译前空间情况
if: (!cancelled())
run: |
df -hT
- name: 编译固件
id: compile
working-directory: ./openwrt
run: |
echo -e "$(($(nproc)+1)) thread compile"
make -j$(($(nproc)+1)) || make -j1 V=s
tree bin/
echo "status=success" >> $GITHUB_OUTPUT
- name: 编译后空间情况
if: steps.compile.outputs.status == 'success' && !cancelled()
run: |
df -hT
- name: 重命名文件
if: steps.compile.outputs.status == 'success' && !cancelled()
run: |
find openwrt/bin/targets -type f \( -name "openwrt*.gz" \) -exec sh -c 'mv "$1" "$(dirname "$1")/${{ env.date1 }}-${{ matrix.target.kernel }}-$(basename "$1")"' sh {} \; 2>/dev/null || true
- name: 整理文件
id: organize
if: steps.compile.outputs.status == 'success' && !cancelled()
run: |
mkdir -p firmware
mkdir -p firmware/package/
find openwrt/bin/targets/ -type f \( -name "*squashfs-combined*.gz" -o -name "*sysupgrade*" \) -exec mv {} ./firmware/ \; 2>/dev/null || true
find openwrt/bin/packages/ -type f \( -name "*.ipk" \) -exec mv {} ./firmware/package/ \; 2>/dev/null || true
mv openwrt/.config ./firmware/${{ matrix.target.arch }}_${{ matrix.target.kernel }}.config 2>/dev/null || true
mv openwrt/build_dir/target-*/linux-*/linux-*/.config ./firmware/${{ matrix.target.arch }}_${{ matrix.target.kernel }}_kernel.config 2>/dev/null || true
[ -e release ] && cp release ./firmware/release.txt
cd firmware
echo -n "${{ env.date1 }}" > version.txt
md5=$(md5sum *squashfs-combined.img.gz | awk '{print $1}') 2>/dev/null || true
md5_efi=$(md5sum *squashfs-combined-efi.img.gz | awk '{print $1}') 2>/dev/null || true
echo "md5=$md5" > md5sum.txt
echo "md5_efi=$md5_efi" >> md5sum.txt
rm -rf sha256sums
echo "status=success" >> $GITHUB_OUTPUT
- name: 上传artifact固件目录
uses: actions/upload-artifact@main
if: steps.organize.outputs.status == 'success' && env.UPLOAD_FIRMWARE == 'true' && !cancelled()
with:
name: ${{ env.date1 }}_${{ matrix.target.arch }}_${{ matrix.target.kernel }}
path: ./firmware/**
- name: 生成releases发布标签
id: tag
if: steps.organize.outputs.status == 'success' && env.UPLOAD_RELEASE == 'true' && !cancelled()
run: |
echo "release_tag=${{ env.date1 }}" >> $GITHUB_OUTPUT
[ -e release ] && cp release ./release.txt
echo "status=success" >> $GITHUB_OUTPUT
- name: 上传releases固件发布
uses: softprops/action-gh-release@master
if: steps.organize.outputs.status == 'success' && env.UPLOAD_RELEASE == 'true' && !cancelled()
env:
GITHUB_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
with:
files: ./firmware/*.*
name: ${{ env.date1 }}_${{ matrix.target.arch }}_${{ matrix.target.kernel }}
tag_name: ${{ matrix.target.arch }}_${{ matrix.target.kernel }}
body_path: release.txt
- name: 删除workflow工作流
uses: Mattraks/delete-workflow-runs@main
with:
token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
repository: ${{ github.repository }}
retain_days: 1
keep_minimum_runs: 1
- name: 删除releases旧版本
uses: dev-drprasad/delete-older-releases@master
if: env.UPLOAD_RELEASE == 'true' && !cancelled()
env:
GITHUB_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
with:
keep_latest: 5
delete_tags: true