Skip to content

20241102

20241102 #78

name: Build x86_64_5.10
on:
repository_dispatch:
workflow_dispatch:
# schedule:
# - cron: '0 18 * * 5'
# watch:
# types: started
env:
REPO_URL: https://github.com/coolsnowwolf/lede
REPO_BRANCH: master
FEEDS_CONF: feeds.conf.default
CONFIG_FILE: x86_64.config
DIY_P1_SH: diy-part1.sh
DIY_P2_SH: diy-part2_5.10.sh
REVERT_COMMIT: false
UPLOAD_FIRMWARE: false
UPLOAD_RELEASE: true
TZ: Asia/Shanghai
jobs:
build:
runs-on: ubuntu-latest
timeout-minutes: 360
name: Build ${{ matrix.target.arch }}_${{ matrix.target.kernel }}
strategy:
fail-fast: false
matrix:
target:
- arch: "x86_64"
target: "x86"
kernel: "5.10"
steps:
- name: 检查
uses: actions/checkout@main
- name: 释放磁盘空间
uses: jlumbroso/free-disk-space@main
with:
tool-cache: false
android: true
dotnet: true
haskell: true
large-packages: true
docker-images: true
swap-storage: true
- name: 初始化环境
env:
DEBIAN_FRONTEND: noninteractive
run: |
sudo -E rm -rf "$AGENT_TOOLSDIRECTORY" || true
sudo -E apt -yqq update
sudo -E apt -yqq full-upgrade
sudo -E apt -yqq install $(curl -fsSL https://raw.githubusercontent.com/ywt114/diy/main/depends | tr '\n' ' ') || true
sudo -E apt -yqq autoremove --purge
sudo -E apt -yqq autoclean
sudo -E systemctl daemon-reload
df -hT
- name: 设置当前的日期
id: date
run: |
sudo timedatectl set-timezone "$TZ"
echo "date1=$(date +'%Y%m%d')" >> $GITHUB_ENV
- name: 克隆源代码
run: |
git clone -b $REPO_BRANCH $REPO_URL openwrt
sed -i "s/KERNEL_PATCHVER:=*.*/KERNEL_PATCHVER:=${{ matrix.target.kernel }}/g" openwrt/target/linux/${{ matrix.target.target }}/Makefile
sed -i "s/KERNEL_TESTING_PATCHVER:=*.*/KERNEL_TESTING_PATCHVER:=${{ matrix.target.kernel }}/g" openwrt/target/linux/${{ matrix.target.target }}/Makefile
- name: 自定义配置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: 更新 feeds
working-directory: ./openwrt
run: |
./scripts/feeds update -a
- name: 执行回滚
if: env.REVERT_COMMIT == 'true' && !cancelled()
run: |
cd $(curl -fsSL https://raw.githubusercontent.com/ywt114/diy/main/directory | tr '\n' ' ')
git reset --hard $(curl -fsSL https://raw.githubusercontent.com/ywt114/diy/main/commit | tr '\n' ' ')
- name: 安装 feeds
working-directory: ./openwrt
run: |
./scripts/feeds install -a
- name: 自定义配置
run: |
[ -e $CONFIG_FILE ] && mv $CONFIG_FILE openwrt/.config
chmod +x $DIY_P2_SH
cd openwrt
$GITHUB_WORKSPACE/$DIY_P2_SH
- name: 下载包文件
id: package
working-directory: ./openwrt
run: |
make defconfig
make download -j$(($(nproc)+1))
find dl -size -1024c -exec ls -l {} \;
find dl -size -1024c -exec rm -f {} \;
- name: 缓存
uses: stupidloud/cachewrtbuild@main
with:
ccache: 'true'
prefix: 'openwrt'
- name: 编译前空间情况
if: (!cancelled())
run: |
df -hT
- name: 编译固件
id: compile
working-directory: ./openwrt
run: |
echo -e "$(($(nproc)+1)) thread compile"
make -j$(($(nproc)+1)) || make -j1 V=s
tree bin/
echo "status=success" >> $GITHUB_OUTPUT
- name: 编译后空间情况
if: steps.compile.outputs.status == 'success' && !cancelled()
run: |
df -hT
- name: 重命名文件
if: steps.compile.outputs.status == 'success' && !cancelled()
run: |
find openwrt/bin/targets -type f \( -name "openwrt*.gz" \) -exec sh -c 'mv "$1" "$(dirname "$1")/${{ env.date1 }}-${{ matrix.target.kernel }}-$(basename "$1")"' sh {} \; 2>/dev/null || true
- name: 整理文件
id: organize
if: steps.compile.outputs.status == 'success' && !cancelled()
run: |
mkdir -p firmware
mkdir -p firmware/package/
find openwrt/bin/targets/ -type f \( -name "*squashfs-combined*.gz" -o -name "*sysupgrade*" \) -exec mv {} ./firmware/ \; 2>/dev/null || true
find openwrt/bin/packages/ -type f \( -name "*.ipk" \) -exec mv {} ./firmware/package/ \; 2>/dev/null || true
mv openwrt/.config ./firmware/${{ matrix.target.arch }}_${{ matrix.target.kernel }}.config 2>/dev/null || true
mv openwrt/build_dir/target-*/linux-*/linux-*/.config ./firmware/${{ matrix.target.arch }}_${{ matrix.target.kernel }}_kernel.config 2>/dev/null || true
[ -e release ] && cp release ./firmware/release.txt
cd firmware
echo -n "${{ env.date1 }}" > version.txt
md5=$(md5sum *squashfs-combined.img.gz | awk '{print $1}') 2>/dev/null || true
md5_efi=$(md5sum *squashfs-combined-efi.img.gz | awk '{print $1}') 2>/dev/null || true
echo "md5=$md5" > md5sum.txt
echo "md5_efi=$md5_efi" >> md5sum.txt
rm -rf sha256sums
echo "status=success" >> $GITHUB_OUTPUT
- name: 上传artifact固件目录
uses: actions/upload-artifact@main
if: steps.organize.outputs.status == 'success' && env.UPLOAD_FIRMWARE == 'true' && !cancelled()
with:
name: ${{ env.date1 }}_${{ matrix.target.arch }}_${{ matrix.target.kernel }}
path: ./firmware/**
- name: 生成releases发布标签
id: tag
if: steps.organize.outputs.status == 'success' && env.UPLOAD_RELEASE == 'true' && !cancelled()
run: |
echo "release_tag=${{ env.date1 }}" >> $GITHUB_OUTPUT
[ -e release ] && cp release ./release.txt
echo "status=success" >> $GITHUB_OUTPUT
- name: 上传releases固件发布
uses: softprops/action-gh-release@master
if: steps.organize.outputs.status == 'success' && env.UPLOAD_RELEASE == 'true' && !cancelled()
env:
GITHUB_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
with:
files: ./firmware/*.*
name: ${{ env.date1 }}_${{ matrix.target.arch }}_${{ matrix.target.kernel }}
tag_name: ${{ matrix.target.arch }}_${{ matrix.target.kernel }}
body_path: release.txt
- name: 删除workflow工作流
uses: Mattraks/delete-workflow-runs@main
with:
token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
repository: ${{ github.repository }}
retain_days: 1
keep_minimum_runs: 1
- name: 删除releases旧版本
uses: dev-drprasad/delete-older-releases@master
if: env.UPLOAD_RELEASE == 'true' && !cancelled()
env:
GITHUB_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
with:
keep_latest: 5
delete_tags: true