OpenWrt相关代码更新 #2338
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-2023 Jason6111 | |
# | |
# This is free software, licensed under the MIT License. | |
# See /LICENSE for more information. | |
# | |
# https://github.com/Jason6111/OpenWrt_Personal | |
# Description: Build OpenWrt using GitHub Actions | |
# | |
name: Openwrt-X86 | |
on: | |
repository_dispatch: | |
workflow_dispatch: | |
# inputs: | |
# ssh: | |
# description: 'SSH connection to Actions' | |
# required: false | |
# default: 'false' | |
#周日22时 CN周一6时 | |
# schedule: | |
# - cron: 0 22 * * 0 | |
env: | |
REPO_URL: https://github.com/coolsnowwolf/lede | |
REPO_BRANCH: master | |
FEEDS_CONF: feeds.conf.default | |
CONFIG_FILE: config/X86.config | |
DIY_P1_SH: diy_script/diy-part1.sh | |
DIY_P2_SH: diy_script/diy-part2.sh | |
COMMIT_LOG_NUM: 1 | |
RELEASE_TAG: 18.06-X86 | |
UPLOAD_BIN_DIR: false | |
UPLOAD_FIRMWARE: true | |
UPLOAD_COWTRANSFER: false | |
UPLOAD_WETRANSFER: false | |
UPLOAD_RELEASE: true | |
SERVERCHAN_SCKEY: true | |
TZ: Asia/Shanghai | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: 检查服务器性能 #Check Server Performance | |
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 -e "CPU核心信息:$(cat /proc/cpuinfo | grep name | cut -f2 -d: | uniq -c) \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: 精简系统释放磁盘空间 (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: false | |
docker-images: true | |
swap-storage: true | |
- name: 检查准备 #Checkout | |
uses: actions/checkout@main | |
with: | |
fetch-depth: 0 | |
- name: TG信息通知 | |
if: ${{ success() }} | |
run: | | |
curl -k --data chat_id=${{ secrets.TGID }} --data "text=主人:正在使用$(cat /proc/cpuinfo | grep name | cut -f2 -d: | uniq -c | sed 's/^\s*//')为您编译新的$RELEASE_TAG,请耐心等待...... 😋💐,务必注意CPU性能!已知CPU型号(降序):7763,8370C,8272CL,8171M,E5-2673." "https://api.telegram.org/bot${{ secrets.TG_TOKEN }}/sendMessage" | |
- name: PushDeer信息通知 | |
if: ${{ success() }} | |
run: | | |
curl -k --data pushkey="${{ secrets.pushkey }}" --data "text=主人:正在使用$(cat /proc/cpuinfo | grep name | cut -f2 -d: | uniq -c | sed 's/^\s*//')为您编译新的$RELEASE_TAG,请耐心等待...... 😋💐" "https://"${{ secrets.pushserve }}"/message/push?" | |
#- name: PUSHPLUS信息通知 | |
# if: ${{ success() }} | |
# run: | | |
# curl -k --data token="${{ secrets.PUSH_PLUS_TOKEN }}" --data title="开始编译$RELEASE_TAG" --data "content=🎉 主人:正在为您编译新的$RELEASE_TAG,请耐心等待...... 😋💐" "http://www.pushplus.plus/send" | |
- name: 开始安装编译所需系统 #Initialization environment | |
env: | |
DEBIAN_FRONTEND: noninteractive | |
run: | | |
sudo rm -rf /etc/apt/sources.list.d/* /usr/share/dotnet /usr/local/lib/android /opt/ghc | |
sudo -E apt-get -qq update | |
sudo -E apt-get -qq full-upgrade | |
sudo -E apt-get -qq install $(curl -fsSL https://github.com/Jason6111/OpenWrt_Personal/raw/main/depends-ubuntu-2004) | |
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: 下载固件源码 #Clone source code | |
working-directory: /workdir | |
run: | | |
df -hT $PWD | |
git clone $REPO_URL -b $REPO_BRANCH openwrt | |
ln -sf /workdir/openwrt $GITHUB_WORKSPACE/openwrt | |
- name: 缓存 #Cache | |
uses: Jason6111/cachewrtbuild@main | |
with: | |
ccache: 'true' | |
prefix: ${{ github.workspace }}/openwrt | |
- name: patch1补丁和自定义设置 #Load custom 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: 更新源 #Update feeds | |
run: cd openwrt && ./scripts/feeds update -a | |
- name: 安装源 #Install feeds | |
run: cd openwrt && ./scripts/feeds install -a | |
- name: patch2补丁和自定义设置 #Load custom configuration | |
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 | |
cd .. | |
platforms=("X86") | |
for i in "${platforms[@]}"; do | |
[ -e config/$i.config ] && cp -r config/$i.config openwrt/.config | |
cd openwrt | |
make defconfig | |
cd .. | |
cp -f openwrt/.config config/$i.config | |
done | |
- name: 自动更新config #Git auto update config | |
uses: stefanzweifel/[email protected] | |
id: commit | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
commit_message: 自动更新config | |
branch: main | |
commit_author: Jason6111 | |
# - name: SSH connection to Actions | |
# uses: P3TERX/[email protected] | |
# 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: 下载软件包 #Download package | |
id: package | |
run: | | |
cd openwrt | |
make download -j8 | |
find dl -size -1024c -exec ls -l {} \; | |
find dl -size -1024c -exec rm -f {} \; | |
#- name: netdata温控检测 | |
# run: | | |
# cd openwrt | |
# tar -xzvf dl/netdata-v1.33.1.tar.gz | |
# sed -i 's/# sensors=force/sensors=force/' ./netdata-v1.33.1/collectors/charts.d.plugin/charts.d.conf | |
# tar -czvf dl/netdata-v1.33.1.tar.gz netdata-v1.33.1 | |
# rm -rf netdata-v1.33.1 | |
# sha256sum dl/netdata-v1.33.1.tar.gz | awk '{print $1}' > checksum.txt | |
# sed -i "s/20ba8695d87187787b27128ac3aab9b09aa29ca6b508c48542e0f7d50ec9322b/$(cat checksum.txt)/" ./feeds/packages/admin/netdata/Makefile | |
- name: 开始编译固件 #Compile the firmware | |
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: 检查空间使用情况 #Check space usage | |
if: (!cancelled()) | |
run: df -hT | |
# - name: 上传bin目录 | |
# uses: actions/upload-artifact@main | |
# if: steps.compile.outputs.status == 'success' && env.UPLOAD_BIN_DIR == 'true' | |
# with: | |
# name: OpenWrt_bin${{ env.DEVICE_NAME }}${{ env.FILE_DATE }} | |
# path: openwrt/bin | |
- name: 获取内核版本号 | |
run: | | |
cd openwrt/bin/targets/x86/64 | |
KERNEL_VERSION=$(ls -l *openwrt-x86-64-generic-kernel.bin | awk '{print $9}' | cut -d '-' -f1) | |
echo "KERNEL_VERSION=$KERNEL_VERSION" >> $GITHUB_ENV | |
- name: 整理固件文件夹 #Organize files | |
id: organize | |
if: env.UPLOAD_FIRMWARE == 'true' && !cancelled() | |
run: | | |
cd openwrt/bin/targets/*/* | |
rm -rf packages | |
rm -rf profiles.json feeds.buildinfo config.buildinfo *openwrt-x86-64-generic-kernel.bin *openwrt-x86-64-generic-squashfs-rootfs.img.gz *openwrt-x86-64-generic.manifest sha256sums version.buildinfo | |
for file in *-openwrt-x86-64-generic-squashfs-combined-efi.img.gz; do | |
mv "$file" "18.06-$file" | |
done | |
echo "FIRMWARE=$PWD" >> $GITHUB_ENV | |
echo "status=success" >> $GITHUB_OUTPUT | |
- name: 上传固件目录 #Upload firmware directory | |
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: Upload firmware to cowtransfer | |
# id: cowtransfer | |
# if: steps.organize.outputs.status == 'success' && env.UPLOAD_COWTRANSFER == 'true' && !cancelled() | |
# run: | | |
# curl -fsSL git.io/file-transfer | sh | |
# ./transfer cow --block 2621440 -s -p 64 --no-progress ${FIRMWARE} 2>&1 | tee cowtransfer.log | |
# echo "::warning file=cowtransfer.com::$(cat cowtransfer.log | grep https)" | |
# echo "url=$(cat cowtransfer.log | grep https | cut -f3 -d" ")" >> $GITHUB_OUTPUT | |
# - name: Upload firmware to WeTransfer | |
# id: wetransfer | |
# if: steps.organize.outputs.status == 'success' && env.UPLOAD_WETRANSFER == 'true' && !cancelled() | |
# run: | | |
# curl -fsSL git.io/file-transfer | sh | |
# ./transfer wet -s -p 16 --no-progress ${FIRMWARE} 2>&1 | tee wetransfer.log | |
# echo "::warning file=wetransfer.com::$(cat wetransfer.log | grep https)" | |
# echo "url=$(cat wetransfer.log | grep https | cut -f3 -d" ")" >> $GITHUB_OUTPUT | |
- name: 生成发布标签 #Generate release tag | |
id: tag | |
if: env.UPLOAD_RELEASE == 'true' && !cancelled() | |
run: | | |
echo "release_tag=$RELEASE_TAG-$KERNEL_VERSION-$(date +"%Y.%m.%d-%H%M")" >> $GITHUB_OUTPUT | |
touch release.txt | |
[ $UPLOAD_COWTRANSFER = true ] && echo "🔗 [Cowtransfer](${{ steps.cowtransfer.outputs.url }})" >> release.txt | |
[ $UPLOAD_WETRANSFER = true ] && echo "🔗 [WeTransfer](${{ steps.wetransfer.outputs.url }})" >> release.txt | |
echo "status=success" >> $GITHUB_OUTPUT | |
echo "## 更新内容" >> release.txt | |
echo "<details> <summary> Lean Openwrt Commit Top $COMMIT_LOG_NUM </summary>" >> release.txt | |
git -C openwrt log -n $COMMIT_LOG_NUM >> release.txt | |
echo "</details> <details> <summary> Lean Package Commit Top $COMMIT_LOG_NUM </summary>" >> release.txt | |
git -C openwrt/feeds/packages log -n $COMMIT_LOG_NUM >> release.txt | |
echo "</details> <details> <summary> Lean Luci Commit Top $COMMIT_LOG_NUM </summary>" >> release.txt | |
git -C openwrt/feeds/luci log -n $COMMIT_LOG_NUM >> release.txt | |
echo "</details> <details> <summary> SSRP Commit Top $COMMIT_LOG_NUM </summary>" >> release.txt | |
git -C openwrt/feeds/helloworld log -n $COMMIT_LOG_NUM >> release.txt | |
- name: 上传固件以及发布 #Upload firmware to release | |
uses: Jason6111/[email protected] | |
if: steps.tag.outputs.status == 'success' && !cancelled() | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ steps.tag.outputs.release_tag }} | |
body_path: release.txt | |
files: ${{ env.FIRMWARE }}/* | |
- name: 删除工作流程运行 #Delete workflow runs | |
uses: Jason6111/delete-workflow-runs@main | |
with: | |
retain_days: 1 | |
keep_minimum_runs: 2 | |
- name: 删除旧版本 #Remove old Releases | |
uses: Jason6111/[email protected] | |
if: env.UPLOAD_RELEASE == 'true' && !cancelled() | |
with: | |
keep_latest: 5 | |
delete_tags: true | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: TG信息通知 | |
if: ${{ success() }} | |
run: | | |
curl -k --data chat_id=${{ secrets.TGID }} --data "text=我亲爱的主人您要编译的$RELEASE_TAG-$KERNEL_VERSION-$(date +"%Y.%m.%d-%H%M")固件编译成功!https://github.com/Jason6111/OpenWrt_Personal/releases/tag/${{ steps.tag.outputs.release_tag }} " "https://api.telegram.org/bot${{ secrets.TG_TOKEN }}/sendMessage" | |
- name: PushDeer信息通知 | |
if: ${{ success() }} | |
run: | | |
curl -k --data pushkey="${{ secrets.pushkey }}" --data "text=我亲爱的主人您要编译的$RELEASE_TAG-$KERNEL_VERSION-$(date +"%Y.%m.%d-%H%M")固件编译成功!" --data "desp=https://github.com/Jason6111/OpenWrt_Personal/releases/tag/${{ steps.tag.outputs.release_tag }}" --data type=markdown "https://"${{ secrets.pushserve }}"/message/push?" | |
#- name: PUSHPLUS信息通知 | |
# if: ${{ success() }} | |
# run: | | |
# curl -k --data token="${{ secrets.PUSH_PLUS_TOKEN }}" --data title="恭喜主人$RELEASE_TAG-$KERNEL_VERSION-$(date +"%Y.%m.%d-%H%M")固件编译成功!" --data "content=我亲爱的主人您要编译的$RELEASE_TAG-$(date +"%Y.%m.%d-%H%M")固件成功完成了!https://github.com/Jason6111/OpenWrt_Personal/releases/tag/${{ steps.tag.outputs.release_tag }} " "http://www.pushplus.plus/send" |