Build OpenWrt #889
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # | |
| # 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 }} |