Skip to content

Padavan CI K2P_4.4 #290

Padavan CI K2P_4.4

Padavan CI K2P_4.4 #290

# # # # # # # # # # #
# 自动构建K2P_4.4
#
# # # # # # # # # # #
name: Padavan CI K2P_4.4
on:
schedule:
- cron: '0 18 * * *'
workflow_dispatch:
inputs:
clean_cache:
description: 'Clear caches'
required: false
type: boolean
watch:
types: [started]
env:
T_NAMES: "K2P-NANO" # 设备名字数组
BASE_PATH: padavan # 基础目录
PUBLIC_PATH: public # 公共目录
VERSION_FILE: versions.inc # 版本后缀
PUBLIC_SH: public.sh # 公共命令
THEME_PATH: theme
UPLOAD_FIRMWARE: true # 是否打包文件
CLONE_URL: https://github.com/chenxudong2020/padavan-4.4.git # padavan 支持KVR源码地址
CLONE_BRANCH: main # padavan 分支
WORK_PATH: /opt/padavan # 工作目录 一定要加 /
UPLOAD_COWTRANSFER: false
UPLOAD_WETRANSFER: true
FILE_NAME: "K2P-NANO"
IMAGES_PATH: /opt/padavan/images/
jobs:
build:
runs-on: ubuntu-20.04
if: github.event.repository.owner.id == github.event.sender.id # 自己点的 start
steps:
- name: Checkout Master # 1.导入主分支
uses: actions/checkout@master
- name: Initialization Environment # 2.初始环境的设置
env:
DEBIAN_FRONTEND: noninteractive # 非交互模式
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
run: |
sudo apt update
# Debian/Ubuntu
sudo apt install -y unzip libtool-bin ccache curl cmake gperf gawk flex bison nano xxd \
fakeroot kmod cpio git python3-docutils gettext automake autopoint \
texinfo build-essential help2man pkg-config zlib1g-dev libgmp3-dev \
libmpc-dev libmpfr-dev libncurses5-dev libltdl-dev wget libc-dev-bin
sudo timedatectl set-timezone 'Asia/Shanghai' # 设置时区
- name: Clone Code # 3.拷贝代码
run: |
git clone --depth=1 $CLONE_URL -b $CLONE_BRANCH $WORK_PATH
- name: Build Tool Chain # 4.构建工具链
run: |
mkdir -p ${WORK_PATH}/images/
- name: Clear And Build # 5.清理构建树并开始构建
run: |
# 1.拷贝公共文件
cp -r $BASE_PATH/$PUBLIC_PATH $WORK_PATH/
sudo chmod +x $WORK_PATH/$PUBLIC_PATH/$PUBLIC_SH
# 2. 循环替换自定义默认模板和构建,单个设备的 sh 拷贝 t_item 需要编译的固件名字
for t_item in $T_NAMES;
do
if [ ! -e $BASE_PATH/$t_item/$t_item.config ] ; then
echo "${BASE_PATH}/${t_item}/${t_item}.config 自定义模板文件未找到"
else
cp -f $BASE_PATH/$t_item/$t_item.config $WORK_PATH/trunk/configs/templates/$t_item.config
echo "${t_item} 修改模板完成"
fi
if [ ! -f $BASE_PATH/$t_item/$t_item.sh ] ; then
echo "${BASE_PATH}/${t_item}/${t_item}.sh 自定义SH文件未找到"
else
cp -f $BASE_PATH/$t_item/$t_item.sh $WORK_PATH/
sudo chmod +x $WORK_PATH/$t_item.sh
echo "${t_item} 自定义SH文件拷贝成功"
fi
if [ ! -d $BASE_PATH/$t_item/$THEME_PATH ] ; then
echo "${BASE_PATH}/${t_item}/${THEME_PATH} 自定义主题文件夹未找到"
elif [! -d $WORK_PATH/$PUBLIC_PATH/$THEME_PATH ] ; then
cp -r $BASE_PATH/$t_item/$THEME_PATH $WORK_PATH/$PUBLIC_PATH
echo "${THEME_PATH} 自定义主题文件夹拷贝成功"
else
#删除public拷贝的主题
sudo rm -rf $WORK_PATH/$PUBLIC_PATH/$THEME_PATH
cp -r $BASE_PATH/$t_item/$THEME_PATH $WORK_PATH/$PUBLIC_PATH
echo "${THEME_PATH} 自定义主题文件夹拷贝成功"
fi
done
# 3. 开始构建
cd $WORK_PATH/trunk
for t_item in $T_NAMES;
do
cp -f $WORK_PATH/trunk/configs/templates/$t_item.config .config # 拷贝模板到 .config
# echo "执行 ${PUBLIC_SH} sh"
# sudo $WORK_PATH/$PUBLIC_PATH/$PUBLIC_SH
if [ -e $WORK_PATH/$t_item.sh ] ; then
echo "执行自定义 ${t_item} sh"
sudo $WORK_PATH/$t_item.sh
fi
sed -i 's/{ "wl_auth_mode", "psk" },/{ "wl_auth_mode", "open" },/g' $WORK_PATH/trunk/user/shared/defaults.c
sed -i 's/{ "rt_auth_mode", "psk" },/{ "rt_auth_mode", "open" },/g' $WORK_PATH/trunk/user/shared/defaults.c
echo "开始构建---------------------"
cd $WORK_PATH/trunk
fakeroot ./build_firmware_modify $t_item # $t_item 是循环的子对象
sudo mv -f images/*.trx ${WORK_PATH}/images/
done
- name : Upload Packages # 6. 打包文件并且上传到当前主分支
uses: actions/upload-artifact@master
if: env.UPLOAD_FIRMWARE == 'true' && success() # 成功才执行
with:
name: Padavan-${{env.FILE_NAME}}
path: ${{ env.IMAGES_PATH }}
- name: Upload firmware to cowtransfer
if: env.UPLOAD_COWTRANSFER == 'true' && success()
run: |
curl -fsSL git.io/file-transfer | sh
./transfer cow --block 2621440 -s -p 64 --no-progress ${IMAGES_PATH} 2>&1 | tee cowtransfer.log
echo "::warning file=cowtransfer.com::$(cat cowtransfer.log | grep https)"
- name: Upload firmware to WeTransfer
if: env.UPLOAD_WETRANSFER == 'true' && success()
run: |
curl -fsSL git.io/file-transfer | sh
./transfer wet -s -p 16 --no-progress ${IMAGES_PATH} 2>&1 | tee wetransfer.log
echo "::warning file=wetransfer.com::$(cat wetransfer.log | grep https)"