mirror of
https://github.com/Dichgrem/Dwrt-build.git
synced 2025-12-16 21:51:59 -05:00
feat:wrt_choice
This commit is contained in:
109
.github/workflows/build.yml
vendored
109
.github/workflows/build.yml
vendored
@@ -1,8 +1,19 @@
|
|||||||
name: Build ImmortalWrt
|
name: Build Custom WRT
|
||||||
|
|
||||||
on:
|
on:
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
inputs:
|
inputs:
|
||||||
|
project:
|
||||||
|
description: "选择 WRT 项目"
|
||||||
|
required: true
|
||||||
|
default: "immortalwrt"
|
||||||
|
type: choice
|
||||||
|
options:
|
||||||
|
- openwrt
|
||||||
|
- immortalwrt
|
||||||
|
- x-wrt
|
||||||
|
- lienol
|
||||||
|
- lede
|
||||||
version_type:
|
version_type:
|
||||||
description: "版本类型"
|
description: "版本类型"
|
||||||
required: true
|
required: true
|
||||||
@@ -14,7 +25,7 @@ on:
|
|||||||
branch:
|
branch:
|
||||||
description: "snapshot-branch"
|
description: "snapshot-branch"
|
||||||
required: false
|
required: false
|
||||||
default: "openwrt-24.10"
|
default: "master"
|
||||||
type: string
|
type: string
|
||||||
tag:
|
tag:
|
||||||
description: "stable-tag"
|
description: "stable-tag"
|
||||||
@@ -22,7 +33,7 @@ on:
|
|||||||
default: "v24.10.2"
|
default: "v24.10.2"
|
||||||
type: string
|
type: string
|
||||||
config_path:
|
config_path:
|
||||||
description: "Config 路径"
|
description: "config路径"
|
||||||
required: true
|
required: true
|
||||||
default: "config/myconfig"
|
default: "config/myconfig"
|
||||||
type: string
|
type: string
|
||||||
@@ -39,19 +50,11 @@ jobs:
|
|||||||
id: refinfo
|
id: refinfo
|
||||||
run: |
|
run: |
|
||||||
if [ "${{ inputs.version_type }}" = "snapshot" ]; then
|
if [ "${{ inputs.version_type }}" = "snapshot" ]; then
|
||||||
echo "Using branch '${{ inputs.branch }}'"
|
|
||||||
echo "ref=${{ inputs.branch }}" >> $GITHUB_OUTPUT
|
echo "ref=${{ inputs.branch }}" >> $GITHUB_OUTPUT
|
||||||
else
|
else
|
||||||
echo "Using tag '${{ inputs.tag }}'"
|
|
||||||
echo "ref=${{ inputs.tag }}" >> $GITHUB_OUTPUT
|
echo "ref=${{ inputs.tag }}" >> $GITHUB_OUTPUT
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: Clone ImmortalWrt source
|
|
||||||
run: |
|
|
||||||
echo "📥 克隆 immortalwrt 仓库,ref=${{ steps.refinfo.outputs.ref }}"
|
|
||||||
git clone --branch "${{ steps.refinfo.outputs.ref }}" \
|
|
||||||
https://github.com/immortalwrt/immortalwrt.git immortalwrt
|
|
||||||
|
|
||||||
- name: Install build dependencies
|
- name: Install build dependencies
|
||||||
run: |
|
run: |
|
||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
@@ -66,8 +69,51 @@ jobs:
|
|||||||
uuid-dev device-tree-compiler antlr3 gperf \
|
uuid-dev device-tree-compiler antlr3 gperf \
|
||||||
time bc jq xxd swig upx-ucl ccache ecj fastjar imagemagick
|
time bc jq xxd swig upx-ucl ccache ecj fastjar imagemagick
|
||||||
|
|
||||||
|
- name: Determine Git URL
|
||||||
|
id: projectinfo
|
||||||
|
run: |
|
||||||
|
case "${{ inputs.project }}" in
|
||||||
|
immortalwrt)
|
||||||
|
echo "url=https://github.com/immortalwrt/immortalwrt.git" >> $GITHUB_OUTPUT
|
||||||
|
;;
|
||||||
|
x-wrt)
|
||||||
|
echo "url=https://github.com/x-wrt/x-wrt.git" >> $GITHUB_OUTPUT
|
||||||
|
;;
|
||||||
|
openwrt)
|
||||||
|
echo "url=https://git.openwrt.org/openwrt/openwrt.git" >> $GITHUB_OUTPUT
|
||||||
|
;;
|
||||||
|
lienol)
|
||||||
|
echo "url=https://github.com/Lienol/openwrt.git" >> $GITHUB_OUTPUT
|
||||||
|
;;
|
||||||
|
lede)
|
||||||
|
echo "url=https://github.com/coolsnowwolf/lede.git" >> $GITHUB_OUTPUT
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "❌ 未知项目: ${{ inputs.project }}" >&2
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
- name: Clone selected WRT source
|
||||||
|
run: |
|
||||||
|
echo "📥 克隆 ${{ inputs.project }} 仓库,ref=${{ steps.refinfo.outputs.ref }}"
|
||||||
|
git clone --branch "${{ steps.refinfo.outputs.ref }}" \
|
||||||
|
"${{ steps.projectinfo.outputs.url }}" wrt
|
||||||
|
|
||||||
|
- name: Copy diy.sh to WRT
|
||||||
|
run: |
|
||||||
|
echo "📂 复制 diy.sh 到 wrt 目录"
|
||||||
|
cp diy.sh wrt/diy.sh
|
||||||
|
|
||||||
|
- name: Run diy.sh
|
||||||
|
working-directory: wrt
|
||||||
|
run: |
|
||||||
|
echo "🔧 执行 diy.sh"
|
||||||
|
chmod +x diy.sh
|
||||||
|
./diy.sh
|
||||||
|
|
||||||
- name: Update and install feeds
|
- name: Update and install feeds
|
||||||
working-directory: immortalwrt
|
working-directory: wrt
|
||||||
run: |
|
run: |
|
||||||
echo "📦 更新 feeds"
|
echo "📦 更新 feeds"
|
||||||
./scripts/feeds update -a
|
./scripts/feeds update -a
|
||||||
@@ -76,50 +122,47 @@ jobs:
|
|||||||
|
|
||||||
- name: Setup configuration
|
- name: Setup configuration
|
||||||
run: |
|
run: |
|
||||||
echo "📋 校验并复制配置:${{ inputs.config_path }} → immortalwrt/.config"
|
echo "📋 复制配置:${{ inputs.config_path }} → wrt/.config"
|
||||||
cp diy.sh immortalwrt/diy.sh
|
|
||||||
if [ ! -f "${{ inputs.config_path }}" ]; then
|
if [ ! -f "${{ inputs.config_path }}" ]; then
|
||||||
echo "❌ 找不到配置文件:${{ inputs.config_path }}"
|
echo "❌ 找不到配置文件:${{ inputs.config_path }}"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
cp "${{ inputs.config_path }}" immortalwrt/.config
|
cp "${{ inputs.config_path }}" wrt/.config
|
||||||
cd immortalwrt
|
cd wrt
|
||||||
echo "🔄 运行 make oldconfig"
|
echo "🔄 运行 make oldconfig"
|
||||||
make oldconfig
|
make oldconfig
|
||||||
|
|
||||||
- name: Download source packages
|
- name: Download source packages
|
||||||
working-directory: immortalwrt
|
working-directory: wrt
|
||||||
run: |
|
run: |
|
||||||
echo "⬇️ 下载所有源码包"
|
echo "⬇️ 下载所有源码包"
|
||||||
make download -j8
|
make download -j8
|
||||||
|
|
||||||
- name: Run diy.sh
|
- name: Build Firmware
|
||||||
working-directory: immortalwrt
|
working-directory: wrt
|
||||||
run: |
|
|
||||||
echo "🔧 执行 diy.sh"
|
|
||||||
chmod +x diy.sh
|
|
||||||
./diy.sh
|
|
||||||
|
|
||||||
- name: Build ImmortalWrt
|
|
||||||
working-directory: immortalwrt
|
|
||||||
run: |
|
run: |
|
||||||
JOBS=$(nproc)
|
JOBS=$(nproc)
|
||||||
echo "🚀 开始全量编译(并行 ${JOBS})"
|
echo "🚀 全量编译(并行 ${JOBS})开始"
|
||||||
START=$(date "+%Y-%m-%d %H:%M:%S")
|
START=$(date "+%Y-%m-%d %H:%M:%S")
|
||||||
echo "⏱️ 编译开始于: ${START}"
|
echo "⏱️ 编译开始:${START}"
|
||||||
if ! time make world -j${JOBS} 2>&1 | tee build.log; then
|
if ! time make world -j${JOBS} 2>&1 | tee build.log; then
|
||||||
echo "❌ 编译失败,输出最后 100 行日志:"
|
echo "❌ 编译失败,输出最后 100 行日志:"
|
||||||
tail -n 100 build.log | sed 's/^/ /'
|
grep error ./build.log
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
END=$(date "+%Y-%m-%d %H:%M:%S")
|
END=$(date "+%Y-%m-%d %H:%M:%S")
|
||||||
echo "✅ 编译成功"
|
echo "✅ 编译成功"
|
||||||
echo "⏱️ 开始: ${START}"
|
echo "⏱️ 结束:${END}"
|
||||||
echo "⏱️ 结束: ${END}"
|
|
||||||
|
|
||||||
- name: Upload firmware artifacts
|
- name: Upload firmware artifacts
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: immortalwrt-output
|
name: ${{ inputs.project }}-output
|
||||||
path: |
|
path: |
|
||||||
immortalwrt/bin/targets/**/*.{img,bin,tar.gz,zip}
|
wrt/bin/targets/**/*.{img,bin,tar.gz,zip}
|
||||||
|
|
||||||
|
- name: Upload build log
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: ${{ inputs.project }}-build-log
|
||||||
|
path: wrt/build.log
|
||||||
|
|||||||
8
diy.sh
8
diy.sh
@@ -5,12 +5,12 @@ set -e
|
|||||||
echo "🚀 添加自定义 feed 源..."
|
echo "🚀 添加自定义 feed 源..."
|
||||||
|
|
||||||
# feeds.conf.default 文件存在才操作
|
# feeds.conf.default 文件存在才操作
|
||||||
FEEDS_CONF="feeds.conf.default"
|
#FEEDS_CONF="feeds.conf.default"
|
||||||
if [ -f "$FEEDS_CONF" ]; then
|
#if [ -f "$FEEDS_CONF" ]; then
|
||||||
# 示例:添加常见 feed(你可按需修改或注释掉)
|
# 示例:添加常见 feed(你可按需修改或注释掉)
|
||||||
# grep -q '^src-git helloworld' "$FEEDS_CONF" || echo 'src-git helloworld https://github.com/fw876/helloworld' >>"$FEEDS_CONF"
|
# grep -q '^src-git helloworld' "$FEEDS_CONF" || echo 'src-git helloworld https://github.com/fw876/helloworld' >>"$FEEDS_CONF"
|
||||||
# grep -q '^src-git passwall' "$FEEDS_CONF" || echo 'src-git passwall https://github.com/xiaorouji/openwrt-passwall' >>"$FEEDS_CONF"
|
# grep -q '^src-git passwall' "$FEEDS_CONF" || echo 'src-git passwall https://github.com/xiaorouji/openwrt-passwall' >>"$FEEDS_CONF"
|
||||||
fi
|
#fi
|
||||||
|
|
||||||
echo "✅ feeds 添加完成"
|
echo "✅ feeds 添加完成"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user