我的OpenWrt云编译:d-team_newifi-d2 #15
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
| name: Auto OpenWrt Build | |
| run-name: 我的OpenWrt云编译:${{ inputs.target_profile }} | |
| env: | |
| TZ: Asia/Shanghai | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| target_profile: | |
| description: '目标设备配置文件' | |
| required: false | |
| default: 'd-team_newifi-d2' | |
| type: string | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: 检出仓库 | |
| uses: actions/checkout@v4 | |
| - name: 安装编译工具 | |
| run: | | |
| sudo apt-get update | |
| sudo DEBIAN_FRONTEND=noninteractive apt-get install -y \ | |
| build-essential clang flex bison g++ gawk gcc-multilib g++-multilib \ | |
| gettext git libncurses5-dev libssl-dev python3 python3-setuptools \ | |
| rsync swig unzip zlib1g-dev file wget | |
| - name: 获取 OpenWrt 源码 | |
| run: | | |
| git clone --depth=1 https://github.com/openwrt/openwrt.git -b openwrt-25.12 | |
| cd openwrt | |
| sed -i '1i src-git kenzo https://github.com/kenzok8/openwrt-packages' feeds.conf.default | |
| sed -i '2i src-git small https://github.com/kenzok8/small' feeds.conf.default | |
| ./scripts/feeds update -a | |
| ./scripts/feeds install -a | |
| - name: 配置 OpenWrt | |
| run: | | |
| cd openwrt | |
| # 如果有指定的配置文件 | |
| if [ -n "${{ inputs.target_profile }}.config" ] && [ -f "../profiles/${{ inputs.target_profile }}.config" ]; then | |
| cp "../profiles/${{ inputs.target_profile }}.config" .config | |
| echo "使用了自定义配置: ${{ inputs.target_profile }}.config" | |
| fi | |
| make defconfig | |
| chmod +x ../profiles/*.sh | |
| if [ -n "${{ inputs.target_profile }}" ]; then | |
| echo "初始化配置: ${{ inputs.target_profile }}.sh" | |
| ../profiles/${{ inputs.target_profile }}.sh | |
| fi | |
| - name: 编译 | |
| run: | | |
| cd openwrt | |
| echo "开始下载和编译..." | |
| # 下载包(最多重试3次) | |
| for i in {1..3}; do | |
| make download -j$(nproc) && break || sleep 10 | |
| done | |
| # 编译 | |
| make -j$(($(nproc)+1)) || make -j$(nproc) || make -j1 V=s | |
| - name: 收集结果 | |
| run: | | |
| echo "编译结果:" | |
| find openwrt -name "*.bin" -o -name "*.img" -o -name "*.gz" | head -20 | xargs ls -lh 2>/dev/null || echo "没有找到固件" | |
| - name: 保存固件 | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: openwrt-build | |
| path: openwrt/bin/ | |
| retention-days: 5 |