Skip to content

Build OpenWrt-K

Build OpenWrt-K #388

Workflow file for this run

#=============================================================================#
#MIT License
#Copyright (c) 2023 沉默の金
#Permission is hereby granted, free of charge, to any person obtaining a copy
#of this software and associated documentation files (the "Software"), to deal
#in the Software without restriction, including without limitation the rights
#to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
#copies of the Software, and to permit persons to whom the Software is
#furnished to do so, subject to the following conditions:
#The above copyright notice and this permission notice shall be included in all
#copies or substantial portions of the Software.
#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
#IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
#FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
#AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
#LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
#OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
#SOFTWARE.
#=============================================================================#
name: Build OpenWrt-K
on:
schedule:
- cron: '0 4 * * *'
# push:
# branches:
# - main
# paths:
# - '.github/**'
# - 'files/**'
# - '!README.md'
# pull_request:
# branches:
# - main
# paths:
# - 'config/**'
# - '.github/**'
# - 'files/**'
# - '!README.md'
workflow_dispatch:
permissions:
contents: write
discussions: write
jobs:
prepare:
outputs:
target: ${{ steps.target.outputs.target }}
subtarget: ${{ steps.target.outputs.subtarget }}
starttime: ${{ steps.time.outputs.starttime }}
runs-on: ubuntu-22.04
steps:
- name: 记录开始时间
id: time
run: |
sudo timedatectl set-timezone "Asia/Shanghai"
echo starttime=$(date +"%y.%m.%d-%H") >> "$GITHUB_OUTPUT"
- name: 准备环境
run: |
sudo -E apt update
sudo apt install -y curl git rsync unzip wget sed tar || sudo apt install -y curl git rsync unzip wget sed tar
- name: 将存储库签出到运行器
uses: actions/checkout@v3
- name: 建立工作文件夹
run: |
cd $GITHUB_WORKSPACE
mkdir -p download
cd download
export DOWNLOAD_ROOT_PATH="$(pwd)"
echo "DOWNLOAD_ROOT_PATH=$DOWNLOAD_ROOT_PATH" >> $GITHUB_ENV
mkdir -p lede Lienol immortalwrt wongsyrone passwall turboacc other
cd $GITHUB_WORKSPACE
mkdir -p cmzj_package
cd cmzj_package
export CMZJ_PACKAGE_ROOT_PATH="$(pwd)"
echo "CMZJ_PACKAGE_ROOT_PATH=$CMZJ_PACKAGE_ROOT_PATH" >> $GITHUB_ENV
mkdir -p turboacc r8125
cd $GITHUB_WORKSPACE
mkdir -p cmzj_patch
cd cmzj_patch
export CMZJ_PATCH_ROOT_PATH="$(pwd)"
echo "CMZJ_PATCH_ROOT_PATH=$CMZJ_PATCH_ROOT_PATH" >> $GITHUB_ENV
mkdir -p $CMZJ_PATCH_ROOT_PATH/firewall4/patches/ $CMZJ_PATCH_ROOT_PATH/libnftnl/patches/ $CMZJ_PATCH_ROOT_PATH/nftables/patches/ $CMZJ_PATCH_ROOT_PATH/hack-5.10 $CMZJ_PATCH_ROOT_PATH/hack-5.15 $CMZJ_PATCH_ROOT_PATH/hack-6.1 $CMZJ_PATCH_ROOT_PATH/dnsmasq $CMZJ_PATCH_ROOT_PATH/libubox $CMZJ_PATCH_ROOT_PATH/netdata
- name: 克隆补丁所需源代码
working-directory: ${{ env.DOWNLOAD_ROOT_PATH }}
run: |
cd lede
git clone https://github.com/coolsnowwolf/lede
cd $DOWNLOAD_ROOT_PATH
cd immortalwrt
git clone https://github.com/immortalwrt/packages
cd $DOWNLOAD_ROOT_PATH
cd turboacc
git clone https://github.com/chenmozhijin/turboacc -b package
cd $DOWNLOAD_ROOT_PATH
git clone https://git.openwrt.org/openwrt/openwrt.git
- name: 导入拓展软件包
run: |
TMPDIR=$(mktemp -d) || exit 1
EXT_PKGS_PREP_PATH=$TMPDIR/extpackages_prepare
EXT_PKGS_DL_PATH=$DOWNLOAD_ROOT_PATH/extpackages/dl
EXT_PKGS_PATH=$DOWNLOAD_ROOT_PATH/extpackages/extpackages
EXT_PKGS_CONFIG=$GITHUB_WORKSPACE/config/OpenWrt-K/extpackages.config
mkdir -p $EXT_PKGS_PREP_PATH $EXT_PKGS_PATH $EXT_PKGS_DL_PATH
NUMBER_OF_PKGS=$(grep -c "^EXT_PACKAGES_NAME\[" $EXT_PKGS_CONFIG)
n=1
while [ "$n" -le $NUMBER_OF_PKGS ]; do
EXT_PKG_REPOSITORIE=$(grep "^EXT_PACKAGES_REPOSITORIE\[$n\]" $EXT_PKGS_CONFIG| sed -e "s/.*=\"//g" -e "s/\"//g")
EXT_PKG_BRANCHE=$(grep "^EXT_PACKAGES_BRANCHE\[$n\]" $EXT_PKGS_CONFIG| sed -e "s/.*=\"//g" -e "s/\"//g")
echo "REPOSITORIE=$EXT_PKG_REPOSITORIE BRANCHE=$EXT_PKG_BRANCHE" >> $EXT_PKGS_PREP_PATH/extpackagesbr.config
n=$(( n+1 ))
done
sort $EXT_PKGS_PREP_PATH/extpackagesbr.config|uniq > $EXT_PKGS_PREP_PATH/clone.config
sed -i -e "s/BRANCHE=$//g" $EXT_PKGS_PREP_PATH/clone.config
sed -i -e "s/BRANCHE=/--branch /g" $EXT_PKGS_PREP_PATH/clone.config
NUMBER_OF_CLONES=$(grep -c "REPOSITORIE=" $EXT_PKGS_PREP_PATH/clone.config)
sed -i "s/^REPOSITORIE=//g" $EXT_PKGS_PREP_PATH/clone.config
echo "开始克隆拓展软件包仓库"
n=1
echo "debug1"
cat $EXT_PKGS_PREP_PATH/clone.config
while [ "$n" -le $NUMBER_OF_CLONES ]; do
echo "debug2"
echo "EXT_PKGS_PREP_PATH=$EXT_PKGS_PREP_PATH"
echo "EXT_PKGS_DL_PATH=$EXT_PKGS_DL_PATH"
echo "EXT_PKGS_PATH=$EXT_PKGS_PATH"
echo "EXT_PKGS_CONFIG=$EXT_PKGS_CONFIG"
echo "NUMBER_OF_CLONES=$NUMBER_OF_CLONES"
echo "n=$n"
mkdir -p $EXT_PKGS_DL_PATH/TMP
echo "debug3"
ls -al $EXT_PKGS_DL_PATH/TMP
COLNE_ARGUMENT=$(sed -n "${n}p" $EXT_PKGS_PREP_PATH/clone.config)
echo "debug4"
echo "COLNE_ARGUMENT=$COLNE_ARGUMENT"
git clone --depth=1 --single-branch $COLNE_ARGUMENT $EXT_PKGS_DL_PATH/TMP
echo "debug5"
ls -al $EXT_PKGS_DL_PATH/TMP
cd $EXT_PKGS_DL_PATH/TMP
if [ "$(echo "$COLNE_ARGUMENT" | grep -c " --branch ")" -ne '0' ];then
BRANCH=$(git rev-parse --abbrev-ref HEAD)
else
BRANCH="default_branch"
fi
echo "debug6"
echo "BRANCH=$BRANCH"
REPO_PATH="$BRANCH""/""$(echo "$COLNE_ARGUMENT" | sed -e "s/ --branch.*//g" -e "s@.*://@@g" -e "s/^[a-zA-Z.]\{1,111\}\///" -e "s/\/$//g")"
fiecho "debug7"
echo "REPO_PATH=$REPO_PATH"
mkdir -p $EXT_PKGS_DL_PATH/$REPO_PATH
cp -RT $EXT_PKGS_DL_PATH/TMP/ $EXT_PKGS_DL_PATH/$REPO_PATH
rm -rf $EXT_PKGS_DL_PATH/TMP/
echo "debug8"
ls -al $EXT_PKGS_DL_PATH/TMP
ls -al $EXT_PKGS_DL_PATH/$REPO_PATH
n=$(( n+1 ))
done
echo "开始整理拓展软件包"
n=1
while [ "$n" -le $NUMBER_OF_PKGS ]; do
NUMBER_OF_PKGS=$(grep -c "^EXT_PACKAGES_NAME\[" $EXT_PKGS_CONFIG)
EXT_PKG_NAME=$(grep "^EXT_PACKAGES_NAME\[$n\]" $EXT_PKGS_CONFIG| sed -e "s/.*=\"//g" -e "s/\"//g")
EXT_PKG_PATH=$(grep "^EXT_PACKAGES_PATH\[$n\]" $EXT_PKGS_CONFIG| sed -e "s/.*=\"//g" -e "s/\"//g")
EXT_PKG_REPOSITORIE=$(grep "^EXT_PACKAGES_REPOSITORIE\[$n\]" $EXT_PKGS_CONFIG| sed -e "s/.*=\"//g" -e "s/\"//g")
EXT_PKG_BRANCHE=$(grep "^EXT_PACKAGES_BRANCHE\[$n\]" $EXT_PKGS_CONFIG| sed -e "s/.*=\"//g" -e "s/\"//g")
EXT_PKG_REPO_PATH=$(echo "$EXT_PKG_REPOSITORIE" | sed -e "s/$ //g" -e "s/ .*//g" -e "s@.*://@@g" -e "s/^[a-zA-Z.]\{1,111\}\///" -e "s/\/$//g")
if [ -z "$EXT_PKG_BRANCHE" ];then
EXT_PKG_BRANCHE="default_branch"
fi
mkdir -p $EXT_PKGS_PATH/$EXT_PKG_NAME
cp -RT $EXT_PKGS_DL_PATH/$EXT_PKG_BRANCHE/$EXT_PKG_REPO_PATH/$EXT_PKG_PATH $EXT_PKGS_PATH/$EXT_PKG_NAME
n=$(( n+1 ))
done
cp -RT $EXT_PKGS_PATH $CMZJ_PACKAGE_ROOT_PATH
[[ -d $TMPDIR ]] && rm -rf "$TMPDIR"
cd $CMZJ_PACKAGE_ROOT_PATH
ls -la $(find $CMZJ_PACKAGE_ROOT_PATH -type d)
- name: 修改Makefile文件
working-directory: ${{ env.CMZJ_PACKAGE_ROOT_PATH }}
run: sed -i 's/include ..\/..\/luci.mk/include $(TOPDIR)\/feeds\/luci\/luci.mk/' $(find ./ -type f -name "Makefile")
- name: 创建符号链接以修复中文支持
working-directory: ${{ env.CMZJ_PACKAGE_ROOT_PATH }}
run: |
TMPDIR=$(mktemp -d) || exit 1
find . -name 'po' -type d > $TMPDIR/podir.list
total_rows=$(sed -n '$=' $TMPDIR/podir.list) #行数-文件夹个数
n=1
while [ "$n" -le $total_rows ]; do
DIR=$(sed -n "${n}p" $TMPDIR/podir.list)
if [ -h $DIR/zh_Hans ]; then
echo "$DIR/zh_Hans 符号链接以存在无需修复"
elif [ -d $DIR/zh_Hans ]; then
echo "$DIR/zh_Hans 目录已存在无需修复"
elif [ -e $DIR/zh_Hans ]; then
echo "$DIR/zh_Hans 存在非符号链接文件删除后重新创建"
rm -rf $DIR/zh_Hans||exit 1
ln -s zh-cn $DIR/zh_Hans||exit 1
elif [ ! -d $DIR/zh-cn ]; then
echo "$DIR/zh-cn 原汉化文件夹不存在,这可能是该luci插件原生为中文或不支持中文"
else
echo "$DIR/zh_Hans 符号链接不存在创建符号链接"
ln -s zh-cn $DIR/zh_Hans||exit 1
fi
n=$(( n+1 ))
done
[[ -d $TMPDIR ]] && rm -rf "$TMPDIR"
- name: 复制到cmzj_patch
run: |
cp $DOWNLOAD_ROOT_PATH/lede/lede/target/linux/generic/hack-5.10/952-net-conntrack-events-support-multiple-registrant.patch $CMZJ_PATCH_ROOT_PATH/hack-5.10/
cp $DOWNLOAD_ROOT_PATH/lede/lede/target/linux/generic/hack-5.10/953-net-patch-linux-kernel-to-support-shortcut-fe.patch $CMZJ_PATCH_ROOT_PATH/hack-5.10/
cp $DOWNLOAD_ROOT_PATH/lede/lede/target/linux/generic/hack-5.10/982-add-bcm-fullconenat-support.patch $CMZJ_PATCH_ROOT_PATH/hack-5.10/
cp $DOWNLOAD_ROOT_PATH/turboacc/turboacc/hack-5.15/952-add-net-conntrack-events-support-multiple-registrant.patch $CMZJ_PATCH_ROOT_PATH/hack-5.15/
cp $DOWNLOAD_ROOT_PATH/lede/lede/target/linux/generic/hack-5.15/953-net-patch-linux-kernel-to-support-shortcut-fe.patch $CMZJ_PATCH_ROOT_PATH/hack-5.15/
cp $DOWNLOAD_ROOT_PATH/turboacc/turboacc/hack-6.1/952-add-net-conntrack-events-support-multiple-registrant.patch $CMZJ_PATCH_ROOT_PATH/hack-6.1/
cp $DOWNLOAD_ROOT_PATH/lede/lede/target/linux/generic/hack-6.1/953-net-patch-linux-kernel-to-support-shortcut-fe.patch $CMZJ_PATCH_ROOT_PATH/hack-6.1/
cp -RT $DOWNLOAD_ROOT_PATH/turboacc/turboacc/firewall4-04a06bd70b9808b14444cae81a2faba4708ee231/firewall4 $CMZJ_PATCH_ROOT_PATH/firewall4
cp -RT $DOWNLOAD_ROOT_PATH/turboacc/turboacc/libnftnl-1.2.5/libnftnl $CMZJ_PATCH_ROOT_PATH/libnftnl
cp -RT $DOWNLOAD_ROOT_PATH/turboacc/turboacc/nftables-1.0.7/nftables $CMZJ_PATCH_ROOT_PATH/nftables
#cp -RT $DOWNLOAD_ROOT_PATH/openwrt/package/network/services/dnsmasq $CMZJ_PATCH_ROOT_PATH/dnsmasq
#cp -RT $DOWNLOAD_ROOT_PATH/openwrt/package/libs/libubox $CMZJ_PATCH_ROOT_PATH/libubox
cp -RT $DOWNLOAD_ROOT_PATH/immortalwrt/packages/admin/netdata $CMZJ_PATCH_ROOT_PATH/netdata
- name: 压缩
run: |
cd $CMZJ_PACKAGE_ROOT_PATH
tar cvpzf $GITHUB_WORKSPACE/cmzj_package.tgz *
cd $CMZJ_PATCH_ROOT_PATH
tar cvpzf $GITHUB_WORKSPACE/cmzj_patch.tgz *
- name: 上传 cmzj_package
uses: actions/upload-artifact@v3
with:
name: cmzj_package
path: cmzj_package.tgz
- name: 上传 cmzj_patch
uses: actions/upload-artifact@v3
with:
name: cmzj_patch
path: cmzj_patch.tgz
- name: 读取架构信息
id: target
working-directory: ${{ env.DOWNLOAD_ROOT_PATH }}/openwrt
run: |
cat $GITHUB_WORKSPACE/config/target.config >> $DOWNLOAD_ROOT_PATH/openwrt/.config
make defconfig
echo target=$(sed -n '/CONFIG_TARGET_BOARD/p' .config | sed -e 's/CONFIG_TARGET_BOARD\=\"//' -e 's/\"//') >> "$GITHUB_OUTPUT"
echo subtarget=$(sed -n '/CONFIG_TARGET_SUBTARGET/p' .config | sed -e 's/CONFIG_TARGET_SUBTARGET\=\"//' -e 's/\"//') >> "$GITHUB_OUTPUT"
build1:
runs-on: ubuntu-22.04
needs: prepare
steps:
- name: 将存储库签出到运行器
uses: actions/checkout@v3
- name: 输出运行器硬件信息
run: |
bash $GITHUB_WORKSPACE/scripts/hardware_info.sh
- name: 安装编译依赖
run: |
bash $GITHUB_WORKSPACE/scripts/install_compilation_dependencies.sh
- name: 合并磁盘
run: |
bash $GITHUB_WORKSPACE/scripts/merge_disk.sh
- name: 将存储库签出到运行器
uses: actions/checkout@v3
- name: 建立工作文件夹
run: |
cd $GITHUB_WORKSPACE
sudo mkdir -p workspace
sudo chown $USER:$GROUPS workspace
cd workspace
export WORKSPACE_ROOT_PATH="$(pwd)"
echo "WORKSPACE_ROOT_PATH=$WORKSPACE_ROOT_PATH" >> $GITHUB_ENV
cd $WORKSPACE_ROOT_PATH
mkdir -p cmzj_package
cd cmzj_package
export CMZJ_PACKAGE_ROOT_PATH="$(pwd)"
echo "CMZJ_PACKAGE_ROOT_PATH=$CMZJ_PACKAGE_ROOT_PATH" >> $GITHUB_ENV
cd $WORKSPACE_ROOT_PATH
mkdir -p cmzj_patch
cd cmzj_patch
export CMZJ_PATCH_ROOT_PATH="$(pwd)"
echo "CMZJ_PATCH_ROOT_PATH=$CMZJ_PATCH_ROOT_PATH" >> $GITHUB_ENV
cd $WORKSPACE_ROOT_PATH
mkdir -p log
cd log
export LOG_PATH="$(pwd)"
echo "LOG_PATH=$LOG_PATH" >> $GITHUB_ENV
cd $GITHUB_WORKSPACE && cat $GITHUB_ENV >> build1_ENV
- name: 下载cmzj_package
uses: actions/download-artifact@v3
with:
name: cmzj_package
- name: 下载cmzj_patch
uses: actions/download-artifact@v3
with:
name: cmzj_patch
- name: 解压
run: |
tar xvpfz $GITHUB_WORKSPACE/cmzj_package.tgz -C $CMZJ_PACKAGE_ROOT_PATH
tar xvpfz $GITHUB_WORKSPACE/cmzj_patch.tgz -C $CMZJ_PATCH_ROOT_PATH
echo "cmzj_package" >> $LOG_PATH/cmzj_package.log
ls $CMZJ_PACKAGE_ROOT_PATH >> $LOG_PATH/cmzj_package.log
echo "cmzj_patch" >> $LOG_PATH/cmzj_patch.log
ls $CMZJ_PATCH_ROOT_PATH >> $LOG_PATH/cmzj_patch.log
echo "cmzj_package-permissions" >> $LOG_PATH/cmzj_package.log
ls -l $CMZJ_PACKAGE_ROOT_PATH/** >> $LOG_PATH/cmzj_package.log
echo "cmzj_patch-permissions" >> $LOG_PATH/cmzj_patch.log
ls -l $CMZJ_PATCH_ROOT_PATH/** >> $LOG_PATH/cmzj_patch.log
- name: 克隆源代码
working-directory: ${{ env.WORKSPACE_ROOT_PATH }}
run: |
git clone https://git.openwrt.org/openwrt/openwrt.git
cd openwrt
export OPENWRT_ROOT_PATH="$(pwd)"
echo "OPENWRT_ROOT_PATH=$OPENWRT_ROOT_PATH" >> $GITHUB_ENV
cd $GITHUB_WORKSPACE && cat $GITHUB_ENV >> build1_ENV
- name: 切换标签/分支
working-directory: ${{ env.OPENWRT_ROOT_PATH }}
run: git checkout $(sed -n '/openwrt_tag\/branche/p' $GITHUB_WORKSPACE/OpenWrt-K.Config | sed -e 's/.*=//')
- name: 复制cmzj_package 打补丁
working-directory: ${{ env.WORKSPACE_ROOT_PATH }}
run: |
cp -r $CMZJ_PACKAGE_ROOT_PATH $OPENWRT_ROOT_PATH/package/cmzj_package
rm -rf $OPENWRT_ROOT_PATH/package/libs/libnftnl
rm -rf $OPENWRT_ROOT_PATH/package/network/config/firewall4
rm -rf $OPENWRT_ROOT_PATH/package/network/utils/nftables
#rm -rf $OPENWRT_ROOT_PATH/package/network/services/dnsmasq
#rm -rf $OPENWRT_ROOT_PATH/package/libs/libubox
mkdir -p $OPENWRT_ROOT_PATH/package/network/config/firewall4
mkdir -p $OPENWRT_ROOT_PATH/package/libs/libnftnl
mkdir -p $OPENWRT_ROOT_PATH/package/network/utils/nftables
#mkdir -p $OPENWRT_ROOT_PATH/package/libs/libubox
#mkdir -p $OPENWRT_ROOT_PATH/package/network/services/dnsmasq
cp -RT $CMZJ_PATCH_ROOT_PATH/firewall4 $OPENWRT_ROOT_PATH/package/network/config/firewall4
cp -RT $CMZJ_PATCH_ROOT_PATH/libnftnl $OPENWRT_ROOT_PATH/package/libs/libnftnl
cp -RT $CMZJ_PATCH_ROOT_PATH/nftables $OPENWRT_ROOT_PATH/package/network/utils/nftables
#cp -RT $CMZJ_PATCH_ROOT_PATH/libubox $OPENWRT_ROOT_PATH/package/libs/libubox
#cp -RT $CMZJ_PATCH_ROOT_PATH/dnsmasq $OPENWRT_ROOT_PATH/package/network/services/dnsmasq
echo "cmzj_patch" >> $LOG_PATH/cmzj_patch.log
ls $CMZJ_PATCH_ROOT_PATH >> $LOG_PATH/cmzj_patch.log
echo "cmzj_package" >> $LOG_PATH/cmzj_patch.log
ls $OPENWRT_ROOT_PATH/package/cmzj_package >> $LOG_PATH/cmzj_patch.log
echo "libnftnl-file" >> $LOG_PATH/cmzj_patch.log
ls $OPENWRT_ROOT_PATH/package/libs/libnftnl >> $LOG_PATH/cmzj_patch.log
echo "firewall4-file" >> $LOG_PATH/cmzj_patch.log
ls $OPENWRT_ROOT_PATH/package/network/config/firewall4 >> $LOG_PATH/cmzj_patch.log
echo "nftables-file" >> $LOG_PATH/cmzj_patch.log
ls $OPENWRT_ROOT_PATH/package/network/utils/nftables >> $LOG_PATH/cmzj_patch.log
echo "firewall4-patches" >> $LOG_PATH/cmzj_patch.log
ls $OPENWRT_ROOT_PATH/package/network/config/firewall4/patches/ >> $LOG_PATH/cmzj_patch.log
echo "libnftnl-patches" >> $LOG_PATH/cmzj_patch.log
ls $OPENWRT_ROOT_PATH/package/libs/libnftnl/patches/ >> $LOG_PATH/cmzj_patch.log
echo "nftables-patches" >> $LOG_PATH/cmzj_patch.log
ls $OPENWRT_ROOT_PATH/package/network/utils/nftables/patches/ >> $LOG_PATH/cmzj_patch.log
- name: 修复问题
working-directory: ${{ env.OPENWRT_ROOT_PATH }}
run: |
sed -i 's/^ DEPENDS:= +kmod-crypto-manager +kmod-crypto-pcbc +kmod-crypto-fcrypt$/ DEPENDS:= +kmod-crypto-manager +kmod-crypto-pcbc +kmod-crypto-fcrypt +kmod-udptunnel4 +kmod-udptunnel6/' package/kernel/linux/modules/netsupport.mk #https://github.com/openwrt/openwrt/commit/ecc53240945c95bc77663b79ccae6e2bd046c9c8
sed -i 's/^ dnsmasq \\$/ dnsmasq-full \\/g' ./include/target.mk
sed -i 's/256/1024/' ./target/linux/${{ needs.prepare.outputs.target }}/image/Makefile
sed -i 's/^ b43-fwsquash.py "$(CONFIG_B43_FW_SQUASH_PHYTYPES)" "$(CONFIG_B43_FW_SQUASH_COREREVS)"/ $(TOPDIR)\/tools\/b43-tools\/files\/b43-fwsquash.py "$(CONFIG_B43_FW_SQUASH_PHYTYPES)" "$(CONFIG_B43_FW_SQUASH_COREREVS)"/' ./package/kernel/mac80211/broadcom.mk
- name: 更新 feeds
working-directory: ${{ env.OPENWRT_ROOT_PATH }}
run: |
./scripts/feeds update -a
./scripts/feeds install -a
- name: 更新smartdns、netdata
working-directory: ${{ env.OPENWRT_ROOT_PATH }}
run: |
WORKINGDIR="`pwd`/feeds/packages/net/smartdns"
mkdir $WORKINGDIR -p
rm $WORKINGDIR/* -fr
wget https://github.com/pymumu/openwrt-smartdns/archive/master.zip -O $WORKINGDIR/master.zip
unzip $WORKINGDIR/master.zip -d $WORKINGDIR
mv $WORKINGDIR/openwrt-smartdns-master/* $WORKINGDIR/
rmdir $WORKINGDIR/openwrt-smartdns-master
rm $WORKINGDIR/master.zip
LUCIBRANCH="master" #更换此变量
WORKINGDIR="`pwd`/feeds/luci/applications/luci-app-smartdns"
mkdir $WORKINGDIR -p
rm $WORKINGDIR/* -fr
wget https://github.com/pymumu/luci-app-smartdns/archive/${LUCIBRANCH}.zip -O $WORKINGDIR/${LUCIBRANCH}.zip
unzip $WORKINGDIR/${LUCIBRANCH}.zip -d $WORKINGDIR
mv $WORKINGDIR/luci-app-smartdns-${LUCIBRANCH}/* $WORKINGDIR/
rmdir $WORKINGDIR/luci-app-smartdns-${LUCIBRANCH}
rm $WORKINGDIR/${LUCIBRANCH}.zip
WORKINGDIR="`pwd`/feeds/packages/admin/netdata"
mkdir $WORKINGDIR -p
rm $WORKINGDIR/* -fr
cp -RT $CMZJ_PATCH_ROOT_PATH/netdata $WORKINGDIR
- name: 安装 feeds
working-directory: ${{ env.OPENWRT_ROOT_PATH }}
run: ./scripts/feeds install -a
- name: 复制自定义文件并添加编译信息
run: |
cp -r files $OPENWRT_ROOT_PATH/files
chmod 755 $OPENWRT_ROOT_PATH/files/etc/uci-defaults/zzz-chenmozhijin
chmod 755 $OPENWRT_ROOT_PATH/files/etc/uci-defaults/zzz-chenmozhijin-passwall
#替换编译者
if [ "$(curl -s https://api.github.com/users/$(echo ${{ github.repository }} | sed "s/\/.*//g") 2>/dev/null|grep -c "^ \"name\": null,$")" -ne '0' ];then
compiler=$(echo ${{ github.repository }} | sed "s/\/.*//g")
else
compiler=$(curl -s https://api.github.com/users/$(echo ${{ github.repository }} | sed "s/\/.*//g") 2>/dev/null |grep '"name":\ "'|sed 's/ "name":\ "//'|sed 's/",//' 2>/dev/null)
fi
echo 'Compiled by' $compiler
sed -i "s/Compiled by 沉默の金/Compiled by $compiler/g" $OPENWRT_ROOT_PATH/files/etc/uci-defaults/zzz-chenmozhijin
cat $OPENWRT_ROOT_PATH/files/etc/uci-defaults/zzz-chenmozhijin | grep 'Compiled by'
#添加编译信息
export OPENWRT_TAG_BRANCHE="$(sed -n '/openwrt_tag\/branche/p' $GITHUB_WORKSPACE/OpenWrt-K.Config | sed -e 's/.*=//')"
echo "COMPILE_START_TIME=\"${{ needs.prepare.outputs.starttime }}\"" >> $OPENWRT_ROOT_PATH/files/etc/openwrt-k_info
echo "COMPILER=\"$compiler\"" >> $OPENWRT_ROOT_PATH/files/etc/openwrt-k_info
echo "RELEASE_NAME=\"OpenWrt-K_V${{ needs.prepare.outputs.starttime }} (${{ needs.prepare.outputs.target }}-${{ needs.prepare.outputs.subtarget }})-[$OPENWRT_TAG_BRANCHE]\"" >> $OPENWRT_ROOT_PATH/files/etc/openwrt-k_info
echo "RELEASE_TAG_NAME=\"v${{ needs.prepare.outputs.starttime }}(${{ needs.prepare.outputs.target }}-${{ needs.prepare.outputs.subtarget }})-($OPENWRT_TAG_BRANCHE)\"" >> $OPENWRT_ROOT_PATH/files/etc/openwrt-k_info
echo "REPOSITORY_URL=\"https://github.com/${{ github.repository }}\"" >> $OPENWRT_ROOT_PATH/files/etc/openwrt-k_info
echo "$OPENWRT_ROOT_PATH/files/etc/openwrt-k_info"
cat $OPENWRT_ROOT_PATH/files/etc/openwrt-k_info
- name: 加载自定义配置并生成配置文件
working-directory: ${{ env.OPENWRT_ROOT_PATH }}
run: |
cat $GITHUB_WORKSPACE/config/target.config >> $OPENWRT_ROOT_PATH/.config
cat $GITHUB_WORKSPACE/config/luci.config >> $OPENWRT_ROOT_PATH/.config
cat $GITHUB_WORKSPACE/config/utilities.config >> $OPENWRT_ROOT_PATH/.config
cat $GITHUB_WORKSPACE/config/network.config >> $OPENWRT_ROOT_PATH/.config
cat $GITHUB_WORKSPACE/config/other.config >> $OPENWRT_ROOT_PATH/.config
cat $GITHUB_WORKSPACE/config/kmod.config >> $OPENWRT_ROOT_PATH/.config
cat $GITHUB_WORKSPACE/config/image.config >> $OPENWRT_ROOT_PATH/.config
make defconfig
./scripts/diffconfig.sh
./scripts/diffconfig.sh >> $LOG_PATH/build1-diffconfig.log
- name: 打内核补丁
working-directory: ${{ env.WORKSPACE_ROOT_PATH }}
run: |
kernel_version="$(sed -n '/CONFIG_LINUX_/p' $OPENWRT_ROOT_PATH/.config | sed -e 's/CONFIG_LINUX_//' -e 's/=y//' -e 's/_/./g')"
echo kernel_version=$kernel_version
cp $CMZJ_PATCH_ROOT_PATH/hack-$kernel_version/952-add-net-conntrack-events-support-multiple-registrant.patch $OPENWRT_ROOT_PATH/target/linux/generic/hack-$kernel_version
#cp $CMZJ_PATCH_ROOT_PATH/hack-$kernel_version/953-net-patch-linux-kernel-to-support-shortcut-fe.patch $OPENWRT_ROOT_PATH/target/linux/generic/hack-$kernel_version
echo "hack-$kernel_version" >> $LOG_PATH/cmzj_patch.log
ls $OPENWRT_ROOT_PATH/target/linux/generic/hack-$kernel_version >> $LOG_PATH/cmzj_patch.log
- name: 加载附加内核配置
working-directory: ${{ env.OPENWRT_ROOT_PATH }}
run: |
kernel_version="$(sed -n '/CONFIG_LINUX_/p' $OPENWRT_ROOT_PATH/.config | sed -e 's/CONFIG_LINUX_//' -e 's/=y//' -e 's/_/./g')"
cat $GITHUB_WORKSPACE/config/linux/config-$kernel_version >> $OPENWRT_ROOT_PATH/target/linux/generic/config-$kernel_version || echo "未加载附加内核配置"
- name: 下载AdGuardHome核心与DNS名单
working-directory: ${{ env.OPENWRT_ROOT_PATH }}
run: |
if [ "$(grep -c "^CONFIG_PACKAGE_luci-app-adguardhome=y$" .config)" -ne '0' ];then
Archt="$(sed -n '/CONFIG_ARCH=/p' .config | sed -e 's/CONFIG_ARCH\=\"//' -e 's/\"//')"
case $Archt in
"i386")
Arch="386"
;;
"i686")
Arch="386"
;;
"x86_64")
Arch="amd64"
;;
"mipsel")
Arch="mipsle"
;;
"mips64el")
Arch="mips64le"
Arch="mipsle"
echo -e "mips64el use $Arch may have bug"
;;
"mips")
Arch="mips"
;;
"mips64")
Arch="mips64"
Arch="mips"
echo -e "mips64 use $Arch may have bug"
;;
"arm")
if [ "$(grep -c "CONFIG_arm_" .config)" -ne '0' ];then
armv="$(sed -n '/CONFIG_arm_/p' .config | sed -e 's/CONFIG_arm_//' -e 's/=y//')"
else
armv=v5
fi
Arch="arm$armv"
;;
"aarch64")
Arch="arm64"
;;
"powerpc")
Arch="ppc"
Arch=1
echo -e "error not support $Archt"
;;
"powerpc64")
Arch="ppc64"
Arch=1
echo -e "error not support $Archt"
;;
*)
echo -e "error not support $Archt if you can use offical release please issue a bug"
Arch=1
;;
esac
if [ "$Arch" != 1 ];then
echo AdGuardHome架构为$Arch,开始下载AdGuardHome
mkdir -p ./files/usr/bin/AdGuardHome/tmp
rm -rf ./files/usr/bin/AdGuardHome/tmp/*
latest_ver="$(curl -s https://api.github.com/repos/AdguardTeam/AdGuardHome/releases/latest 2>/dev/null|grep -E 'tag_name' |grep -E 'v[0-9.]+' -o 2>/dev/null)"
wget https://github.com/AdguardTeam/AdGuardHome/releases/download/${latest_ver}/AdGuardHome_linux_${Arch}.tar.gz -O ./files/usr/bin/AdGuardHome/tmp/AdGuardHome.tar.gz
tar -zxf "./files/usr/bin/AdGuardHome/tmp/AdGuardHome.tar.gz" -C "./files/usr/bin/AdGuardHome/tmp/"
mv -f ./files/usr/bin/AdGuardHome/tmp/AdGuardHome/AdGuardHome ./files/usr/bin/AdGuardHome
rm -rf ./files/usr/bin/AdGuardHome/tmp
chmod 755 $OPENWRT_ROOT_PATH/files/usr/bin/AdGuardHome/AdGuardHome
echo "下载AdGuardHome DNS黑白名单"
mkdir -p ./files/usr/bin/AdGuardHome/data/filters
cd $OPENWRT_ROOT_PATH/files/usr/bin/AdGuardHome/data/filters
curl -o 1628750870.txt https://adguardteam.github.io/AdGuardSDNSFilter/Filters/filter.txt -s -L --retry 3
curl -o 1628750871.txt https://anti-ad.net/easylist.txt -s -L --retry 3
curl -o 1677875715.txt https://easylist-downloads.adblockplus.org/easylist.txt -s -L --retry 3
curl -o 1677875716.txt https://easylist-downloads.adblockplus.org/easylistchina.txt -s -L --retry 3
curl -o 1677875717.txt https://cdn.jsdelivr.net/gh/cjx82630/cjxlist@master/cjx-annoyance.txt -s -L --retry 3
curl -o 1677875718.txt https://cdn.jsdelivr.net/gh/zsakvo/AdGuard-Custom-Rule@master/rule/zhihu-strict.txt -s -L --retry 3
curl -o 1677875720.txt https://gist.githubusercontent.com/Ewpratten/a25ae63a7200c02c850fede2f32453cf/raw/b9318009399b99e822515d388b8458557d828c37/hosts-yt-ads -s -L --retry 3
curl -o 1677875721.txt https://raw.githubusercontent.com/adbyby/xwhyc-rules/master/lazy.txt -s -L --retry 3
curl -o 1677875722.txt https://raw.githubusercontent.com/adbyby/xwhyc-rules/master/v -s -L --retry 3
curl -o 1677875724.txt https://raw.githubusercontent.com/banbendalao/ADgk/master/ADgk.txt -s -L --retry 3
curl -o 1677875725.txt https://www.i-dont-care-about-cookies.eu/abp/ -s -L --retry 3
curl -o 1677875726.txt https://raw.githubusercontent.com/jdlingyu/ad-wars/master/hosts -s -L --retry 3
curl -o 1677875727.txt https://raw.githubusercontent.com/Goooler/1024_hosts/master/hosts -s -L --retry 3
curl -o 1677875728.txt https://winhelp2002.mvps.org/hosts.txt -s -L --retry 3
curl -o 1677875733.txt https://cdn.jsdelivr.net/gh/hl2gu -s -L --retry 3
curl -o 1677875734.txt https://cdn.jsdelivr.net/gh/hg1978/AdGuard-Home-Whitelist@master/whitelist.txt -s -L --retry 3
curl -o 1677875735.txt https://cdn.jsdelivr.net/gh/mmotti/adguard-home-filters@master/whitelist.txt -s -L --retry 3
curl -o 1677875737.txt https://cdn.jsdelivr.net/gh/liwenjie119/adg-rules@master/white.txt -s -L --retry 3
curl -o 1677875739.txt https://cdn.jsdelivr.net/gh/JamesDamp/AdGuard-Home---Personal-Whitelist@master/AdGuardHome-Whitelist.txt -s -L --retry 3
curl -o 1677875740.txt https://cdn.jsdelivr.net/gh/scarletbane/AdGuard-Home-Whitelist@main/whitelist.txt -s -L --retry 3
ls
echo "制作AdGuardHome上游 DNS 服务器规则"
cd $WORKSPACE_ROOT_PATH
mkdir -p tmp
cd $WORKSPACE_ROOT_PATH/tmp
ls
rm -rf *
curl -s -L --retry 3 https://raw.githubusercontent.com/YW5vbnltb3Vz/domain-list-community/release/gfwlist.txt -o base64_YW5vbnltb3Vz.txt
curl -s -L --retry 3 https://raw.githubusercontent.com/Loyalsoldier/v2ray-rules-dat/release/gfw.txt -o Loyalsoldier.txt
curl -s -L --retry 3 https://raw.githubusercontent.com/gfwlist/gfwlist/master/gfwlist.txt -o base64_gfwlist.txt
curl -s -L --retry 3 https://raw.githubusercontent.com/Loukky/gfwlist-by-loukky/master/gfwlist.txt -o base64_Loukky.txt
base64 -d base64_YW5vbnltb3Vz.txt > YW5vbnltb3Vz.txt
base64 -d base64_gfwlist.txt > gfwlist.txt
base64 -d base64_Loukky.txt > Loukky.txt
sed -e '/^!/d' -e '/^\\/d' -e '/^@/d' -e 's/|//g' -e '/^http:\/\//d' -e '/^https:\/\//d' -e '/\//d' -e 's/^\.//g' -e '/\./!d' -e '/ /d' -e '/\*/d' -e '/%/d' -e '/^[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}/d' YW5vbnltb3Vz.txt>> gfwlist_chen
sed -e '/^!/d' -e '/^\\/d' -e '/^@/d' -e 's/|//g' -e '/^http:\/\//d' -e '/^https:\/\//d' -e '/\//d' -e 's/^\.//g' -e '/\./!d' -e '/ /d' -e '/\*/d' -e '/%/d' -e '/^[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}/d' Loyalsoldier.txt>> gfwlist_chen
sed -e '/^!/d' -e '/^\\/d' -e '/^@/d' -e 's/|//g' -e '/^http:\/\//d' -e '/^https:\/\//d' -e '/\//d' -e 's/^\.//g' -e '/\./!d' -e '/ /d' -e '/\*/d' -e '/%/d' -e '/^[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}/d' gfwlist.txt>> gfwlist_chen
sed -e '/^!/d' -e '/^\\/d' -e '/^@/d' -e 's/|//g' -e '/^http:\/\//d' -e '/^https:\/\//d' -e '/\//d' -e 's/^\.//g' -e '/\./!d' -e '/ /d' -e '/\*/d' -e '/%/d' -e '/^[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}/d' Loukky.txt>> gfwlist_chen
sort gfwlist_chen | uniq > gfwlist
sed -n '/^ - DOMAIN,/p' $OPENWRT_ROOT_PATH/files/etc/openclash/rule_provider/DirectRule-chenmozhijin.yaml|sed -e "s/^ - DOMAIN,/[\//g" -e 's/$/\/]127.0.0.1:6053/g' >> ./AdGuardHomednslist
sed -n '/^ - DOMAIN-SUFFIX,/p' $OPENWRT_ROOT_PATH/files/etc/openclash/rule_provider/DirectRule-chenmozhijin.yaml|sed -e "s/^ - DOMAIN-SUFFIX,/[\//g" -e 's/$/\/]127.0.0.1:6053/g' >> ./AdGuardHomednslist
sed -n '/^ - DOMAIN,/p' $OPENWRT_ROOT_PATH/files/etc/openclash/rule_provider/ProxyRule-chenmozhijin.yaml|sed -e "s/^ - DOMAIN,/[\//g" -e 's/$/\/]127.0.0.1:5335/g' >> ./AdGuardHomednslist
sed -n '/^ - DOMAIN-SUFFIX,/p' $OPENWRT_ROOT_PATH/files/etc/openclash/rule_provider/ProxyRule-chenmozhijin.yaml|sed -e "s/^ - DOMAIN-SUFFIX,/[\//g" -e 's/$/\/]127.0.0.1:5335/g' >> ./AdGuardHomednslist
sed -e 's/^/[\//g' -e 's/$/\/]127.0.0.1:5335/g' gfwlist >AdGuardHomednslist
sed -i "s/ //g" ./AdGuardHomednslist
cat ./AdGuardHomednslist >> $OPENWRT_ROOT_PATH/files/etc/AdGuardHome-dnslist"(by cmzj)".yaml
echo "AdGuardHome-dnslist(by cmzj).yaml" >> $LOG_PATH/AdGuardHome.log
cat $OPENWRT_ROOT_PATH/files/etc/AdGuardHome-dnslist"(by cmzj)".yaml >> $LOG_PATH/AdGuardHome.log
rm -rf $WORKSPACE_ROOT_PATH/tmp/*
echo "files"
ls -la $(find $OPENWRT_ROOT_PATH/files/ -type d)
else
echo "AdGuardHome核心不支持此架构,退出执行。"
rm -rf $OPENWRT_ROOT_PATH/files/etc/AdGuardHome-dnslist\(by\ cmzj\).yaml $OPENWRT_ROOT_PATH/files/etc/AdGuardHome.yaml $OPENWRT_ROOT_PATH/files/AdGuardHome
fi
else
echo "未检测到luci-app-adguardhome配置为编译进固件,退出执行。"
rm -rf $OPENWRT_ROOT_PATH/files/etc/AdGuardHome-dnslist\(by\ cmzj\).yaml $OPENWRT_ROOT_PATH/files/etc/AdGuardHome.yaml $OPENWRT_ROOT_PATH/files/AdGuardHome
fi
- name: 下载openclash内核
working-directory: ${{ env.OPENWRT_ROOT_PATH }}
run: |
if [ "$(grep -c "^CONFIG_PACKAGE_luci-app-openclash=y$" .config)" -ne '0' ];then
ARCHT="$(sed -n '/CONFIG_ARCH=/p' .config | sed -e 's/CONFIG_ARCH\=\"//' -e 's/\"//')"
case "${ARCHT}" in
aarch64)
CORE_ARCH="linux-arm64"
;;
arm)
if [ "$(grep -c "CONFIG_arm_" .config)" -ne '0' ];then
armv="$(sed -n '/CONFIG_arm_/p' .config | sed -e 's/CONFIG_arm_//' -e 's/=y//')"
else
armv=v5
fi
CORE_ARCH="linux-arm$armv"
;;
i386)
CORE_ARCH="linux-386"
;;
mips64)
CORE_ARCH="linux-mips64"
;;
mips)
CORE_ARCH="linux-mips-softfloat"
;;
mipsel)
CORE_ARCH="linux-mipsle-softfloat"
;;
x86_64)
CORE_ARCH="linux-amd64"
;;
*)
CORE_ARCH="1"
;;
esac
echo $CORE_ARCH
if [ "$CORE_ARCH" != 1 ];then
OpenClashTMPDIR=$WORKSPACE_ROOT_PATH/tmp/openclash
dev_core_path="$OPENWRT_ROOT_PATH/files/etc/openclash/core/clash"
tun_core_path="$OPENWRT_ROOT_PATH/files/etc/openclash/core/clash_tun"
meta_core_path="$OPENWRT_ROOT_PATH/files/etc/openclash/core/clash_meta"
CPU_MODEL=$CORE_ARCH
RELEASE_BRANCH=master
mkdir -p $OpenClashTMPDIR $OPENWRT_ROOT_PATH/files/etc/openclash/core/
rm -rf $OpenClashTMPDIR/*
CORE_LV=$(curl -s -L --retry 3 https://raw.githubusercontent.com/vernesong/OpenClash/core/master/core_version|sed -n 2p)
curl -s -L --retry 3 -o $OpenClashTMPDIR/clash_tun.gz https://raw.githubusercontent.com/vernesong/OpenClash/core/"$RELEASE_BRANCH"/premium/clash-"$CPU_MODEL"-"$CORE_LV".gz
curl -s -L --retry 3 -o $OpenClashTMPDIR/clash_meta.tar.gz https://raw.githubusercontent.com/vernesong/OpenClash/core/"$RELEASE_BRANCH"/meta/clash-"$CPU_MODEL".tar.gz
curl -s -L --retry 3 -o $OpenClashTMPDIR/clash.tar.gz https://raw.githubusercontent.com/vernesong/OpenClash/core/"$RELEASE_BRANCH"/dev/clash-"$CPU_MODEL".tar.gz
#tun
gzip -d $OpenClashTMPDIR/clash_tun.gz
rm -rf $OpenClashTMPDIR/clash_tun.gz
rm -rf "$tun_core_path"
chmod 4755 $OpenClashTMPDIR/clash_tun
mv $OpenClashTMPDIR/clash_tun "$tun_core_path"
#mate
rm -rf "$meta_core_path"
tar zxvf $OpenClashTMPDIR/clash_meta.tar.gz -C $OpenClashTMPDIR
mv $OpenClashTMPDIR/clash $OpenClashTMPDIR/clash_meta
rm -rf $OpenClashTMPDIR/clash_meta.tar.gz
chmod 4755 $OpenClashTMPDIR/clash_meta
mv $OpenClashTMPDIR/clash_meta "$meta_core_path"
#dev
rm -rf "$dev_core_path"
tar zxvf $OpenClashTMPDIR/clash.tar.gz -C $OpenClashTMPDIR
rm -rf $OpenClashTMPDIR/clash.tar.gz
chmod 4755 $OpenClashTMPDIR/clash
mv $OpenClashTMPDIR/clash "$dev_core_path"
echo "files"
ls -la $(find $OPENWRT_ROOT_PATH/files/ -type d)
else
echo openclash内核不支持此架构,退出执行。
rm -rf $OPENWRT_ROOT_PATH/files/etc/openclash
fi
else
echo "未检测到luci-app-openclash配置为编译进固件,退出执行。"
rm -rf $OPENWRT_ROOT_PATH/files/etc/openclash
fi
- name: 更新BT Tracker
working-directory: ${{ env.OPENWRT_ROOT_PATH }}
run: |
export bt_tracker="$(curl -s -L --retry 3 https://github.com/XIU2/TrackersListCollection/raw/master/all_aria2.txt || curl -s -L --retry 3 https://cf.trackerslist.com/all_aria2.txt)"
sed -i "s#^uci set aria2.main.bt_tracker=.*#uci set aria2.main.bt_tracker=\'$bt_tracker\'#g" $OPENWRT_ROOT_PATH/files/etc/uci-defaults/zzz-chenmozhijin
- name: 设置时区与主机名
working-directory: ${{ env.OPENWRT_ROOT_PATH }}
run: sed -i -e "s/set system.@system\[-1].hostname='OpenWrt'/set system.@system\[-1].hostname='OpenWrt-k'/g" -e "s/set system.@system\[-1].timezone='UTC'/set system.@system\[-1].timezone='CST-8'/g" -e "/set system.@system\[-1].timezone='CST-8'/i\ set system.@system\[-1].zonename='Asia/Shanghai'" $OPENWRT_ROOT_PATH/package/base-files/files/bin/config_generate
- name: 检查剩余空间
run: |
echo "======================="
echo "空间使用情况:"
echo "======================="
df --total -Th
echo "======================="
- name: 下载 dl 库
working-directory: ${{ env.OPENWRT_ROOT_PATH }}
run: |
make download -j16
find dl -size -1024c -exec ls -l {} \;
find dl -size -1024c -exec rm -f {} \;
make download -j16 || make download -j1 V=s
- name: 构建工具
working-directory: ${{ env.OPENWRT_ROOT_PATH }}
run: |
make tools/install -j $(($(nproc)+1)) || make tools/install -j1 V=s
echo "======================="
echo "空间使用情况:"
echo "======================="
df --total -Th
echo "======================="
- name: 构建工具链
working-directory: ${{ env.OPENWRT_ROOT_PATH }}
run: |
make toolchain/install -j $(($(nproc)+1)) || make toolchain/install -j1 V=s
echo "======================="
echo "空间使用情况:"
echo "======================="
df --total -Th
echo "======================="
- name: 删除 dl 库
working-directory: ${{ env.OPENWRT_ROOT_PATH }}
run: rm -rf dl
- name: 准备上传
run: |
cd $GITHUB_WORKSPACE
sudo tar cvpzf /build1_WORKSPACE.tgz *
cp $OPENWRT_ROOT_PATH/.config $OPENWRT_ROOT_PATH/build1.config
cd $OPENWRT_ROOT_PATH/files
tar cvpzf $GITHUB_WORKSPACE/openwrt_files.tgz *
- name: 上传 build1_WORKSPACE
uses: actions/upload-artifact@v3
with:
name: build1_WORKSPACE
path: /build1_WORKSPACE.tgz
- name: 上传 .config
uses: actions/upload-artifact@v3
with:
name: build1_openwrt_config
path: ${{ env.OPENWRT_ROOT_PATH }}/build1.config
- name: 上传 files
uses: actions/upload-artifact@v3
with:
name: build1_openwrt_files
path: openwrt_files.tgz
- name: 收集日志
if: failure()
run: |
mkdir -p openwrt-logs
cp -r $OPENWRT_ROOT_PATH/logs $LOG_PATH/openwrt-logs || echo "没有openwrt/logs"
cp $OPENWRT_ROOT_PATH/.config $LOG_PATH/openwrt.config || echo "没有openwrt/.config"
ls -la $(find $OPENWRT_ROOT_PATH/files/ -type d) >> $LOG_PATH/files.list
- name: 上传日志
if: failure()
uses: actions/upload-artifact@v3
with:
name: ${{ needs.prepare.outputs.target }}-${{ needs.prepare.outputs.subtarget }}-logs-
path: "${{ env.LOG_PATH }}"
build-package:
runs-on: ubuntu-latest
needs: [prepare,build1]
steps:
- name: 将存储库签出到运行器
uses: actions/checkout@v3
- name: 输出运行器硬件信息
run: |
bash $GITHUB_WORKSPACE/scripts/hardware_info.sh
- name: 清理空间
run: |
bash $GITHUB_WORKSPACE/scripts/clear_space.sh
- name: 安装编译依赖
run: |
bash $GITHUB_WORKSPACE/scripts/install_compilation_dependencies.sh
- name: 合并磁盘
run: |
bash $GITHUB_WORKSPACE/scripts/merge_disk.sh
- name: 下载build1_WORKSPACE
uses: actions/download-artifact@v3
with:
name: build1_WORKSPACE
- name: 解压
run: |
sudo mv $GITHUB_WORKSPACE/build1_WORKSPACE.tgz /build1_WORKSPACE.tgz
tar xvpfz /build1_WORKSPACE.tgz -C $GITHUB_WORKSPACE
sudo rm -rf /build1_WORKSPACE.tgz
cat build1_ENV
cat build1_ENV >> $GITHUB_ENV
- name: 环境变量
run: env
- name: 下载 dl 库
working-directory: ${{ env.OPENWRT_ROOT_PATH }}
run: |
make download -j16
find dl -size -1024c -exec ls -l {} \;
find dl -size -1024c -exec rm -f {} \;
make download -j16 || make download -j1 V=s
- name: 构建内核
working-directory: ${{ env.OPENWRT_ROOT_PATH }}
run: |
make target/compile -j $(($(nproc)+1)) || make target/compile -j$(nproc) V=s || make target/compile -j1 V=s
echo "======================="
echo "空间使用情况:"
echo "======================="
df --total -Th
echo "======================="
- name: 编译并生成安装包
working-directory: ${{ env.OPENWRT_ROOT_PATH }}
run: |
make package/compile -j $(($(nproc)+1)) || make package/compile -j1 V=s
make package/install -j $(($(nproc)+1)) || make package/install -j1 V=s
echo "======================="
echo "空间使用情况:"
echo "======================="
df --total -Th
echo "======================="
du -h --max-depth=1 ./ --exclude=build_dir --exclude=bin
du -h --max-depth=1 ./build_dir
du -h --max-depth=1 ./bin
- name: 准备 artifact
working-directory: ${{ env.OPENWRT_ROOT_PATH }}
run: |
mkdir -p ./artifact/package
echo "artifact-/bin" >> $LOG_PATH/cmzj_package.log
ls -l ./bin/** >> $LOG_PATH/cmzj_package.log
cp -rf $(find ./bin/targets/ -type f -name "*.ipk") ./artifact/package/
rm -rf $(find ./bin/targets/ -type d -name "packages")
cp -rf $(find ./bin/packages/ -type f -name "*.ipk") ./artifact/package/
rm -rf $(find ./artifact/package/ -type f -name "kmod-*")
- name: 上传 package
uses: actions/upload-artifact@v3
with:
name: OpenWrt-package
path: ${{ env.OPENWRT_ROOT_PATH }}/artifact/package/
- name: 收集日志
if: success() || failure()
run: |
mkdir -p openwrt-logs
cp -r $OPENWRT_ROOT_PATH/logs $LOG_PATH/openwrt-logs || echo "没有openwrt/logs"
cp $OPENWRT_ROOT_PATH/.config $LOG_PATH/openwrt.config || echo "没有openwrt/.config"
- name: 上传日志
if: success() || failure()
uses: actions/upload-artifact@v3
with:
name: build-package-${{ needs.prepare.outputs.target }}-${{ needs.prepare.outputs.subtarget }}-logs
path: "${{ env.LOG_PATH }}"
build-Image_Builder:
runs-on: ubuntu-latest
needs: [prepare,build1]
steps:
- name: 将存储库签出到运行器
uses: actions/checkout@v3
- name: 输出运行器硬件信息
run: |
bash $GITHUB_WORKSPACE/scripts/hardware_info.sh
- name: 清理空间
run: |
bash $GITHUB_WORKSPACE/scripts/clear_space.sh
- name: 安装编译依赖
run: |
bash $GITHUB_WORKSPACE/scripts/install_compilation_dependencies.sh
- name: 合并磁盘
run: |
bash $GITHUB_WORKSPACE/scripts/merge_disk.sh
- name: 下载build1_WORKSPACE
uses: actions/download-artifact@v3
with:
name: build1_WORKSPACE
- name: 解压
run: |
sudo mv $GITHUB_WORKSPACE/build1_WORKSPACE.tgz /build1_WORKSPACE.tgz
tar xvpfz /build1_WORKSPACE.tgz -C $GITHUB_WORKSPACE
sudo rm -rf /build1_WORKSPACE.tgz
cat build1_ENV
cat build1_ENV >> $GITHUB_ENV
- name: 环境变量
run: env
- name: 加载自定义配置并生成配置文件
working-directory: ${{ env.OPENWRT_ROOT_PATH }}
run: |
sed -n '/^# CONFIG_PACKAGE_kmod/p' .config | sed '/# CONFIG_PACKAGE_kmod is not set/d'|sed 's/# //g'|sed 's/ is not set/=m/g' |sed 's/kmod-shortcut-fe-cm=m/kmod-shortcut-fe-cm=n/g'|sed 's/kmod-shortcut-fe=m/kmod-shortcut-fe=n/g' |sed 's/kmod-fast-classifier=m/kmod-fast-classifier=n/g' >> .config
make defconfig
sed -n '/^# CONFIG_PACKAGE_kmod/p' .config | sed '/# CONFIG_PACKAGE_kmod is not set/d'|sed 's/# //g'|sed 's/ is not set/=m/g' |sed 's/kmod-shortcut-fe-cm=m/kmod-shortcut-fe-cm=n/g'|sed 's/kmod-shortcut-fe=m/kmod-shortcut-fe=n/g' |sed 's/kmod-fast-classifier=m/kmod-fast-classifier=n/g' >> .config
make defconfig
sed -n '/^# CONFIG_PACKAGE_kmod/p' .config | sed '/# CONFIG_PACKAGE_kmod is not set/d'|sed 's/# //g'|sed 's/ is not set/=m/g' |sed 's/kmod-shortcut-fe-cm=m/kmod-shortcut-fe-cm=n/g'|sed 's/kmod-shortcut-fe=m/kmod-shortcut-fe=n/g' |sed 's/kmod-fast-classifier=m/kmod-fast-classifier=n/g' >> .config
make defconfig
sed -i -n '/CONFIG_PACKAGE_kmod/p' .config
echo CONFIG_IB=y >> .config
echo CONFIG_IB_STANDALONE=y >> .config
cat $GITHUB_WORKSPACE/config/target.config >> $OPENWRT_ROOT_PATH/.config
cat $GITHUB_WORKSPACE/config/image.config >> $OPENWRT_ROOT_PATH/.config
make defconfig
sed -i -e "/^CONFIG_[a-zA-Z0-9]\{1,99\}_IMAGES=y$/s/=y/=cmzjnot/g" -e "/^CONFIG_GRUB_IMAGES=cmzjnot$/s/=cmzjnot/=y/g" -e "/^CONFIG_[a-zA-Z0-9]\{1,99\}_IMAGES=cmzjnot$/s/=cmzjnot/=n/g" .config
sed -i -e "/^CONFIG_TARGET_ROOTFS_TARGZ=y$/s/=y/=n/g" .config
sed -i -e "/^CONFIG_TARGET_ROOTFS_CPIOGZ=y$/s/=y/=n/g" .config
make defconfig
./scripts/diffconfig.sh
- name: 下载 dl 库
working-directory: ${{ env.OPENWRT_ROOT_PATH }}
run: |
make download -j16
find dl -size -1024c -exec ls -l {} \;
find dl -size -1024c -exec rm -f {} \;
make download -j16 || make download -j1 V=s
- name: 构建内核
working-directory: ${{ env.OPENWRT_ROOT_PATH }}
run: |
make target/compile -j $(($(nproc)+1)) || make target/compile -j$(nproc) V=s || make target/compile -j1 V=s
echo "======================="
echo "空间使用情况:"
echo "======================="
df --total -Th
echo "======================="
- name: 清理包
working-directory: ${{ env.OPENWRT_ROOT_PATH }}
run: |
make package/cleanup -j $(($(nproc)+1)) || make package/cleanup -j$(nproc) V=s || make package/cleanup -j1 V=s
echo "======================="
echo "空间使用情况:"
echo "======================="
df --total -Th
echo "======================="
- name: 编译并生成安装包
working-directory: ${{ env.OPENWRT_ROOT_PATH }}
run: |
make package/compile -j $(($(nproc)+1)) || make package/compile -j1 V=s
make package/install -j $(($(nproc)+1)) || make package/install -j1 V=s
echo "======================="
echo "空间使用情况:"
echo "======================="
df --total -Th
echo "======================="
du -h --max-depth=1 ./ --exclude=build_dir --exclude=bin
du -h --max-depth=1 ./build_dir
du -h --max-depth=1 ./bin
- name: 制作Image Builder包
working-directory: ${{ env.OPENWRT_ROOT_PATH }}
run: |
make target/install -j $(($(nproc)+1)) || make target/install -j$(nproc) V=s || make target/install -j1 V=s
echo "======================="
echo "空间使用情况:"
echo "======================="
df --total -Th
echo "======================="
du -h --max-depth=1 ./ --exclude=build_dir --exclude=bin
du -h --max-depth=1 ./build_dir
du -h --max-depth=1 ./bin
- name: 制作包索引、镜像概述信息并计算校验和
working-directory: ${{ env.OPENWRT_ROOT_PATH }}
run: |
make package/index -j $(($(nproc)+1)) || make package/index -j$(nproc) V=s || make package/index -j1 V=s
make json_overview_image_info
make checksum
echo "======================="
echo "空间使用情况:"
echo "======================="
df --total -Th
echo "======================="
du -h --max-depth=1 ./ --exclude=build_dir --exclude=bin
du -h --max-depth=1 ./build_dir
du -h --max-depth=1 ./bin
- name: 准备 artifact
working-directory: ${{ env.OPENWRT_ROOT_PATH }}
run: |
mkdir -p ./artifact/package
mkdir -p ./artifact/kmod
mkdir -p ./artifact/buildinfo
echo "artifact-/bin" >> $LOG_PATH/cmzj_package.log
ls -l ./bin/** >> $LOG_PATH/cmzj_package.log
ls -l ./bin/targets/${{ needs.prepare.outputs.target }}/${{ needs.prepare.outputs.subtarget }}/** >> $LOG_PATH/Image_Builder-bin.log
cp -rf $(find ./bin/targets/ -type f -name "*.buildinfo" -o -name "*.manifest") ./artifact/buildinfo/
cp -rf $(find ./bin/packages/ -type f -name "*.ipk") ./artifact/package/
cp -rf $(find ./bin/targets/ -type f -name "*.ipk") ./artifact/package/
cp -rf $(find ./artifact/package/ -type f -name "kmod-*") ./artifact/kmod/
- name: 上传 kmod
uses: actions/upload-artifact@v3
with:
name: OpenWrt-kmod
path: ${{ env.OPENWRT_ROOT_PATH }}/artifact/kmod/
- name: 上传 Image Builder
uses: actions/upload-artifact@v3
with:
name: OpenWrt-Image_Builder
path: ${{ env.OPENWRT_ROOT_PATH }}/bin/targets/${{ needs.prepare.outputs.target }}/${{ needs.prepare.outputs.subtarget }}/openwrt-imagebuilder-${{ needs.prepare.outputs.target }}-${{ needs.prepare.outputs.subtarget }}.Linux-${{ needs.prepare.outputs.target }}_${{ needs.prepare.outputs.subtarget }}.tar.xz
- name: 收集日志
if: success() || failure()
run: |
mkdir -p openwrt-logs
cp -r $OPENWRT_ROOT_PATH/logs $LOG_PATH/openwrt-logs || echo "没有openwrt/logs"
cp $OPENWRT_ROOT_PATH/.config $LOG_PATH/openwrt.config || echo "没有openwrt/.config"
- name: 上传日志
if: success() || failure()
uses: actions/upload-artifact@v3
with:
name: build-Image_Builder-${{ needs.prepare.outputs.target }}-${{ needs.prepare.outputs.subtarget }}-logs
path: "${{ env.LOG_PATH }}"
build-Image:
runs-on: ubuntu-latest
needs: [prepare,build1,build-package,build-Image_Builder]
steps:
- name: 将存储库签出到运行器
uses: actions/checkout@v3
- name: 输出运行器硬件信息
run: |
bash $GITHUB_WORKSPACE/scripts/hardware_info.sh
- name: 清理空间
run: |
bash $GITHUB_WORKSPACE/scripts/clear_space.sh
- name: 安装编译依赖
run: |
bash $GITHUB_WORKSPACE/scripts/install_compilation_dependencies.sh
- name: 合并磁盘
run: |
bash $GITHUB_WORKSPACE/scripts/merge_disk.sh
- name: 将存储库签出到运行器
uses: actions/checkout@v3
- name: 下载Image Builder
uses: actions/download-artifact@v3
with:
name: OpenWrt-Image_Builder
- name: 下载包
uses: actions/download-artifact@v3
with:
name: OpenWrt-package
path: ${{ github.workspace }}/package/
- name: 下载build1配置文件
uses: actions/download-artifact@v3
with:
name: build1_openwrt_config
- name: 下载 files
uses: actions/download-artifact@v3
with:
name: build1_openwrt_files
- name: 建立日志文件夹
run: |
cd $GITHUB_WORKSPACE
mkdir -p log
cd log
export LOG_PATH="$(pwd)"
echo "LOG_PATH=$LOG_PATH" >> $GITHUB_ENV
- name: 解压
run: |
tar -xvJf openwrt-imagebuilder-${{ needs.prepare.outputs.target }}-${{ needs.prepare.outputs.subtarget }}.Linux-${{ needs.prepare.outputs.target }}_${{ needs.prepare.outputs.subtarget }}.tar.xz
cd openwrt-imagebuilder-${{ needs.prepare.outputs.target }}-${{ needs.prepare.outputs.subtarget }}.Linux-${{ needs.prepare.outputs.target }}_${{ needs.prepare.outputs.subtarget }}
export IMAGE_BUILDER_ROOT_PATH="$(pwd)"
echo "IMAGE_BUILDER_ROOT_PATH=$IMAGE_BUILDER_ROOT_PATH" >> $GITHUB_ENV
mkdir -p $IMAGE_BUILDER_ROOT_PATH/files
cd $GITHUB_WORKSPACE
tar xvpfz $GITHUB_WORKSPACE/openwrt_files.tgz -C $IMAGE_BUILDER_ROOT_PATH/files
- name: 环境变量
run: env
- name: 复制package到build-Image_Builder
run: |
cd $GITHUB_WORKSPACE/package/
rm -rf $(ls $IMAGE_BUILDER_ROOT_PATH/packages)
rm -rf kernel_*
cd $GITHUB_WORKSPACE
cp $GITHUB_WORKSPACE/package/* $IMAGE_BUILDER_ROOT_PATH/packages/
- name: 制作包列表
run: sed -n "/^CONFIG_PACKAGE_[-a-zA-Z0-9]\{1,99\}=y$/p" build1.config | sed -e "s/CONFIG_PACKAGE_//g" -e "s/=y//g" | sed ':label;N;s/\n/ /;b label' > package.list
- name: 覆盖配置文件
run: |
rm -rf $IMAGE_BUILDER_ROOT_PATH/.config
cat build1.config > $IMAGE_BUILDER_ROOT_PATH/.config
- name: 镜像信息
working-directory: ${{ env.IMAGE_BUILDER_ROOT_PATH }}
run: |
echo "可用目标配置文件的列表"
make info
echo "安装的包列表"
make manifest PACKAGES="$(cat $GITHUB_WORKSPACE/package.list)"
- name: 构建镜像
working-directory: ${{ env.IMAGE_BUILDER_ROOT_PATH }}
run: |
make image FILES="$IMAGE_BUILDER_ROOT_PATH/files" PACKAGES="$(cat $GITHUB_WORKSPACE/package.list)"
echo "======================="
echo "空间使用情况:"
echo "======================="
df --total -Th
echo "======================="
du -h --max-depth=1 ./ --exclude=bin
du -h --max-depth=1 ./bin
- name: 准备 artifact
working-directory: ${{ env.IMAGE_BUILDER_ROOT_PATH }}
run: |
mkdir -p ./artifact/buildinfo
echo "artifact-/bin" >> $LOG_PATH/cmzj_package.log
ls -l ./bin/targets/${{ needs.prepare.outputs.target }}/${{ needs.prepare.outputs.subtarget }}/** >> $LOG_PATH/Image_Builder-bin.log
cp -rf $(find ./bin/targets/ -type f -name "*.buildinfo" -o -name "*.manifest") ./artifact/buildinfo/
- name: 上传 firmware
uses: actions/upload-artifact@v3
with:
name: OpenWrt-firmware
path: ${{ env.IMAGE_BUILDER_ROOT_PATH }}/bin/targets/
- name: 上传 buildinfo
uses: actions/upload-artifact@v3
with:
name: OpenWrt-buildinfo
path: ${{ env.IMAGE_BUILDER_ROOT_PATH }}/artifact/buildinfo/
- name: 收集日志
if: success() || failure()
run: |
mkdir -p openwrt-logs
cp -r $IMAGE_BUILDER_ROOT_PATH/logs $LOG_PATH/openwrt-logs || echo "没有openwrt/logs"
cp $IMAGE_BUILDER_ROOT_PATH/.config $LOG_PATH/openwrt.config || echo "没有openwrt/.config"
- name: 上传日志
if: success() || failure()
uses: actions/upload-artifact@v3
with:
name: build-Image-${{ needs.prepare.outputs.target }}-${{ needs.prepare.outputs.subtarget }}-logs
path: "${{ env.LOG_PATH }}"
upload:
needs: [prepare,build1,build-package,build-Image_Builder,build-Image]
runs-on: ubuntu-22.04
steps:
- name: 将存储库签出到运行器
uses: actions/checkout@v3
- name: 建立工作文件夹
run: |
cd $GITHUB_WORKSPACE
sudo mkdir -p upload
sudo chown $USER:$GROUPS upload
cd upload
export UPLOAD_ROOT_PATH="$(pwd)"
echo "UPLOAD_ROOT_PATH=$UPLOAD_ROOT_PATH" >> $GITHUB_ENV
cd $GITHUB_WORKSPACE
mkdir -p packagecompare
cd packagecompare
export PACKAGECOMPARE_ROOT_PATH="$(pwd)"
echo "PACKAGECOMPARE_ROOT_PATH=$PACKAGECOMPARE_ROOT_PATH" >> $GITHUB_ENV
- name: 初始化环境
run: |
sudo -E apt update
sudo -E apt install -y git aria2 zip bzip2 curl rsync unzip wget || sudo -E apt install -y git aria2 zip bzip2 curl rsync unzip wget
sudo timedatectl set-timezone "Asia/Shanghai"
- name: 生成 release 所需变量
working-directory: ${{ env.UPLOAD_ROOT_PATH }}
run: |
export OPENWRT_TAG_BRANCHE="$(sed -n '/openwrt_tag\/branche/p' $GITHUB_WORKSPACE/OpenWrt-K.Config | sed -e 's/.*=//')"
echo "OPENWRT_TAG_BRANCHE=$OPENWRT_TAG_BRANCHE" >> $GITHUB_ENV
export RELEASE_NAME="OpenWrt-K_V${{ needs.prepare.outputs.starttime }} (${{ needs.prepare.outputs.target }}-${{ needs.prepare.outputs.subtarget }})-[$OPENWRT_TAG_BRANCHE]"
echo "RELEASE_NAME=$RELEASE_NAME" >> $GITHUB_ENV
export RELEASE_TAG_NAME="v${{ needs.prepare.outputs.starttime }}(${{ needs.prepare.outputs.target }}-${{ needs.prepare.outputs.subtarget }})-($OPENWRT_TAG_BRANCHE)"
echo "RELEASE_TAG_NAME=$RELEASE_TAG_NAME" >> $GITHUB_ENV
- name: 下载固件
uses: actions/download-artifact@v3
with:
name: OpenWrt-firmware
path: ${{ env.UPLOAD_ROOT_PATH }}
- name: 下载包
uses: actions/download-artifact@v3
with:
name: OpenWrt-package
path: ${{ env.UPLOAD_ROOT_PATH }}/package
- name: 下载内核模块
uses: actions/download-artifact@v3
with:
name: OpenWrt-kmod
path: ${{ env.UPLOAD_ROOT_PATH }}/kmod
- name: 整理包
working-directory: ${{ env.UPLOAD_ROOT_PATH }}
run: |
mkdir package-upload
zip -r ./package-upload/package.zip package
zip -r ./package-upload/allkmod.zip kmod
- name: 整理包生成 release body
run: |
echo 编译完成于$(date +"%Y-%m-%d %H:%M") >> $UPLOAD_ROOT_PATH/release.txt
echo "编译的openwrt版本/分支: " $OPENWRT_TAG_BRANCHE >> $UPLOAD_ROOT_PATH/release.txt
latest_ver="$(curl -s https://api.github.com/repos/${{ github.repository }}/releases 2>/dev/null | grep -E 'tag_name' | grep -E '(${{ needs.prepare.outputs.target }}-${{ needs.prepare.outputs.subtarget }})' | grep -E "($OPENWRT_TAG_BRANCHE)" | sed -e 's/ "tag_name": "//' -e 's/",//' | sed -n '1p')"
echo latest_ver=$latest_ver
rm -rf $PACKAGECOMPARE_ROOT_PATH/*
wget https://github.com/${{ github.repository }}/releases/download/${latest_ver}/allkmod.zip -O $PACKAGECOMPARE_ROOT_PATH/allkmod.zip -nv || wget https://github.com/${{ github.repository }}/releases/download/$(curl -s https://api.github.com/repos/${{ github.repository }}/releases 2>/dev/null | grep -E 'tag_name' | grep -E '(${{ needs.prepare.outputs.target }}-${{ needs.prepare.outputs.subtarget }})' | grep -E "($OPENWRT_TAG_BRANCHE)" | sed -e 's/ "tag_name": "//' -e 's/",//' | sed -n '1p')/allkmod.zip -O $PACKAGECOMPARE_ROOT_PATH/allkmod.zip -nv || exit 0
wget https://github.com/${{ github.repository }}/releases/download/${latest_ver}/package.zip -O $PACKAGECOMPARE_ROOT_PATH/package.zip -nv || wget https://github.com/${{ github.repository }}/releases/download/$(curl -s https://api.github.com/repos/${{ github.repository }}/releases 2>/dev/null | grep -E 'tag_name' | grep -E '(${{ needs.prepare.outputs.target }}-${{ needs.prepare.outputs.subtarget }})' | grep -E "($OPENWRT_TAG_BRANCHE)" | sed -e 's/ "tag_name": "//' -e 's/",//' | sed -n '1p')/package.zip -O $PACKAGECOMPARE_ROOT_PATH/package.zip -nv || exit 0
cd $PACKAGECOMPARE_ROOT_PATH
unzip package.zip
unzip allkmod.zip
mv package oldpackage
mv kmod oldkmod
cp -rf oldkmod/* oldpackage/
ls $PACKAGECOMPARE_ROOT_PATH/oldpackage/|sort| uniq >oldpackage.list
sed -i -e "s/_${{ needs.prepare.outputs.target }}_${{ needs.prepare.outputs.subtarget }}.ipk//g" -e "s/_all.ipk//g" oldpackage.list
rm -rf $PACKAGECOMPARE_ROOT_PATH/package.zip
rm -rf $PACKAGECOMPARE_ROOT_PATH/allkmod.zip
cp -f $UPLOAD_ROOT_PATH/package-upload/package.zip $PACKAGECOMPARE_ROOT_PATH/package.zip
cp -f $UPLOAD_ROOT_PATH/package-upload/allkmod.zip $PACKAGECOMPARE_ROOT_PATH/allkmod.zip
unzip package.zip
unzip allkmod.zip
mv package newpackage
mv kmod newkmod
cp -rf newkmod/* newpackage/
ls $PACKAGECOMPARE_ROOT_PATH/newpackage/|sort| uniq >newpackage.list
sed -i -e "s/_${{ needs.prepare.outputs.target }}_${{ needs.prepare.outputs.subtarget }}.ipk//g" -e "s/_all.ipk//g" newpackage.list && echo "list complete"
echo "内核版本: "$(sed -n '/kernel_/p' newpackage.list | sed -e 's/kernel_//') >> $UPLOAD_ROOT_PATH/release.txt
echo "包更改/版本升级列表" >> $UPLOAD_ROOT_PATH/release.txt
diff oldpackage.list newpackage.list -y -W 80 -B -b |grep -E '[\|><]' >diff.temp && echo "Compare complete" || echo "没有包新增删除或版本升级" >> $UPLOAD_ROOT_PATH/release.txt
sed -e "/</s/^/delete:/g" -e "/|/s/^/update:/g" -e "/>/s/^/Add:/g" -e 's/[[:space:]]//g' -e 's/<//g' -e 's/>//g' -e 's/|/ > /g' -e 's/> [a-zA-Z0-9\-]*_/> /g' -e 's/_/ /g' diff.temp >> $UPLOAD_ROOT_PATH/release.txt || echo "没有包新增删除或版本升级"
- name: 上传固件到 Release
id: firmware-release
uses: softprops/action-gh-release@v0.1.15
with:
name: ${{ env.RELEASE_NAME }}
tag_name: ${{ env.RELEASE_TAG_NAME }}
files: |
${{ env.UPLOAD_ROOT_PATH }}/${{ needs.prepare.outputs.target }}/${{ needs.prepare.outputs.subtarget }}/*
${{ env.UPLOAD_ROOT_PATH }}/package-upload/*
body_path: ${{ env.UPLOAD_ROOT_PATH }}/release.txt
- name: 删除旧的Releases
uses: dev-drprasad/delete-older-releases@v0.2.1
with:
keep_latest: 10
delete_tags: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}