Skip to content

Build x86 Lede

Build x86 Lede #126

Workflow file for this run

#
# 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 x86 Lede
on:
# schedule:
# - cron: 0 20 * * 5
repository_dispatch:
workflow_dispatch:
inputs:
firewall:
description: 'WAN口启用防火墙'
required: false
default: 'true'
type: choice
options:
- 'false'
- 'true'
lan-ip:
description: 'LAN口IP'
required: false
default: ''
wan-eth:
description: 'WAN接口'
required: false
default: 'eth0'
type: choice
options:
- 'eth0'
- 'eth1'
- 'eth2'
- 'eth3'
- 'eth4'
- 'eth5'
wan-ip:
description: 'WAN口IP'
required: false
default: ''
wan-netmask:
description: 'WAN口掩码'
required: false
default: ''
wan-gateway:
description: 'WAN口网关'
required: false
default: ''
npc-protocol:
description: 'NPS服务端通信协议'
required: false
default: 'tcp'
type: choice
options:
- 'tcp'
- 'kcp'
npc-server:
description: 'NPS服务端地址'
required: false
default: ''
npc-port:
description: 'NPS服务端端口'
required: false
default: ''
npc-vkey:
description: 'NPS服务端密钥'
required: false
default: ''
env:
REPO_URL: https://github.com/coolsnowwolf/lede
REPO_BRANCH: master
RELEASE_PREFIX: lede
FEEDS_CONF: feeds.conf
CONFIG_FILE: x86.config
DIY_P1_SH: x86-part1.sh
DIY_P2_SH: x86-part2.sh
DISTFEEDS: distfeeds.conf
UPLOAD_BIN_DIR: true
UPLOAD_FIRMWARE: true
UPLOAD_RELEASE: true
TZ: Asia/Shanghai
jobs:
build:
runs-on: ubuntu-22.04
steps:
- 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
sudo -E apt -qq update -y
sudo -E apt -qq full-upgrade -y
sudo -E apt -qq 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 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 python2.7 python3 python3-pyelftools libpython3-dev qemu-utils rsync scons squashfs-tools subversion swig texinfo uglifyjs upx-ucl unzip vim wget xmlto xxd zlib1g-dev
sudo -E apt -qq autoremove --purge
sudo -E apt -qq clean
sudo timedatectl set-timezone "$TZ"
sudo mkdir -p /workdir
sudo chown $USER:$GROUPS /workdir
- name: 释放磁盘空间
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: 克隆 Lede 源码
working-directory: /workdir
run: |
df -hT $PWD
echo Start cloning...
git clone $REPO_URL -b $REPO_BRANCH lede
ln -sf /workdir/lede $GITHUB_WORKSPACE/lede
echo Clone finished.
- name: 载入自定义 Feeds
run: |
echo Start loading customize feeds...
[ -e $FEEDS_CONF ] && mv $FEEDS_CONF lede/feeds.conf.default
echo Load customize feeds finished.
- name: 更新 Feeds
run: |
echo Start updating feeds...
cd lede
./scripts/feeds update -a
echo Update feeds finished.
- name: 安装 Feeds
run: |
echo Start installing feeds...
cd lede
./scripts/feeds install -a
echo Install feeds finished.
- name: 执行自定义脚本1
run: |
echo Start executing script...
chmod +x $DIY_P1_SH
cd lede
$GITHUB_WORKSPACE/$DIY_P1_SH
echo Execute script finished.
- name: 载入自定义配置
run: |
echo Start loading config...
[ -e files ] && mv files lede/files
[ -e $CONFIG_FILE ] && mv $CONFIG_FILE lede/.config
echo Load config finished.
- name: 设置初次启动脚本可执行权限
run: |
echo Start authorizing script...
[ -e lede/files/etc/uci-defaults ] && chmod +x -R lede/files/etc/uci-defaults/
[ -e lede/files/etc/uci-defaults ] && ls -l lede/files/etc/uci-defaults/
echo Authorize script finished.
- name: 运行自定义脚本2
env:
ENABLE_FIREWALL: ${{github.event.inputs.firewall}}
LAN_IP: ${{github.event.inputs.lan-ip}}
WAN_IP: ${{github.event.inputs.wan-ip}}
WAN_NETMASK: ${{github.event.inputs.wan-netmask}}
WAN_GATEWAY: ${{github.event.inputs.wan-gateway}}
WAN_ETH: ${{github.event.inputs.wan-eth}}
NPC_PROTOCOL: ${{github.event.inputs.npc-protocol}}
NPC_SERVER: ${{github.event.inputs.npc-server}}
NPC_PORT: ${{github.event.inputs.npc-port}}
NPC_VKEY: ${{github.event.inputs.npc-vkey}}
run: |
echo Start executing script...
chmod +x $DIY_P2_SH
cd lede
$GITHUB_WORKSPACE/$DIY_P2_SH
echo Execute script finished.
- name: 下载所需文件
id: package
run: |
cd lede
echo Start downloading...
make defconfig
make download -j$(nproc)
echo Download finished.
- name: 编译固件
id: compile
run: |
cd lede
echo Start compiling...
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
echo Compile finished.
- name: 检查使用空间
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: Lede_bin${{ env.DEVICE_NAME }}${{ env.FILE_DATE }}
path: lede/bin
- name: 清理多余文件
id: organize
if: env.UPLOAD_FIRMWARE == 'true' && !cancelled()
run: |
cd lede/bin/targets/*/*
rm -rf packages
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: Lede_firmware${{ env.DEVICE_NAME }}${{ env.FILE_DATE }}
path: ${{ env.FIRMWARE }}
- name: 生成 Release 标签
id: tag
if: steps.organize.outputs.status == 'success' && env.UPLOAD_RELEASE == 'true' && !cancelled()
env:
ENABLE_FIREWALL: ${{github.event.inputs.firewall}}
LAN_IP: ${{github.event.inputs.lan-ip}}
WAN_IP: ${{github.event.inputs.wan-ip}}
WAN_NETMASK: ${{github.event.inputs.wan-netmask}}
WAN_GATEWAY: ${{github.event.inputs.wan-gateway}}
WAN_ETH: ${{github.event.inputs.wan-eth}}
NPC_PROTOCOL: ${{github.event.inputs.npc-protocol}}
NPC_SERVER: ${{github.event.inputs.npc-server}}
NPC_PORT: ${{github.event.inputs.npc-port}}
NPC_VKEY: ${{github.event.inputs.npc-vkey}}
run: |
LAN_PREFIX=""
if [[ "${LAN_IP}" != "" ]]; then
LAN_PREFIX="-"
fi
FIREWALL_TEXT=""
if [[ "${ENABLE_FIREWALL}" == "true" ]]; then
FIREWALL_TEXT="-firewall"
fi
CUSTOMIZE_TEXT=""
if [[ "${WAN_IP}" != "" && "${WAN_NETMASK}" != "" && "${WAN_GATEWAY}" != "" ]] || [[ "${NPC_SERVER}" != "" && "${NPC_PORT}" != "" && "${NPC_VKEY}" != "" ]]; then
CUSTOMIZE_TEXT="-customize"
fi
WAN_ETH_TEXT=""
if [[ "${WAN_ETH}" != "" ]]; then
WAN_ETH_TEXT="-wan-${WAN_ETH}"
fi
echo "release_tag=${RELEASE_PREFIX}${LAN_PREFIX}${LAN_IP}${FIREWALL_TEXT}${CUSTOMIZE_TEXT}${WAN_ETH_TEXT}-$(date +"%Y.%m.%d-%H%M")" >> $GITHUB_OUTPUT
touch release.txt
echo "status=success" >> $GITHUB_OUTPUT
- name: 上传固件到 Release
uses: softprops/action-gh-release@master
if: steps.tag.outputs.status == 'success' && !cancelled()
env:
GITHUB_TOKEN: ${{ secrets.LEDE_TOKEN }}
with:
token: ${{ secrets.LEDE_TOKEN }}
tag_name: ${{ steps.tag.outputs.release_tag }}
body_path: release.txt
files: ${{ env.FIRMWARE }}/*
- name: 删除 workflow runs
uses: FunctionXJB/delete-workflow-runs@main
env:
GITHUB_TOKEN: ${{ secrets.LEDE_TOKEN }}
with:
token: ${{ secrets.LEDE_TOKEN }}
retain_days: 10
keep_minimum_runs: 10
- name: 删除旧的 Releases
uses: dev-drprasad/delete-older-releases@master
if: steps.organize.outputs.status == 'success' && env.UPLOAD_RELEASE == 'true' && !cancelled()
env:
GITHUB_TOKEN: ${{ secrets.LEDE_TOKEN }}
with:
keep_latest: 10
delete_tags: true