forked from coolsnowwolf/lede
-
Notifications
You must be signed in to change notification settings - Fork 0
210 lines (182 loc) · 7.76 KB
/
openwrt-ci.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
#
# This is free software, lisence use MIT.
#
# Copyright (C) 2019 P3TERX <https://p3terx.com>
# Copyright (C) 2020 KFERMercer <[email protected]>
#
# <https://github.com/KFERMercer/OpenWrt-CI>
#
name: OpenWrt-CI
on:
push:
branches:
- master
schedule:
- cron: 0 20 * * *
release:
types: [published]
env:
UPLOAD_RELEASE: true
jobs:
build_openwrt:
name: Build OpenWrt firmware
runs-on: ubuntu-22.04
if: github.event.repository.owner.id == github.event.sender.id || ! github.event.sender.id
steps:
- name: Before freeing up disk space
run: |
echo "Before freeing up disk space"
echo "=============================================================================="
df -hT
echo "=============================================================================="
- name: "Optimize Disk Space"
uses: "hugoalh/[email protected]"
with:
operate_sudo: "True"
general_include: ".+"
general_exclude: |-
^GCC$
^G\+\+$
Clang
LLVM
docker_include: ".+"
docker_prune: "True"
docker_clean: "True"
apt_prune: "True"
apt_clean: "True"
homebrew_prune: "True"
homebrew_clean: "True"
npm_prune: "True"
npm_clean: "True"
os_swap: "True"
- name: Freeing up disk space
uses: easimon/maximize-build-space@master
with:
root-reserve-mb: 2048
swap-size-mb: 1
remove-dotnet: 'true'
remove-android: 'true'
remove-haskell: 'true'
remove-codeql: 'true'
remove-docker-images: 'true'
- name: Free up disk space complete
run: |
echo "Free up disk space complete"
echo "=============================================================================="
df -hT
echo "=============================================================================="
- name: Checkout
uses: actions/checkout@v4
with:
ref: master
- name: Space cleanup
env:
DEBIAN_FRONTEND: noninteractive
run: |
sudo -E rm -rf /usr/share/dotnet /etc/mysql /etc/php /etc/apt/sources.list.d /usr/local/lib/android
sudo -E apt-mark hold grub-efi-amd64-signed
sudo -E apt update
sudo -E apt -y purge azure-cli* docker* ghc* zulu* llvm* firefox google* dotnet* powershell* openjdk* mysql* php* mongodb* dotnet* snap*
sudo -E apt -y full-upgrade
sudo -E apt -y install ack antlr3 asciidoc autoconf automake autopoint binutils bison build-essential bzip2 ccache clang cmake cpio curl device-tree-compiler flex gawk gcc-multilib g++-multilib gettext genisoimage git gperf haveged help2man intltool libc6-dev-i386 libelf-dev libfuse-dev libglib2.0-dev libgmp3-dev libltdl-dev libmpc-dev libmpfr-dev libncurses5-dev libncursesw5-dev libpython3-dev libreadline-dev libssl-dev libtool llvm lrzsz msmtp ninja-build p7zip p7zip-full patch pkgconf python3 python3-pyelftools python3-setuptools qemu-utils rsync scons squashfs-tools subversion swig texinfo uglifyjs upx-ucl unzip vim wget xmlto xxd zlib1g-dev
sudo -E systemctl daemon-reload
sudo -E apt -y autoremove --purge
sudo -E apt clean
sudo -E timedatectl set-timezone "Asia/Shanghai"
- name: Update feeds
run: |
./scripts/feeds update -a
./scripts/feeds install -a
- name: Openwrt AutoUpdate
run: |
TEMP=$(date +"OpenWrt_%Y%m%d_%H%M%S_")$(git rev-parse --short HEAD)
echo "RELEASE_TAG=$TEMP" >> $GITHUB_ENV
#required>>add "DISTRIB_GITHUB" to "zzz-default-settings"
sed -i "/DISTRIB_DESCRIPTION=/a\sed -i '/DISTRIB_GITHUB/d' /etc/openwrt_release" ./package/lean/default-settings/files/zzz-default-settings
sed -i "/DISTRIB_GITHUB/a\echo \"DISTRIB_GITHUB=\'https://github.com/${{github.repository}}\'\" >> /etc/openwrt_release" ./package/lean/default-settings/files/zzz-default-settings
#required>>add "DISTRIB_VERSIONS" to "zzz-default-settings"
sed -i "/DISTRIB_DESCRIPTION=/a\sed -i '/DISTRIB_VERSIONS/d' /etc/openwrt_release" ./package/lean/default-settings/files/zzz-default-settings
sed -i "/DISTRIB_VERSIONS/a\echo \"DISTRIB_VERSIONS=\'${TEMP:8}\'\" >> /etc/openwrt_release" ./package/lean/default-settings/files/zzz-default-settings
#nonessential>>add "github.actor" to "DISTRIB_DESCRIPTION" in "zzz-default-settings"
sed -i "s/OpenWrt /${{github.actor}} compiled (${TEMP:8}) \/ OpenWrt /g" ./package/lean/default-settings/files/zzz-default-settings
- name: Generate configuration file
run: |
cp ./makeconfig.d/x86_64.config ./.config
make oldconfig
- name: Make download
run: |
make download -j16
- name: Compile firmware
run: |
make -j$(nproc) || make -j1 V=s
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/package
mkdir -p ./artifact/buildinfo
rm -rf $(find ./bin/targets/ -type d -name "packages")
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/
- name: Deliver buildinfo
uses: actions/upload-artifact@v3
with:
name: OpenWrt_buildinfo
path: ./artifact/buildinfo/
- name: Deliver package
uses: actions/upload-artifact@v3
with:
name: OpenWrt_package
path: ./artifact/package/
- name: Deliver firmware
uses: actions/upload-artifact@v3
with:
name: OpenWrt_firmware
path: ./bin/targets/
- name: Upload release asset
if: github.event == 'release'
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.YOURTOKEN }}
file: ./artifact/firmware/*
tag: ${{ github.ref }}
file_glob: true
- name: Generate release tag
id: tag
if: env.UPLOAD_RELEASE == 'true' && !cancelled()
run: |
echo "release_tag=$(date +"%Y.%m.%d-%H%M")" >>$GITHUB_OUTPUT
touch release.txt
[ $UPLOAD_COWTRANSFER = true ] && echo "🔗 [Cowtransfer](${{ steps.cowtransfer.outputs.url }})" >> release.txt
[ $UPLOAD_WETRANSFER = true ] && echo "🔗 [WeTransfer](${{ steps.wetransfer.outputs.url }})" >> release.txt
echo "status=success" >>$GITHUB_OUTPUT
- name: Upload firmware to release
uses: softprops/action-gh-release@v1
if: steps.tag.outputs.status == 'success' && !cancelled()
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ env.RELEASE_TAG }}
body_path: release.txt
files: ./bin/targets/x86/64/*
- name: Delete workflow runs
uses: Mattraks/delete-workflow-runs@v2
with:
token: ${{ github.token }}
repository: ${{ github.repository }}
retain_days: 30
keep_minimum_runs: 6
- name: Remove old Releases
uses: Vucko130/[email protected]
if: env.UPLOAD_RELEASE == 'true' && !cancelled()
with:
keep_latest: 3
delete_tags: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}