mirror of
https://github.com/Dichgrem/Dwrt-build.git
synced 2025-12-16 21:51:59 -05:00
feat:free_space
This commit is contained in:
76
.github/workflows/build.yml
vendored
76
.github/workflows/build.yml
vendored
@@ -51,6 +51,24 @@ jobs:
|
|||||||
- name: Checkout current repository
|
- name: Checkout current repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Free up disk space
|
||||||
|
run: |
|
||||||
|
echo "🧹 开始清理无用文件,释放磁盘空间"
|
||||||
|
# 删除预装但编译中不需要的 SDK/工具
|
||||||
|
sudo rm -rf /usr/share/dotnet \
|
||||||
|
/usr/local/lib/android \
|
||||||
|
/opt/ghc \
|
||||||
|
/opt/hostedtoolcache \
|
||||||
|
/opt/az \
|
||||||
|
/opt/microsoft
|
||||||
|
# 删除 GitHub Actions self-hosted runner 缓存目录(如果存在)
|
||||||
|
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
|
||||||
|
# 删除系统缓存和日志
|
||||||
|
sudo rm -rf /var/cache/apt/archives/* /var/lib/apt/lists/* /var/log/*.log
|
||||||
|
# 显示当前磁盘使用情况
|
||||||
|
echo "📊 磁盘使用情况:"
|
||||||
|
df -h || true
|
||||||
|
|
||||||
- name: Determine Git ref
|
- name: Determine Git ref
|
||||||
id: refinfo
|
id: refinfo
|
||||||
run: |
|
run: |
|
||||||
@@ -108,15 +126,11 @@ jobs:
|
|||||||
echo "🔖 切换到版本:${{ steps.refinfo.outputs.ref }}"
|
echo "🔖 切换到版本:${{ steps.refinfo.outputs.ref }}"
|
||||||
git checkout "${{ steps.refinfo.outputs.ref }}"
|
git checkout "${{ steps.refinfo.outputs.ref }}"
|
||||||
|
|
||||||
- name: Copy diy.sh
|
- name: Copy and Run diy.sh
|
||||||
run: |
|
run: |
|
||||||
echo "📂 复制 diy.sh 到 wrt 目录"
|
echo "📂 复制 diy.sh 到 wrt 目录并执行"
|
||||||
cp diy.sh wrt/diy.sh
|
cp diy.sh wrt/diy.sh
|
||||||
|
cd wrt
|
||||||
- name: Run diy.sh
|
|
||||||
working-directory: wrt
|
|
||||||
run: |
|
|
||||||
echo "🔧 执行 diy.sh"
|
|
||||||
chmod +x diy.sh
|
chmod +x diy.sh
|
||||||
./diy.sh
|
./diy.sh
|
||||||
|
|
||||||
@@ -135,37 +149,31 @@ jobs:
|
|||||||
echo "❌ 找不到配置文件:${{ inputs.config_path }}"
|
echo "❌ 找不到配置文件:${{ inputs.config_path }}"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cp "${{ inputs.config_path }}" wrt/.config
|
cp "${{ inputs.config_path }}" wrt/.config
|
||||||
|
|
||||||
# 校验 .config 是否与原始配置完全相同
|
|
||||||
if cmp -s "${{ inputs.config_path }}" wrt/.config; then
|
|
||||||
echo "✅ .config 与 ${{ inputs.config_path }} 完全一致"
|
|
||||||
else
|
|
||||||
echo "❌ .config 与 ${{ inputs.config_path }} 不一致,输出差异:"
|
|
||||||
diff -u "${{ inputs.config_path }}" wrt/.config || true
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
cd wrt
|
cd wrt
|
||||||
|
|
||||||
|
echo "📑 备份配置文件以供对比"
|
||||||
|
cp .config .config.before_oldconfig
|
||||||
|
|
||||||
echo "🔄 运行 make oldconfig"
|
echo "🔄 运行 make oldconfig"
|
||||||
make oldconfig
|
make oldconfig
|
||||||
|
|
||||||
|
echo "🔍 对比 make oldconfig 前后的 .config 差异"
|
||||||
|
if cmp -s .config.before_oldconfig .config; then
|
||||||
|
echo "✅ .config 在 make oldconfig 后未发生变化"
|
||||||
|
else
|
||||||
|
echo "⚠️ .config 在 make oldconfig 后发生变化,差异如下:"
|
||||||
|
diff -u .config.before_oldconfig .config || true
|
||||||
|
fi
|
||||||
|
|
||||||
- name: Download source packages
|
- name: Download source packages
|
||||||
working-directory: wrt
|
working-directory: wrt
|
||||||
run: |
|
run: |
|
||||||
echo "⬇️ 下载所有源码包"
|
echo "⬇️ 下载所有源码包(使用单线程 -j1 避免卡住)"
|
||||||
|
|
||||||
if [ "${{ inputs.threads }}" = "0" ] || [ -z "${{ inputs.threads }}" ]; then
|
|
||||||
JOBS=$(nproc)
|
|
||||||
else
|
|
||||||
JOBS=${{ inputs.threads }}
|
|
||||||
fi
|
|
||||||
|
|
||||||
set -o pipefail
|
set -o pipefail
|
||||||
if ! make download -j${JOBS}; then
|
time make download -j1
|
||||||
echo "⚠️ 多线程下载失败,尝试单线程下载..."
|
|
||||||
make download -j1
|
|
||||||
fi
|
|
||||||
|
|
||||||
- name: Build Firmware
|
- name: Build Firmware
|
||||||
working-directory: wrt
|
working-directory: wrt
|
||||||
@@ -208,16 +216,16 @@ jobs:
|
|||||||
echo "❗ wrt/bin/targets 目录不存在"
|
echo "❗ wrt/bin/targets 目录不存在"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: Upload firmware artifacts
|
- name: Upload build artifacts
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: ${{ inputs.project }}-output
|
name: ${{ inputs.project }}-output
|
||||||
path: |
|
path: |
|
||||||
wrt/bin/targets/**/*.img
|
wrt/bin/targets/**
|
||||||
wrt/bin/targets/**/*.bin
|
!wrt/bin/targets/x86/64/packages/**
|
||||||
wrt/bin/targets/**/*.tar.gz
|
if-no-files-found: warn
|
||||||
wrt/bin/targets/**/*.zip
|
compression-level: 6
|
||||||
if-no-files-found: warning
|
overwrite: false
|
||||||
|
|
||||||
- name: Upload build log
|
- name: Upload build log
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v4
|
||||||
|
|||||||
Reference in New Issue
Block a user