X86_64 Mini OpenWrt #83
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
#=============================================== | |
# Description: Build OpenWrt | |
# File name: build-openwrt.yml | |
# Lisence: MIT | |
# Author: P3TERX | |
# https://github.com/P3TERX | |
#=============================================== | |
name: X86_64 Mini OpenWrt | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: 0 19 * * * | |
env: | |
SOURCE_URL: https://github.com/coolsnowwolf/lede | |
SOURCE_BRANCH: master | |
CONFIG_FILE: configs/x86_64-mini.config | |
DIY_SCRIPT: diy-mini.sh | |
CLASH_KERNEL: amd64 | |
UPLOAD_BIN_DIR: false | |
FIRMWARE_RELEASE: true | |
FIRMWARE_TAG: X86_64 | |
TZ: Asia/Shanghai | |
jobs: | |
Build: | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@main | |
- name: Check Server Performance | |
run: | | |
echo "警告⚠" | |
echo "分配的服务器性能有限,若选择的插件过多,务必注意CPU性能!" | |
echo -e "已知CPU型号(降序):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: Initialization Environment | |
env: | |
DEBIAN_FRONTEND: noninteractive | |
run: | | |
docker rmi $(docker images -q) | |
sudo rm -rf /etc/apt/sources.list.d/* /usr/share/dotnet /etc/mysql /etc/php /usr/local/lib/android | |
sudo -E apt-get -qq update | |
sudo -E apt-get -y install rename libfuse-dev $(curl -fsSL is.gd/depends_ubuntu_2204) | |
sudo -E apt-get -qq autoremove --purge | |
sudo -E apt-get -qq clean | |
sudo timedatectl set-timezone "$TZ" | |
- name: Clone Source Code | |
id: clone | |
run: | | |
df -hT $GITHUB_WORKSPACE | |
git clone $SOURCE_URL -b $SOURCE_BRANCH workspace/openwrt | |
cd workspace/openwrt | |
echo "OPENWRT_PATH=$PWD" >> $GITHUB_ENV | |
VERSION_INFO=$(git show -s --date=short --format="Author: %an<br/>date: %cd<br/>commit: %s<br/>commit hash: %H") | |
echo "VERSION_INFO=$VERSION_INFO" >> $GITHUB_ENV | |
- name: Install Feeds | |
run: | | |
cd $OPENWRT_PATH | |
./scripts/feeds update -a | |
./scripts/feeds install -a | |
- name: Load Custom Configuration | |
run: | | |
[ -e files ] && mv files $OPENWRT_PATH/files | |
[ -e $CONFIG_FILE ] && mv $CONFIG_FILE $OPENWRT_PATH/.config | |
chmod +x $GITHUB_WORKSPACE/scripts/*.sh | |
chmod +x $DIY_SCRIPT | |
cd $OPENWRT_PATH | |
$GITHUB_WORKSPACE/$DIY_SCRIPT | |
$GITHUB_WORKSPACE/scripts/preset-clash-core.sh $CLASH_KERNEL | |
$GITHUB_WORKSPACE/scripts/preset-terminal-tools.sh | |
- name: Download DL Package | |
run: | | |
cd $OPENWRT_PATH | |
make defconfig | |
make download -j8 | |
find dl -size -1024c -exec ls -l {} \; | |
find dl -size -1024c -exec rm -f {} \; | |
- name: Generate Variables | |
run: | | |
cd $OPENWRT_PATH | |
SOURCE_REPO="$(echo $SOURCE_URL | awk -F '/' '{print $(NF)}')" | |
echo "SOURCE_REPO=$SOURCE_REPO" >> $GITHUB_ENV | |
DEVICE_TARGET=$(cat .config | grep CONFIG_TARGET_BOARD | awk -F '"' '{print $2}') | |
echo "DEVICE_TARGET=$DEVICE_TARGET" >> $GITHUB_ENV | |
DEVICE_SUBTARGET=$(cat .config | grep CONFIG_TARGET_SUBTARGET | awk -F '"' '{print $2}') | |
echo "DEVICE_SUBTARGET=$DEVICE_SUBTARGET" >> $GITHUB_ENV | |
- name: Compile Packages | |
run: | | |
cd $OPENWRT_PATH | |
echo -e "$(nproc) thread compile" | |
make tools/compile -j$(nproc) || make tools/compile -j1 V=s | |
make toolchain/compile -j$(nproc) || make toolchain/compile -j1 V=s | |
make diffconfig | |
make target/compile -j$(nproc) || make target/compile -j1 V=s IGNORE_ERRORS=1 | |
make package/compile -j$(nproc) IGNORE_ERRORS=1 || make package/compile -j1 V=s IGNORE_ERRORS=1 | |
make package/index | |
- name: Generate Firmware | |
id: generate | |
run: | | |
cd $OPENWRT_PATH | |
mkdir -p files/etc/uci-defaults | |
cp $GITHUB_WORKSPACE/scripts/init-settings.sh files/etc/uci-defaults/99-init-settings | |
make package/install -j$(nproc) || make package/install -j1 V=s | |
make target/install -j$(nproc) || make target/install -j1 V=s | |
echo "status=success" >> $GITHUB_OUTPUT | |
echo "DATE=$(date +"%Y-%m-%d %H:%M:%S")" >> $GITHUB_ENV | |
echo "FILE_DATE=$(date +"%Y.%m.%d")" >> $GITHUB_ENV | |
- name: Check Space Usage | |
if: always() | |
run: df -hT | |
- name: Upload Bin Directory | |
if: steps.generate.outputs.status == 'success' && env.UPLOAD_BIN_DIR == 'true' | |
uses: actions/upload-artifact@main | |
with: | |
name: ${{ env.SOURCE_REPO }}-bin-${{ env.DEVICE_TARGET }}-${{ env.DEVICE_SUBTARGET }}-${{ env.FILE_DATE }} | |
path: ${{ env.OPENWRT_PATH }}/bin | |
- name: Organize Files | |
if: steps.generate.outputs.status == 'success' | |
run: | | |
cd $OPENWRT_PATH/bin/targets/*/* | |
rm -rf packages *.buildinfo *.manifest *kernel.bin *rootfs.img.gz | |
rename 's/^/mini-/' * | |
echo "FIRMWARE_PATH=$PWD" >> $GITHUB_ENV | |
- name: Upload Firmware To Artifact | |
if: steps.generate.outputs.status == 'success' && env.FIRMWARE_RELEASE != 'true' | |
uses: actions/upload-artifact@main | |
with: | |
name: ${{ env.SOURCE_REPO }}-firmware-${{ env.DEVICE_TARGET }}-${{ env.DEVICE_SUBTARGET }}-${{ env.FILE_DATE }} | |
path: ${{ env.FIRMWARE_PATH }} | |
- name: Upload Firmware To Release | |
if: steps.generate.outputs.status == 'success' && env.FIRMWARE_RELEASE == 'true' | |
uses: ncipollo/release-action@v1 | |
with: | |
name: R${{ env.DATE }} for ${{ env.FIRMWARE_TAG }} | |
allowUpdates: true | |
tag: ${{ env.FIRMWARE_TAG }} | |
token: ${{ secrets.GITHUB_TOKEN }} | |
artifacts: ${{ env.FIRMWARE_PATH }}/* | |
body: | | |
**This is OpenWrt Firmware for ${{ env.FIRMWARE_TAG }}** | |
* 这是 ${{ env.FIRMWARE_TAG }} 平台使用的 OpenWrt 固件 | |
默认 IP:192.168.1.1 默认密码:password | |
当前使用版本:【编译前的最后一次[➦主源码](https://github.com/coolsnowwolf/lede)更新记录】 | |
${{ env.VERSION_INFO }} |