1212 - cron : " 0 0 1/2 * *"
1313 workflow_dispatch :
1414
15+ permissions :
16+ contents : write
17+
18+ concurrency :
19+ group : ${{ github.workflow }}-${{ github.ref }}
20+ cancel-in-progress : true
21+
22+ defaults :
23+ run :
24+ shell : bash
25+
1526jobs :
1627 matrix :
1728 runs-on : ubuntu-latest
@@ -20,100 +31,90 @@ jobs:
2031 matrix : ${{ steps.set-matrix.outputs.matrix }}
2132 steps :
2233 - name : Checkout
23- uses : actions/checkout@main
34+ uses : actions/checkout@v4
2435
2536 - name : Generate build matrix
2637 id : set-matrix
2738 run : |
39+ set -euo pipefail
2840 sudo timedatectl set-timezone "Asia/Shanghai"
29- echo "release=$(date +" %Y.%m.%d-%H%M" )" >> $ GITHUB_OUTPUT
41+ echo "release=$(date +' %Y.%m.%d-%H%M' )" >> "${ GITHUB_OUTPUT}"
3042
31- # -m 所有项目以逗号分隔,并填满整行行宽
32- # -B 不列出任何以 ~ 字符结束的项目
33- # -Q 将条目名称括上双引号
43+ python3 - <<'PY' >> "${GITHUB_OUTPUT}"
44+ import json
45+ import pathlib
3446
35- echo "matrix={ \"config\": [ $(echo $(ls -mBQ *.config)) ] }" >> $GITHUB_OUTPUT
47+ configs = sorted(
48+ p.name for p in pathlib.Path(".").glob("*.config")
49+ if not p.name.endswith("~")
50+ )
51+
52+ print(f"matrix={json.dumps({'config': configs}, ensure_ascii=False)}")
53+ PY
3654
3755 build :
3856 name : Build OpenWrt
3957 runs-on : ubuntu-latest
58+ timeout-minutes : 360
4059 needs : matrix
4160 env :
4261 release : ${{ needs.matrix.outputs.release }}
4362 strategy :
63+ fail-fast : false
4464 matrix : ${{ fromJson(needs.matrix.outputs.matrix) }}
4565
4666 steps :
4767 - name : Checkout
48- uses : actions/checkout@main
49-
50- # - name: Free Disk Space (Ubuntu)
51- # uses: jlumbroso/free-disk-space@main
52- # with:
53- # tool-cache: true
68+ uses : actions/checkout@v4
5469
5570 - name : Init Env
5671 env :
5772 DEBIAN_FRONTEND : noninteractive
5873 run : |
74+ set -euo pipefail
75+
5976 git config --global user.email "github-actions[bot]@users.noreply.github.com"
6077 git config --global user.name "github-actions[bot]"
6178 sudo timedatectl set-timezone "Asia/Shanghai"
6279
63- sudo apt update
64- sudo apt full-upgrade -y
65- sudo apt install -y ack antlr3 asciidoc autoconf automake autopoint binutils bison build-essential \
66- bzip2 ccache clang cmake cpio curl device-tree-compiler flex gawk gcc-multilib g++-multilib gettext \
67- genisoimage git gperf haveged help2man intltool libc6-dev-i386 libelf-dev libfuse-dev libglib2.0-dev \
68- libgmp3-dev libltdl-dev libmpc-dev libmpfr-dev libncurses5-dev libncursesw5-dev libpython3-dev \
69- libreadline-dev libssl-dev libtool llvm lrzsz msmtp ninja-build p7zip p7zip-full patch pkgconf \
70- python3 python3-pyelftools python3-setuptools qemu-utils rsync scons squashfs-tools subversion \
71- swig texinfo uglifyjs upx-ucl unzip vim wget xmlto xxd zlib1g-dev
72-
73- # sudo apt install --reinstall libc6
74- # sudo systemctl daemon-reload
75- sudo apt -y autoremove --purge
76- sudo apt -y clean
80+ sudo apt-get update
81+ sudo apt-get install -y --no-install-recommends \
82+ ack antlr3 asciidoc autoconf automake autopoint binutils bison build-essential \
83+ bzip2 ccache clang cmake cpio curl device-tree-compiler flex gawk gcc-multilib g++-multilib gettext \
84+ genisoimage git gperf haveged help2man intltool libc6-dev-i386 libelf-dev libfuse-dev libglib2.0-dev \
85+ libgmp3-dev libltdl-dev libmpc-dev libmpfr-dev libncurses5-dev libncursesw5-dev libpython3-dev \
86+ libreadline-dev libssl-dev libtool llvm lrzsz msmtp ninja-build p7zip p7zip-full patch pkgconf \
87+ python3 python3-pyelftools python3-setuptools qemu-utils rsync scons squashfs-tools subversion \
88+ swig texinfo uglifyjs upx-ucl unzip vim wget xmlto xxd zlib1g-dev
7789
7890 git clone --depth=1 https://github.com/openwrt-dev/po2lmo
7991 (cd po2lmo && sudo make && sudo make install)
92+ rm -rf po2lmo
8093
94+ sudo apt-get autoremove -y
95+ sudo apt-get clean
8196 df -h
8297
83- - name : make
98+ - name : Build Firmware
8499 run : |
85- sudo mkdir -p /mnt/openwrt
100+ set -euo pipefail
86101
102+ sudo mkdir -p /mnt/openwrt
87103 cd /mnt/openwrt
104+
88105 sudo "${GITHUB_WORKSPACE}/build.sh" "${GITHUB_WORKSPACE}/${{ matrix.config }}" "true"
89106
90- ls -al
91- if [ $(ls *.img.gz | wc -l) -le 0 ]; then
107+ if ! compgen -G "*.img.gz" > /dev/null; then
92108 echo "No firmware found"
93109 exit 1
94110 fi
95111
96- sudo zip -q -r $(basename "${{ matrix.config }}" .config | awk -F';' '{printf $1"-"$3}')-${{ env.release }}.zip *.img.gz
112+ zip_name="$(basename "${{ matrix.config }}" .config | awk -F';' '{printf $1"-"$3}')-${{ env.release }}.zip"
113+ sudo zip -q -r "${zip_name}" *.img.gz
97114
98115 - name : Upload firmware to release
99116 uses : softprops/action-gh-release@v2
100117 if : success() && !cancelled()
101- env :
102- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
103118 with :
104119 tag_name : ${{ env.release }}
105120 files : /mnt/openwrt/*.zip
106-
107- # - name: Delete workflow runs
108- # uses: Mattraks/delete-workflow-runs@v2
109- # with:
110- # retain_days: 1
111- # keep_minimum_runs: 9
112-
113- # - name: Remove old Releases
114- # uses: dev-drprasad/delete-older-releases@v0.1.0
115- # with:
116- # keep_latest: 9
117- # delete_tags: true
118- # env:
119- # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
0 commit comments