Skip to content

Build ImmortalWrt-mt798x #22

Build ImmortalWrt-mt798x

Build ImmortalWrt-mt798x #22

#
# 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 ImmortalWrt-mt798x
permissions: write-all
# 开启写权限,防止无法上传到release
on:
workflow_dispatch:
inputs:
USE_MTWIFI_CFG:
description: 'Use mtwifi-cfg'
required: true
default: true
type: boolean
USE_NX30PRO_EEPROM:
description: 'Use nx30pro eeprom'
required: true
default: true
type: boolean
env:
REPO_URL: https://github.com/GD-Slime/immortalwrt-mt798x
FREE_DISK_SH: scripts/free_disk_space.sh
ENV_SH: scripts/environment.sh
DIY_SH: scripts/diy.sh
UPLOAD_BIN_DIR: false
UPLOAD_FIRMWARE: false
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: |
echo "USE_MTWIFI_CFG=${{ github.event.inputs.USE_MTWIFI_CFG }}" >> $GITHUB_ENV
echo "USE_NX30PRO_EEPROM=${{ github.event.inputs.USE_NX30PRO_EEPROM }}" >> $GITHUB_ENV
chmod +x $FREE_DISK_SH && $FREE_DISK_SH
sudo rm -rf /usr/share/dotnet /usr/local/lib/android /opt/ghc
sudo -E apt-get -qq update -y
sudo -E apt-get -qq full-upgrade -y
chmod +x $ENV_SH && $ENV_SH
sudo timedatectl set-timezone "$TZ"
sudo mkdir -p /workdir
sudo chown $USER:$GROUPS /workdir
- name: 检查空间使用情况
if: (!cancelled())
run: df -hT
- name: 克隆源码
working-directory: /workdir
run: |
git clone $REPO_URL openwrt
ln -sf /workdir/openwrt $GITHUB_WORKSPACE/openwrt
- name: 开启缓存
uses: klever1988/cachewrtbuild@main
with:
ccache: 'true'
mixkey: 'openwrt21-cortexa53'
prefix: ${{ github.workspace }}/openwrt
- name: 更新 & 安装 feeds & 执行脚本
run: |
cd openwrt
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
#git fetch https://github.com/padavanonly/immortalwrt-mt798x
#git merge FETCH_HEAD
sed -i '$a src-git smpackage https://github.com/kenzok8/small-package' feeds.conf.default
sed -i '$a src-git istore https://github.com/linkease/istore;main' feeds.conf.default
./scripts/feeds update -a && ./scripts/feeds install -a
# 防止包冲突
rm -rf feeds/smpackage/{base-files,dnsmasq,firewall*,fullconenat,libnftnl,nftables,ppp,opkg,ucl,upx,vsftpd-alt,miniupnpd-iptables,wireless-regdb}
# 替换原版 mosdns 防止 luci 界面编译失败
rm -rf ./feeds/packages/net/mosdns && cp -r -f ./feeds/smpackage/mosdns ./feeds/packages/net/mosdns
# 安装 golang 1.20
rm -rf feeds/packages/lang/golang && git clone https://github.com/sbwml/packages_lang_golang -b 20.x feeds/packages/lang/golang
# 重新安装一次 防止依赖错误
./scripts/feeds install -a
chmod +x $GITHUB_WORKSPACE/$DIY_SH && $GITHUB_WORKSPACE/$DIY_SH
- name: 导入补丁和配置
run: |
[ -e files ] && mv files openwrt/files
cat configs/rax3000m-emmc_mtksdk.config >> openwrt/.config
- name: 设置无线控制界面样式
if: env.USE_MTWIFI_CFG == 'true'
run: |
sed -i '/CONFIG_PACKAGE_luci-app-mtk=y/{N;N;N;s/CONFIG_PACKAGE_luci-app-mtk=y\nCONFIG_PACKAGE_luci-i18n-mtk-zh-cn=y\nCONFIG_PACKAGE_wifi-profile=y\nCONFIG_WIFI_NORMAL_SETTING=y/CONFIG_PACKAGE_lua-cjson=y\nCONFIG_PACKAGE_luci-app-mtwifi-cfg=y\nCONFIG_PACKAGE_luci-i18n-mtwifi-cfg-zh-cn=y\nCONFIG_PACKAGE_mtwifi-cfg=y/}' openwrt/.config
- name: 下载文件
run: |
cd openwrt
# chmod +x $GITHUB_WORKSPACE/$CLASH_CORE && $GITHUB_WORKSPACE/$CLASH_CORE
make defconfig
make download -j8 V=10
find dl -size -1024c -exec ls -l {} \;
find dl -size -1024c -exec rm -f {} \;
- name: 编译固件中
id: compile
run: |
cd openwrt
echo -e "$(($(nproc)+1)) thread compile"
make -j$(($(nproc)+1)) || make -j$(nproc) || make -j1 V=s
echo "status=success" >> $GITHUB_OUTPUT
- 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: OpenWrt_bin${{ env.DEVICE_NAME }}${{ env.FILE_DATE }}
path: openwrt/bin
- name: 整理文件
id: organize
if: steps.compile.outputs.status == 'success'
run: |
cd openwrt/bin/targets/*/*
rm -rf *.buildinfo
rm -rf *.json
rm -rf *.manifest
rm -rf packages
echo "FIRMWARE=$PWD" >> $GITHUB_ENV
echo "status=success" >> $GITHUB_OUTPUT
- name: 上传固件目录
uses: actions/upload-artifact@main
if: env.UPLOAD_FIRMWARE == 'true' && steps.organize.outputs.status == 'success' && !cancelled()
with:
name: OpenWrt_firmware${{ env.DEVICE_NAME }}${{ env.FILE_DATE }}
path: ${{ env.FIRMWARE }}
- name: 生成发布标签
id: tag
if: env.UPLOAD_RELEASE == 'true' && steps.compile.outputs.status == 'success' && !cancelled()
run: |
echo -e "### immortalwrt-mt7981-cmcc_rax3000m-nand" >> release.txt
wlan_luci_interface=""
if grep -q 'CONFIG_PACKAGE_mtwifi-cfg=y' openwrt/.config; then
echo "- 使用 OpenWrt 原生无线控制界面" >> release.txt
wlan_luci_interface="mtwifi-cfg"
else
echo "- 使用 MTK SDK 无线控制界面" >> release.txt
wlan_luci_interface="luci-app-mtk"
fi
eeprom_status=""
echo "- eeprom 使用 H3C NX30 Pro 提取版本" >> release.txt
eeprom_status="nx30pro_eeprom"
release_tag=$(date +"%Y.%m.%d-mt7981-cmcc_rax3000m-nand-${wlan_luci_interface}-${eeprom_status}")
echo "release_tag=${release_tag}" >> $GITHUB_OUTPUT
echo "status=success" >> $GITHUB_OUTPUT
- name: 上传固件发布
uses: softprops/action-gh-release@v1
if: steps.tag.outputs.status == 'success' && !cancelled()
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.tag.outputs.release_tag }}
body_path: release.txt
files: ${{ env.FIRMWARE }}/*
- name: 删除旧发布的固件
uses: dev-drprasad/[email protected]
if: steps.compile.outputs.status == 'success' && env.UPLOAD_RELEASE == 'true' && !cancelled()
with:
keep_latest: 7
delete_tags: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: 删除过时工作流程
uses: Mattraks/delete-workflow-runs@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
repository: ${{ github.repository }}
retain_days: 1
keep_minimum_runs: 3