OpenWrt Builder #464
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
| # | |
| # https://github.com/P3TERX/Actions-OpenWrt | |
| # | |
| # File: .github/workflows/openwrt-bulder.yml | |
| # Description: Build OpenWrt using GitHub Actions | |
| # | |
| # Copyright (c) 2019-2024 P3TERX <https://p3terx.com> | |
| # | |
| # This is free software, licensed under the MIT License. | |
| # See /LICENSE for more information. | |
| # | |
| name: OpenWrt Builder | |
| on: | |
| repository_dispatch: | |
| workflow_dispatch: | |
| env: | |
| REPO_URL: https://github.com/coolsnowwolf/lede | |
| REPO_BRANCH: master | |
| FEEDS_CONF: feeds.conf.default | |
| CONFIG_FILE: .config | |
| DIY_P1_SH: diy-part1.sh | |
| DIY_P2_SH: diy-part2.sh | |
| UPLOAD_BIN_DIR: true | |
| UPLOAD_FIRMWARE: true | |
| TZ: Asia/Shanghai | |
| jobs: | |
| build: | |
| runs-on: ubuntu-22.04 | |
| steps: | |
| - name: Before freeing up disk space | |
| run: | | |
| echo "Before freeing up disk space" | |
| echo "==============================================================================" | |
| df -hT | |
| echo "==============================================================================" | |
| - name: Initialization environment | |
| env: | |
| DEBIAN_FRONTEND: noninteractive | |
| run: | | |
| docker image prune -f | |
| 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 scdoc | |
| sudo -E systemctl daemon-reload | |
| sudo -E apt -y autoremove --purge | |
| sudo -E apt clean | |
| sudo -E timedatectl set-timezone "Asia/Shanghai" | |
| sudo chown $USER:$GROUPS $GITHUB_WORKSPACE | |
| - name: Checkout | |
| uses: actions/checkout@main | |
| - name: Free Disk Space (Ubuntu) | |
| uses: jlumbroso/free-disk-space@main | |
| with: | |
| # this might remove tools that are actually needed, | |
| # if set to "true" but frees about 6 GB | |
| tool-cache: true | |
| # all of these default to true, but feel free to set to | |
| # "false" if necessary for your workflow | |
| android: true | |
| dotnet: true | |
| haskell: true | |
| large-packages: true | |
| swap-storage: true | |
| - name: Clone source code | |
| working-directory: ./ | |
| run: | | |
| df -hT $PWD | |
| git clone $REPO_URL -b $REPO_BRANCH openwrt | |
| - name: Load custom 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: Update feeds | |
| run: cd openwrt && ./scripts/feeds update -a | |
| - name: Install feeds | |
| run: cd openwrt && ./scripts/feeds install -a | |
| - name: Load custom configuration | |
| run: | | |
| [ -e files ] && mv files openwrt/files | |
| [ -e $CONFIG_FILE ] && mv $CONFIG_FILE openwrt/.config | |
| chmod +x $DIY_P2_SH | |
| cd openwrt | |
| $GITHUB_WORKSPACE/$DIY_P2_SH | |
| - name: Download package | |
| id: package | |
| run: | | |
| cd openwrt | |
| make defconfig | |
| make download -j8 | |
| find dl -size -1024c -exec ls -l {} \; | |
| find dl -size -1024c -exec rm -f {} \; | |
| - name: Compile the firmware | |
| id: compile | |
| run: | | |
| cd openwrt | |
| echo -e "$(nproc) thread compile" | |
| make -j$(nproc) || make -j1 || make -j1 V=s | |
| echo "status=success" >> $GITHUB_OUTPUT | |
| grep '^CONFIG_TARGET.*DEVICE.*=y' .config | sed -r 's/.*DEVICE_(.*)=y/\1/' > DEVICE_NAME | |
| [ -s DEVICE_NAME ] && echo "DEVICE_NAME=_$(cat DEVICE_NAME)" >> $GITHUB_ENV | |
| echo "FILE_DATE=_$(date +"%Y%m%d%H%M")" >> $GITHUB_ENV | |
| - name: Check space usage | |
| if: (!cancelled()) | |
| run: df -hT | |
| - name: Upload bin directory | |
| uses: actions/upload-artifact@main | |
| if: steps.compile.outputs.status == 'success' && env.UPLOAD_BIN_DIR == 'true' | |
| with: | |
| name: OpenWrt_bin${{ env.DEVICE_NAME }}${{ env.FILE_DATE }} | |
| path: openwrt/bin | |
| - name: Organize files | |
| id: organize | |
| if: env.UPLOAD_FIRMWARE == 'true' && !cancelled() | |
| run: | | |
| cd openwrt/bin/targets/*/* | |
| rm -rf packages | |
| echo "FIRMWARE=$PWD" >> $GITHUB_ENV | |
| echo "status=success" >> $GITHUB_OUTPUT | |
| - name: Upload firmware directory | |
| uses: actions/upload-artifact@main | |
| if: steps.organize.outputs.status == 'success' && !cancelled() | |
| with: | |
| name: OpenWrt_firmware${{ env.DEVICE_NAME }}${{ env.FILE_DATE }} | |
| path: ${{ env.FIRMWARE }} | |
| - name: Upload efi.img.gz | |
| uses: actions/upload-artifact@main | |
| with: | |
| name: efi.img.gz | |
| path: openwrt/bin/targets/x86/64/*efi.img.gz | |
| - name: Upload passwall2 | |
| uses: actions/upload-artifact@main | |
| with: | |
| name: passwall2 | |
| path: openwrt/bin/packages/x86_64/passwall2/*passwall* |