编译OpenWrt固件r66s-6 #21
This file contains 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
# | |
# Copyright (c) 2019-2020 P3TERX <https://p3terx.com> | |
# | |
# This is free software, licensed under the MIT License. | |
# See /LICENSE for more information. | |
# | |
# https://github.com/P3TERX/Actions-OpenWrt | |
# Description: Build OpenWrt using GitHub Actions | |
name: 编译OpenWrt固件r66s-6 | |
on: | |
repository_dispatch: | |
workflow_dispatch: | |
inputs: | |
ssh: | |
description: 'SSH connection to Actions' | |
required: false | |
default: 'false' | |
# 定时触发编译(每月1日早3点) | |
schedule: | |
- cron: 0 17 2,12,22 * * | |
env: | |
REPO_URL: https://github.com/coolsnowwolf/lede | |
REPO_BRANCH: master | |
FEEDS_CONF: feeds.conf.default | |
CONFIG_FILE: r66s/6.1/config/r66s.config | |
DIY_P1_SH: r66s/6.1/diy-part1.sh | |
DIY_P2_SH: r66s/6.1/diy-part2.sh | |
UPLOAD_BIN_DIR: false | |
UPLOAD_FIRMWARE: true | |
UPLOAD_RELEASE: true | |
GITHUB_TOKEN: ${{ secrets.GIT_USER_TOKEN }} | |
TZ: Asia/Shanghai | |
KERNEL_VERSION: 6.1.79 | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: 释放Ubuntu磁盘空间 | |
uses: jlumbroso/free-disk-space@main | |
with: | |
# this might remove tools that are actually needed, | |
# if set to "true" but frees about 6 GB | |
tool-cache: true | |
# all of these default to true, but feel free to set to | |
# "false" if necessary for your workflow | |
android: true | |
dotnet: true | |
haskell: true | |
large-packages: true | |
swap-storage: true | |
- name: CPU检测 | |
run: | | |
echo "警告⚠" | |
echo "分配的服务器性能有限,若选择的插件过多,务必注意CPU性能!" | |
echo -e "已知CPU型号(降序): 7763,8370C,8272CL,8171M,E5-2673\n" | |
echo "--------------------------CPU信息--------------------------" | |
echo "CPU物理数量: $(cat /proc/cpuinfo | grep "physical id" | sort | uniq | wc -l)" | |
echo "CPU核心数量: $(nproc)" | |
echo -e "CPU型号信息:$(cat /proc/cpuinfo | grep -m1 name | awk -F: '{print $2}')\n" | |
echo "--------------------------内存信息--------------------------" | |
echo "已安装内存详细信息:" | |
echo -e "$(sudo lshw -short -C memory | grep GiB)\n" | |
echo "--------------------------硬盘信息--------------------------" | |
echo "硬盘数量: $(ls /dev/sd* | grep -v [1-9] | wc -l)" && df -hT | |
- name: 准备完成 | |
uses: actions/checkout@main | |
- name: 初始化系统环境 | |
env: | |
DEBIAN_FRONTEND: noninteractive | |
run: | | |
sudo rm -rf /etc/apt/sources.list.d/* /usr/share/dotnet /usr/local/lib/android /opt/ghc /opt/hostedtoolcache/CodeQL | |
sudo docker image prune --all --force | |
sudo -E apt-get -qq update | |
sudo -E apt-get -qq install $(curl -fsSL https://github.com/popeyema/OpenWrt-R66s/raw/main/depends-ubuntu-latest) | |
sudo -E apt-get -qq autoremove --purge | |
sudo -E apt-get -qq clean | |
sudo timedatectl set-timezone "$TZ" | |
sudo mkdir -p /workdir | |
sudo chown $USER:$GROUPS /workdir | |
- name: 下载源代码 | |
working-directory: /workdir | |
run: | | |
df -hT $PWD | |
git clone $REPO_URL -b $REPO_BRANCH openwrt | |
ln -sf /workdir/openwrt $GITHUB_WORKSPACE/openwrt | |
- name: 更新时区、编译时间 | |
id: date | |
run: | | |
sudo timedatectl set-timezone "$TZ" | |
echo "FILE_TIME=$(date +"%m-%d %H.%M")" >> $GITHUB_ENV | |
echo "FILE_TIME1=$(date "+%Y年%m月%d日-%H点%M分")" >> $GITHUB_ENV | |
echo "FILE_TIME2=$(date "+%Y%m%d-%H%M")" >> $GITHUB_ENV | |
echo "编译开始时间..." | |
START_TIME=`date +'%Y-%m-%d %H:%M:%S'` | |
echo "START_SECONDS=$(date --date="$START_TIME" +%s)" >> $GITHUB_ENV | |
- name: patch1补丁和自定义设置 | |
run: | | |
[ -e $FEEDS_CONF ] && mv $FEEDS_CONF openwrt/feeds.conf.default | |
chmod +x $DIY_P1_SH | |
cd openwrt | |
$GITHUB_WORKSPACE/$DIY_P1_SH | |
- name: 更新源 #Update feeds | |
run: cd openwrt && ./scripts/feeds update -a | |
- name: 安装源 #Install feeds | |
run: cd openwrt && ./scripts/feeds install -a | |
- name: patch2补丁和自定义设置 | |
run: | | |
[ -e files ] && mv files openwrt/files | |
[ -e $CONFIG_FILE ] && mv $CONFIG_FILE openwrt/.config | |
chmod +x $DIY_P2_SH | |
cd openwrt | |
$GITHUB_WORKSPACE/$DIY_P2_SH | |
- name: SSH connection to Actions | |
uses: P3TERX/ssh2actions@v1.0.0 | |
if: (github.event.inputs.ssh == 'true' && github.event.inputs.ssh != 'false') || contains(github.event.action, 'ssh') | |
env: | |
TELEGRAM_CHAT_ID: ${{ secrets.TELEGRAM_CHAT_ID }} | |
TELEGRAM_BOT_TOKEN: ${{ secrets.TELEGRAM_BOT_TOKEN }} | |
- name: 输出编译信息 | |
run: | | |
cd openwrt | |
echo " 系统空间 类型 总数 已用 可用 使用率" | |
df -hT $PWD | |
echo | |
echo "==========================================" | |
echo | |
ZZZ="package/lean/default-settings/files/zzz-default-settings" | |
echo "DISTRIB_REVISION=$(cat $ZZZ|grep DISTRIB_REVISION= | sed 's/^.\{24\}//g' | sed 's/.\{26\}$//')" >> $GITHUB_ENV | |
echo "KERNEL_PATCHVER=$(cat target/linux/rockchip/Makefile|grep KERNEL_PATCHVER | sed 's/^.\{17\}//g')" >> $GITHUB_ENV | |
echo " 当前编译版本:$(cat $ZZZ|grep DISTRIB_REVISION= | sed 's/^.\{24\}//g' | sed 's/.\{26\}$//')" | |
echo " 内核版本:$(cat target/linux/rockchip/Makefile|grep KERNEL_PATCHVER | sed 's/^.\{17\}//g')" | |
echo | |
echo "==========================================" | |
grep -i CONFIG_PACKAGE_luci-app .config | grep -v \# > Plug-in | |
grep -i CONFIG_PACKAGE_luci-theme .config | grep -v \# >> Plug-in | |
sed -i '/INCLUDE/d' Plug-in > /dev/null 2>&1 | |
sed -i 's/CONFIG_PACKAGE_/、/g' Plug-in | |
sed -i '/Transparent_Proxy/d' Plug-in > /dev/null 2>&1 #排除 luci-app-passwall_Transparent_Proxy | |
sed -i '/qbittorrent-simple_dynamic/d' Plug-in > /dev/null 2>&1 #排除 luci-app-qbittorrent-simple_dynamic | |
sed -i 's/=y/\ /g' Plug-in | |
awk '$0=NR$0' Plug-in > Plug-2 | |
awk '{print " " $0}' Plug-2 > Plug-in | |
echo | |
echo | |
echo " 已选插件列表" | |
cat Plug-in | |
rm -rf {Plug-in,Plug-2} | |
echo | |
echo "==========================================" | |
echo | |
echo | |
echo "输出完整插件信息..." | |
echo | |
echo | |
cat .config | |
- name: 下载固件包 | |
id: package | |
run: | | |
cd openwrt | |
make defconfig | |
make download -j8 | |
find dl -size -1024c -exec ls -l {} \; | |
find dl -size -1024c -exec rm -f {} \; | |
- name: 开始编译固件 | |
id: compile | |
run: | | |
cd openwrt | |
echo -e "$(nproc) thread compile" | |
make -j$(nproc) || make -j1 || make -j1 V=s | |
echo "status=success" >> $GITHUB_OUTPUT | |
grep '^CONFIG_TARGET.*DEVICE.*=y' .config | sed -r 's/.*DEVICE_(.*)=y/\1/' > DEVICE_NAME | |
[ -s DEVICE_NAME ] && echo "DEVICE_NAME=_$(cat DEVICE_NAME)" >> $GITHUB_ENV | |
echo "FILE_DATE=_$(date +"%Y%m%d%H%M")" >> $GITHUB_ENV | |
- name: 检查空间使用情况 | |
run: | | |
echo "==========================================" | |
echo "----------------空间使用-------------------" | |
echo "==========================================" | |
echo " 系统空间 类型 总数 已用 可用 使用率" | |
df -hT | |
echo "==========================================" | |
du -h --max-depth=1 openwrt/ --exclude=build_dir --exclude=bin | |
du -h --max-depth=1 openwrt/build_dir | |
du -h --max-depth=1 openwrt/bin | |
- name: Package OpenWrt Firmware | |
uses: ophub/flippy-openwrt-actions@main | |
env: | |
OPENWRT_ARMVIRT: openwrt/bin/targets/*/*/*.tar.gz | |
PACKAGE_SOC: r66s | |
KERNEL_VERSION_NAME: ${{ env.KERNEL_VERSION }} | |
KERNEL_AUTO_LATEST: true | |
- name: 整理固件文件 | |
id: organize | |
if: env.UPLOAD_FIRMWARE == 'true' && !cancelled() | |
run: | | |
cd openwrt/bin/targets/*/* | |
rm -rf packages openwrt-armvirt-64-default.manifest openwrt-armvirt-64-Image sha256sums version.buildinfo feeds.buildinfo openwrt-armvirt-64-generic-kernel.bin openwrt-armvirt-64-generic.manifest | |
echo "FIRMWARE=$PWD" >> $GITHUB_ENV | |
echo "status=success" >> $GITHUB_OUTPUT | |
- name: 上传固件目录 | |
uses: actions/upload-artifact@main | |
if: steps.organize.outputs.status == 'success' && !cancelled() | |
with: | |
name: OpenWrt_firmware${{ env.DEVICE_NAME }}${{ env.FILE_DATE }} | |
path: ${{ env.FIRMWARE }} | |
- name: 生成发布标签 | |
id: tag | |
if: env.UPLOAD_RELEASE == 'true' && !cancelled() | |
run: | | |
echo "release_tag=$(date +"%Y.%m.%d")" >> $GITHUB_OUTPUT | |
echo "release_date=$(date +"%Y.%m.%d")" >> $GITHUB_OUTPUT | |
touch release.txt | |
echo " | |
★ 源码 : https://github.com/coolsnowwolf/lede | |
★ 分支 : master | |
★ 感谢源码作者无私分享! | |
⏰ 编译时间:${{ env.FILE_TIME1 }} | |
🎈 内核版本:${{ env.KERNEL_VERSION }} | |
🎉 编译版本:${{ env.DISTRIB_REVISION }} | |
🖥 管理地址:192.168.1.1 | |
🌴 名称:root | |
🛠 密码:password" >> release.txt | |
echo "status=success" >> $GITHUB_OUTPUT | |
- name: 自动发布固件到 Releases | |
uses: softprops/action-gh-release@master | |
if: steps.tag.outputs.status == 'success' && !cancelled() | |
env: | |
GITHUB_TOKEN: ${{ secrets.GIT_USER_TOKEN }} | |
with: | |
name: ${{ steps.tag.outputs.release_date }} FastRhino-R66S-linux-固件下载 | |
tag_name: ${{ steps.tag.outputs.release_tag }} | |
body_path: release.txt | |
files: ${{ env.FIRMWARE }}/*.img.gz | |
- name: 删除运行记录 | |
uses: Mattraks/delete-workflow-runs@main | |
continue-on-error: true | |
with: | |
retain_days: 3 #保留最后多少记录不删除 | |
keep_minimum_runs: 0 | |
- name: 删除自动发布的旧固件 | |
uses: dev-drprasad/delete-older-releases@master | |
continue-on-error: true | |
if: env.UPLOAD_RELEASE == 'true' && !cancelled() | |
with: | |
keep_latest: 20 #保留多少个releases不删除 | |
delete_tags: true | |
env: | |
GITHUB_TOKEN: ${{ secrets.GIT_USER_TOKEN }} |