Skip to content

ZN-M2

ZN-M2 #93

Workflow file for this run

#
# httpsgithub.comP3TERXActions-OpenWrt
#
# File .githubworkflowsopenwrt-bulder.yml
# Description Build OpenWrt using GitHub Actions
#
# Copyright (c) 2019-2024 P3TERX httpsp3terx.com
#
# This is free software, licensed under the MIT License.
# See LICENSE for more information.
#
name: ZN-M2
on:
repository_dispatch:
workflow_dispatch:
inputs:
env:
REPO_URL: https://github.com/try496/openwrt.git
REPO_BRANCH: openwrt-24.10
CONFIG_FILE: config/ZN-M2.config
DIY_SCRIPT: zn.sh
UPLOAD_BIN_DIR: false
UPLOAD_FIRMWARE: true
UPLOAD_RELEASE: true
TZ: Asia/Shanghai
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: 检查分支
uses: actions/checkout@main
- name: 编译环境
env:
DEBIAN_FRONTEND: noninteractive
run: |
sudo -E apt-get -qq update
sudo -E apt-get -y -qq install asciidoc bash bcc bin86 binutils bison bzip2 clang-15 llvm-15 clang llvm file flex g++ g++-multilib gawk gcc gcc-multilib gettext git gzip help2man intltool libboost-dev libelf-dev libncurses-dev libncurses5-dev libssl-dev libthread-queue-any-perl libusb-dev libxml-parser-perl make patch perl-modules python3-dev python3-pip python3-pyelftools python3-setuptools rsync sharutils swig time unzip util-linux wget xsltproc zlib1g-dev zip zstd
sudo -E apt-get -y -qq install dos2unix dwarves quilt npm jq
sudo -E npm install -g pnpm
pip3 install --user -U pylibfdt --break-system-packages
sudo -E apt-get -qq autoremove --purge
sudo -E apt-get -qq clean
sudo timedatectl set-timezone "$TZ"
sudo mkdir -p /workdir
sudo chown $USER:$GROUPS /workdir
df -h
- name: 克隆源代码
working-directory: /workdir
run: |
df -hT $PWD
git clone $REPO_URL -b $REPO_BRANCH openwrt
ln -sf /workdir/openwrt $GITHUB_WORKSPACE/openwrt
- name: 加载软件源
working-directory: ./openwrt
run: |
./scripts/feeds update -a
./scripts/feeds install -a
- name: 加载自定义配置
run: |
[ -e files ] && mv files openwrt/files
[ -e $CONFIG_FILE ] && mv $CONFIG_FILE openwrt/.config
cat $EXTRA_CONFIG >> openwrt/.config
chmod +x $DIY_SCRIPT
cd openwrt
$GITHUB_WORKSPACE/$DIY_SCRIPT
- name: 下载软件
id: package
run: |
cd openwrt
make defconfig
make download -j8
find dl -size -1024c -exec ls -l {} \;
find dl -size -1024c -exec rm -f {} \;
- name: 开始编译
id: compile
run: |
cd openwrt
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
- name: 查看磁盘使用情况
if: (!cancelled())
run: df -hT
- name: 整理文件
id: organize
if: env.UPLOAD_FIRMWARE == 'true' && !cancelled()
run: |
cd openwrt/bin/targets/*/*
rm -rf packages
echo "FIRMWARE=$PWD" >> $GITHUB_ENV
echo "status=success" >> $GITHUB_OUTPUT
- name: 上传文件到Actions
uses: actions/upload-artifact@main
if: steps.organize.outputs.status == 'success' && !cancelled()
with:
name: OpenWrt_firmware${{ env.DEVICE_NAME }}${{ env.FILE_DATE }}
path: ${{ env.FIRMWARE }}
- name: 生成Releases标签
id: tag
if: env.UPLOAD_RELEASE == 'true' && !cancelled()
run: |
echo "release_tag=$(date +"%Y.%m.%d-%H%M")" >> $GITHUB_OUTPUT
touch release.txt
[ ${UPLOAD_GOFILE} = true && ${{ steps.gofile.outputs.url }} ] && echo "🔗 [GoFile](${{ steps.gofile.outputs.url }})" >> release.txt
echo "status=success" >> $GITHUB_OUTPUT
- name: 上传固件到Releases
uses: softprops/action-gh-release@master
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: 清理Releases
uses: dev-drprasad/delete-older-releases@master
if: env.UPLOAD_RELEASE == 'true' && !cancelled()
with:
keep_latest: 6
delete_tags: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}