Skip to content

Build_x86_64

Build_x86_64 #26

#=================================================
# Description: Build OpenWrt using GitHub Actions
# Lisence: MIT
# Author: eSirPlayground
# Youtube Channel: https://goo.gl/fvkdwm
#=================================================
name: Build_x86_64
# Add a button to trigger the workflow
on:
repository_dispatch:
workflow_dispatch:
env:
REPO_URL: https://github.com/coolsnowwolf/lede
REPO_BRANCH: master
CONFIG_FILE: x86_64.config
DIY_SCRIPT: customize.sh
CACHE_TOOLCHAIN: true
UPLOAD_BIN_DIR: false
FIRMWARE_RELEASE: true
FIRMWARE_TAG: X86_64
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 "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: Free disk space
uses: endersonmenezes/free-disk-space@main
with:
remove_android: true
remove_dotnet: true
remove_haskell: true
remove_tool_cache: false
remove_swap: true
remove_packages: "android* azure* clang* dotnet* firefox* ghc* golang* google* libclang* libgl1* lld* llvm* microsoft* mongodb* mono* mysql* nodejs* openjdk* php* postgresql* powershell* snap* temurin* yarn* zulu*"
remove_packages_one_command: true
remove_folders: "/etc/apt/sources.list.d* /etc/mono* /etc/mysql* /usr/include/linux/android* /usr/lib/llvm* /usr/lib/mono* /usr/local/lib/android* /usr/local/lib/node_modules* /usr/local/share/chromium* /usr/local/share/powershell* /usr/local/share/vcpkg/ports/azure* /usr/local/share/vcpkg/ports/google* /usr/local/share/vcpkg/ports/libpq/android* /usr/local/share/vcpkg/ports/llvm* /usr/local/share/vcpkg/ports/mysql* /usr/local/share/vcpkg/ports/snap* /usr/share/azure* /usr/share/dotnet* /usr/share/glade* /usr/share/miniconda* /usr/share/php* /usr/share/swift /var/lib/mysql* /var/log/azure*"
testing: false
- name: Combine Disks
uses: easimon/maximize-build-space@master
with:
swap-size-mb: 1024
temp-reserve-mb: 100
root-reserve-mb: 1024
- 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-mark hold grub-efi-amd64-signed
sudo -E apt update
sudo -E apt -y purge azure-cli* docker* ghc* zulu* llvm* firefox google* dotnet* powershell* openjdk* mysql* php* mongodb* dotnet* snap*
sudo -E apt -y full-upgrade
sudo -E apt -y install ack antlr3 aria2 asciidoc autoconf automake autopoint binutils bison build-essential bzip2 ccache cmake cpio curl device-tree-compiler fastjar flex gawk gettext gcc-multilib g++-multilib git gperf haveged help2man intltool libc6-dev-i386 libelf-dev libglib2.0-dev libgmp3-dev libltdl-dev libmpc-dev libmpfr-dev libncurses5-dev libncursesw5-dev libreadline-dev libssl-dev libtool lrzsz mkisofs msmtp nano ninja-build p7zip p7zip-full patch pkgconf python3 python3-pip libpython3-dev qemu-utils rsync scons squashfs-tools subversion swig texinfo uglifyjs upx-ucl unzip vim wget xmlto xxd zlib1g-dev
sudo -E systemctl daemon-reload
sudo -E apt -y autoremove --purge
sudo -E apt clean
sudo -E timedatectl set-timezone "$TZ"
#set +e
#docker rmi `docker images -q`
#sudo -E apt-get -y purge azure-cli* docker* ghc* zulu* hhvm* llvm* firefox* google* dotnet* aspnetcore* powershell* openjdk* adoptopenjdk* mysql* php* mongodb* moby* snap* || true
#sudo -E apt-get update
#sudo -E apt-get -y install ack antlr3 asciidoc autoconf automake autopoint binutils bison build-essential bzip2 ccache cmake cpio curl device-tree-compiler fastjar flex gawk gettext gcc-multilib g++-multilib git gperf haveged help2man intltool libc6-dev-i386 libelf-dev libfuse-dev libglib2.0-dev libgmp3-dev libltdl-dev libmpc-dev libmpfr-dev libncurses5-dev libncursesw5-dev libpython3-dev libreadline-dev libssl-dev libtool lrzsz mkisofs msmtp nano ninja-build p7zip p7zip-full patch pkgconf python2.7 python3 python3-pyelftools python3-setuptools qemu-utils rsync scons squashfs-tools subversion swig texinfo uglifyjs upx-ucl unzip vim wget xmlto xxd zlib1g-dev qemu-img
#sudo -E apt-get -y autoremove --purge
#sudo -E apt-get clean
#sudo timedatectl set-timezone "$TZ"
- name: Checkout
uses: actions/checkout@master
with:
fetch-depth: 0
- name: Clone source code
run: |
git clone --depth 1 $REPO_URL -b $REPO_BRANCH openwrt
cd openwrt
echo "OPENWRT_PATH=$PWD" >> $GITHUB_ENV
COMMIT_AUTHOR=$(git show -s --date=short --format="作者: %an")
echo "COMMIT_AUTHOR=$COMMIT_AUTHOR" >> $GITHUB_ENV
COMMIT_DATE=$(git show -s --date=short --format="时间: %ci")
echo "COMMIT_DATE=$COMMIT_DATE" >> $GITHUB_ENV
COMMIT_MESSAGE=$(git show -s --date=short --format="内容: %s")
echo "COMMIT_MESSAGE=$COMMIT_MESSAGE" >> $GITHUB_ENV
COMMIT_HASH=$(git show -s --date=short --format="hash: %H")
echo "COMMIT_HASH=$COMMIT_HASH" >> $GITHUB_ENV
- name: Generate Variables - Build_x86_64
run: |
cp $CONFIG_FILE $OPENWRT_PATH/.config
cd $OPENWRT_PATH
make defconfig > /dev/null 2>&1
SOURCE_REPO="$(echo $REPO_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: Cache Toolchain
if: env.CACHE_TOOLCHAIN == 'true'
uses: klever1988/cachewrtbuild@main
with:
ccache: true
mixkey: ${{ env.SOURCE_REPO }}-${{ env.REPO_BRANCH }}-${{ env.DEVICE_TARGET }}-${{ env.DEVICE_SUBTARGET }}
prefix: ${{ env.OPENWRT_PATH }}
- name: Update & Install feeds
run: |
cd $OPENWRT_PATH
./scripts/feeds update -a
./scripts/feeds install -a
- name: Configuration Customization - Build_x86_64
run: |
[ -e $CONFIG_FILE ] && mv $CONFIG_FILE $OPENWRT_PATH/.config
chmod +x $DIY_SCRIPT
cd $OPENWRT_PATH
$GITHUB_WORKSPACE/$DIY_SCRIPT
- name: Download package
if: (!cancelled())
run: |
cd $OPENWRT_PATH
make defconfig
make download -j8
find dl -size -1024c -exec ls -l {} \;
find dl -size -1024c -exec rm -f {} \;
- name: Build firmware
if: (!cancelled())
run: |
cd $OPENWRT_PATH
echo -e "$(nproc) thread build."
make -j$(nproc) || make -j1 || make -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: Upload Bin Directory
if: 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
run: |
cd $OPENWRT_PATH/bin/targets/*/*
cat sha256sums
cp $OPENWRT_PATH/.config build.config
mv -f $OPENWRT_PATH/bin/packages/*/*/*.ipk packages
tar -zcf Packages.tar.gz packages
rm -rf packages feeds.buildinfo version.buildinfo
echo "KERNEL=$(cat *.manifest | grep ^kernel | cut -d- -f2 | tr -d ' ')" >> $GITHUB_ENV
echo "FIRMWARE_PATH=$PWD" >> $GITHUB_ENV
- name: Upload Firmware To Artifact
if: 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: 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.DEVICE_TARGET }}-${{ env.DEVICE_SUBTARGET }}
- ⚽ 固件源码: ${{ env.REPO_URL }}
- 💝 源码分支: ${{ env.REPO_BRANCH }}
- 🚀 内核版本: ${{ env.KERNEL }}
### 🧊 固件版本
- 固件编译前最后一次➦[主源码](${{ env.REPO_URL }})更新记录
- ${{ env.COMMIT_AUTHOR }}
- ${{ env.COMMIT_DATE }}
- ${{ env.COMMIT_MESSAGE }}
- ${{ env.COMMIT_HASH }}