Skip to content

我的OpenWrt云编译:d-team_newifi-d2 #10

我的OpenWrt云编译:d-team_newifi-d2

我的OpenWrt云编译:d-team_newifi-d2 #10

Workflow file for this run

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
chmod +x ../profiles/*.sh
if [ -n "${{ inputs.target_profile }}" ]; then
cp ../profiles/${{ inputs.target_profile }}.sh ${{ inputs.target_profile }}.sh
./${{ inputs.target_profile }}.sh
fi
./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 }}"
else
# 自动选择一个常见设备
echo "使用默认配置 (Newifi D2)"
cat > .config << 'EOF'
# 自动生成的默认配置
CONFIG_TARGET_ramips=y
CONFIG_TARGET_ramips_mt7621=y
CONFIG_TARGET_ramips_mt7621_DEVICE_d-team_newifi-d2=y
CONFIG_PACKAGE_luci=y
CONFIG_PACKAGE_luci-ssl-openssl=y
CONFIG_LUCI_LANG_zh-cn=y
# 基础包
CONFIG_PACKAGE_wpad-openssl=y
CONFIG_PACKAGE_iptables-mod-extra=y
CONFIG_PACKAGE_iptables-mod-tproxy=y
# 文件系统支持
CONFIG_PACKAGE_kmod-fs-ext4=y
CONFIG_PACKAGE_kmod-fs-ntfs=y
CONFIG_PACKAGE_kmod-usb-storage=y
EOF
fi
make defconfig
- 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
- 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