-
Notifications
You must be signed in to change notification settings - Fork 69
119 lines (98 loc) · 3.77 KB
/
Copy pathbuild.yml
File metadata and controls
119 lines (98 loc) · 3.77 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
#
# Copyright (C) 2022 Ing <https://github.com/wjz304>
#
# This is free software, licensed under the MIT License.
# See /LICENSE for more information.
#
name: Build OpenWrt
on:
schedule:
- cron: "0 0 1/2 * *"
workflow_dispatch:
jobs:
matrix:
runs-on: ubuntu-latest
outputs:
release: ${{ steps.set-matrix.outputs.release }}
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Checkout
uses: actions/checkout@main
- name: Generate build matrix
id: set-matrix
run: |
sudo timedatectl set-timezone "Asia/Shanghai"
echo "release=$(date +"%Y.%m.%d-%H%M")" >> $GITHUB_OUTPUT
# -m 所有项目以逗号分隔,并填满整行行宽
# -B 不列出任何以 ~ 字符结束的项目
# -Q 将条目名称括上双引号
echo "matrix={ \"config\": [ $(echo $(ls -mBQ *.config)) ] }" >> $GITHUB_OUTPUT
build:
name: Build OpenWrt
runs-on: ubuntu-latest
needs: matrix
env:
release: ${{ needs.matrix.outputs.release }}
strategy:
matrix: ${{ fromJson(needs.matrix.outputs.matrix) }}
steps:
- name: Checkout
uses: actions/checkout@main
#- name: Free Disk Space (Ubuntu)
# uses: jlumbroso/free-disk-space@main
# with:
# tool-cache: true
- name: Init Env
env:
DEBIAN_FRONTEND: noninteractive
run: |
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
sudo timedatectl set-timezone "Asia/Shanghai"
sudo apt update
sudo apt full-upgrade -y
sudo apt install -y 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 apt install --reinstall libc6
# sudo systemctl daemon-reload
sudo apt -y autoremove --purge
sudo apt -y clean
git clone --depth=1 https://github.com/openwrt-dev/po2lmo
(cd po2lmo && sudo make && sudo make install)
df -h
- name: make
run: |
sudo mkdir -p /mnt/openwrt
cd /mnt/openwrt
sudo "${GITHUB_WORKSPACE}/build.sh" "${GITHUB_WORKSPACE}/${{ matrix.config }}" "true"
ls -al
if [ $(ls *.img.gz | wc -l) -le 0 ]; then
echo "No firmware found"
exit 1
fi
sudo zip -q -r $(basename "${{ matrix.config }}" .config | awk -F';' '{printf $1"-"$3}')-${{ env.release }}.zip *.img.gz
- name: Upload firmware to release
uses: softprops/action-gh-release@v2
if: success() && !cancelled()
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ env.release }}
files: /mnt/openwrt/*.zip
# - name: Delete workflow runs
# uses: Mattraks/delete-workflow-runs@v2
# with:
# retain_days: 1
# keep_minimum_runs: 9
# - name: Remove old Releases
# uses: dev-drprasad/delete-older-releases@v0.1.0
# with:
# keep_latest: 9
# delete_tags: true
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}