Build LEDE x86_x64 ROOTFS #12
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: Build LEDE x86_x64 ROOTFS | |
permissions: write-all | |
#开启写权限,防止无法上传到release | |
on: | |
repository_dispatch: | |
workflow_dispatch: | |
inputs: | |
ssh: | |
description: 'SSH connection to Actions' | |
required: false | |
default: 'false' | |
schedule: | |
- cron: '0 18 * * 5' | |
env: | |
REPO_URL: https://github.com/coolsnowwolf/lede | |
REPO_BRANCH: master | |
FEEDS_CONF: LEDE/feeds.conf.default | |
CONFIG_FILE: LEDE/.x86_x64.config | |
DIY_P1_SH: LEDE/diy-part1.sh | |
DIY_P2_SH: LEDE/diy-part2.sh | |
UPLOAD_BIN_DIR: false | |
UPLOAD_FIRMWARE: true | |
UPLOAD_COWTRANSFER: false | |
UPLOAD_WETRANSFER: false | |
UPLOAD_RELEASE: true | |
TZ: Asia/Shanghai | |
FILE_NAME: OP_x86_x64_ROOTFS | |
PRODUCT_NAME: OP_x86_x64_ROOTFS | |
GITHUB_RELEASE: https://g3s0.short.gy/OpenWRT | |
DISTRIB_REVISION: LEDE master | |
KERNEL_PATCHVER: 无内核,纯LXC ROOTFS | |
jobs: | |
build: | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@main | |
- name: Check server configuration | |
run: | | |
echo "警告⚠" | |
echo "若分配的服务器性能不足,务必及时取消,重新运行!" | |
echo "已知编译成功CPU型号:8370C,8171M" | |
echo "已知性能不足CPU型号:8272CL" | |
echo -e "-------------- ------------CPU信息------------------------------------------\n" | |
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 "已安装内存详细信息:" | |
sudo lshw -short -C memory | grep GiB | |
echo -e "\n" | |
echo "-----------------------------硬盘信息---------------------------------------------" | |
echo -e "硬盘数量:$(ls /dev/sd* | grep -v [1-9] | wc -l) \n" | |
echo "硬盘详情:" | |
df -Th | |
- name: Initialization environment | |
env: | |
DEBIAN_FRONTEND: noninteractive | |
run: | | |
docker rmi `docker images -q` | |
sudo -E rm -rf /usr/share/dotnet /etc/mysql /etc/php /etc/apt/sources.list.d /usr/local/lib/android | |
sudo -E apt -y purge azure-cli* docker* ghc* zulu* llvm* firefox google* dotnet* powershell* openjdk* mysql* php* mongodb* dotnet* snap* aspnetcore* | |
[ -n "$AGENT_TOOLSDIRECTORY" ] && sudo rm -rf "$AGENT_TOOLSDIRECTORY" | |
sudo -E apt update | |
sudo -E apt -y install $(curl -fsSL https://is.gd/depends_ubuntu_2204) | |
sudo -E apt -y autoremove --purge | |
sudo -E systemctl daemon-reload | |
sudo -E apt clean | |
sudo timedatectl set-timezone "$TZ" | |
sudo mkdir -p /workdir | |
sudo chown $USER:$GROUPS /workdir | |
echo "status=success" >> ${GITHUB_OUTPUT} | |
df -Th | |
- name: 缓存加速 | |
uses: stupidloud/cachewrtbuild@main | |
if: env.CACHE_BUILD == 'true' || (github.event.inputs.CACHE_BUILD == 'true') | |
with: | |
ccache: 'true' | |
prefix: ${{ 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: 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 | |
cd openwrt | |
useVersionInfo=$(git show -s --date=short --format="Author: %an<br/>date: %cd<br/>commit: %s<br/>commit hash: %H") | |
echo "useVersionInfo=$useVersionInfo" >> $GITHUB_ENV | |
echo "DATE=$(date "+%Y-%m-%d %H:%M:%S")" >> $GITHUB_ENV | |
echo "DATE1=$(date "+%Y-%m-%d")" >> $GITHUB_ENV | |
echo "tag_name=$(date +%Y%m%d)" >> $GITHUB_ENV | |
- name: 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: 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 | |
- 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 defconfig | |
make download -j8 | |
find dl -size -1024c -exec ls -l {} \; | |
find dl -size -1024c -exec rm -f {} \; | |
- name: Compile the firmware | |
id: compile | |
run: | | |
cd openwrt | |
echo -e "$(nproc) thread compile" | |
make -j$(nproc) || make -j1 || make -j1 V=s | |
# echo "::set-output name=status::success" | |
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 | |
echo "编译完成时间..." | |
START_SECONDS=${{ env.START_SECONDS }} | |
END_TIME=`date +'%Y-%m-%d %H:%M:%S'` | |
END_SECONDS=$(date --date="$END_TIME" +%s) | |
SECONDS=$((END_SECONDS-START_SECONDS)) | |
HOUR=$(( $SECONDS/3600 )) && MIN=$(( ($SECONDS-${HOUR}*3600)/60 )) && SEC=$(( $SECONDS-${HOUR}*3600-${MIN}*60 )) | |
echo "BUILD_TIME=${HOUR}时${MIN}分${SEC}秒" >> $GITHUB_ENV | |
echo "FILE_DATE=_$(date +"%Y%m%d%H%M")" >> $GITHUB_ENV | |
echo "FILE_DATE2=$(date +"%Y%m%d%H%M")" >> $GITHUB_ENV | |
- name: Clean up server space | |
if: steps.compile.outputs.status == 'success' && !cancelled() | |
run: | | |
cd openwrt/ | |
rm -rf $(ls . | grep -v "^bin$" | xargs) 2>/dev/null | |
df -hT ${PWD} | |
- name: Upload bin directory | |
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: Organize files | |
id: organize | |
if: env.UPLOAD_FIRMWARE == 'true' && !cancelled() | |
run: | | |
cd openwrt/bin/targets/*/* | |
rm -rf packages | |
rm -rf *.buildinfo | |
rm -rf profiles.json | |
rm -rf sha256sums | |
rm -rf openwrt-x86-64-generic-kernel.bin | |
rm -rf openwrt-x86-64-generic.manifest | |
rm -rf openwrt-x86-64-generic-squashfs-combined-efi.vmdk | |
rm -rf openwrt-x86-64-generic-squashfs-rootfs.img.gz | |
rm -rf openwrt-x86-64-generic-squashfs-combined-efi.img.gz | |
mv openwrt-x86-64-generic-rootfs.tar.gz openwrt-LEDE-${{ env.VERSION }}x86-64-generic-rootfs-${{ env.FILE_DATE2 }}.tar.gz | |
echo "FIRMWARE=$PWD" >> $GITHUB_ENV | |
# echo "::set-output name=status::success" | |
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: Generate release tag | |
#id: tag | |
#if: env.UPLOAD_RELEASE == 'true' && !cancelled() | |
#run: | | |
## echo "::set-output name=release_tag::$(date +"%Y.%m.%d-%H%M")" | |
#echo "release_tag=${{ env.FILE_NAME }}" >> $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 "::set-output name=status::success" | |
#echo "status=success" >> $GITHUB_OUTPUT | |
- name: Create release | |
id: release | |
uses: ncipollo/release-action@v1 | |
with: | |
name: R${{ env.DATE }} for ${{ env.PRODUCT_NAME }} | |
allowUpdates: true | |
tag: ${{ env.FILE_NAME }} | |
commit: main | |
token: ${{ secrets.TOKEN3 }} | |
body: | | |
**This is Temporary Mini Firmware for x86_x64** | |
### 📒 固件信息 | |
- 🚀 每日:OpenWRT 作者固件 ➦ [xYx-c](https://github.com/xYx-c/build-openwrt/releases) ➦ [Zane-E](https://github.com/Zane-E/ROOTFS/releases) ➦ [217heidai](https://github.com/217heidai/OpenWrt-Builder/releases) | |
- 🚀 随缘:LXC MINI ROOTFS ➦ [OpenWRT](https://github.com/518512/My-ROOTFS/releases) ➦ [LEDE](https://github.com/518512/My-ROOTFS/releases) ➦ [ImmortalWrt](https://github.com/518512/My-ROOTFS/releases)即可下载 | |
- 💻 平台架构: x86_x64 , 🌐 默认地址: 10.5.2.1 , 🔑 默认密码: password | |
- ⚽ 固件源码: ${{ env.REPO_URL }} , 💝 源码分支: ${{ env.REPO_BRANCH }}(24.7.7) | |
### 🧊 固件版本 | |
- LXC Mini底包,非完整固件,每周五18点自动编译 | |
- 固件编译前最后一次➦[主源码](${{ env.REPO_URL }})更新记录 | |
${{ env.useVersionInfo }} | |
artifacts: ${{ env.FIRMWARE }}/* | |
#- name: Upload firmware to release | |
# uses: softprops/action-gh-release@v1 | |
# if: steps.tag.outputs.status == 'success' && !cancelled() | |
# env: | |
# GITHUB_TOKEN: ${{ secrets.TOKEN3 }} | |
# with: | |
# tag_name: ${{ steps.tag.outputs.release_tag }} | |
# body_path: release.txt | |
# files: ${{ env.FIRMWARE }}/* | |
- name: Delete workflow runs | |
uses: Mattraks/delete-workflow-runs@main | |
with: | |
token: ${{ secrets.TOKEN3 }} | |
repository: ${{ github.repository }} | |
retain_days: 3 | |
keep_minimum_runs: 3 | |
- name: Remove old Releases | |
uses: dev-drprasad/delete-older-releases@master | |
if: env.UPLOAD_RELEASE == 'true' && !cancelled() | |
with: | |
repo: | |
keep_latest: 10 | |
delete_tag_pattern: | |
delete_tags: true | |
env: | |
GITHUB_TOKEN: ${{ secrets.TOKEN3 }} | |
- name: Telegram notification | |
run: | | |
curl "https://api.telegram.org/bot${{ secrets.TELEGRAM_BOT_TOKEN }}/sendMessage" -d "chat_id=${{ secrets.TELEGRAM_CHAT_ID }}&text= | |
您的${{ env.PRODUCT_NAME }}固件成功编译完成了! | |
🛠 编译版本:${{ env.DISTRIB_REVISION }} | |
🖥 内核版本:${{ env.KERNEL_PATCHVER }} | |
🎈 编译时间:${{ env.FILE_TIME1 }} | |
⏰ 编译用时:${{ env.BUILD_TIME }} | |
🎉 发布地址:${{ env.GITHUB_RELEASE }} | |
🌴 固件已经编译完成 🎈!!! | |
" >/dev/null 2>&1 && echo "ok..." |