2022-03-21 15:43:00 +00:00
|
|
|
###########################################################
|
|
|
|
# Description: Compile OpenWrt by GitHub Actions #
|
|
|
|
# Based on: https://github.com/P3TERX/Actions-OpenWrt #
|
|
|
|
# Author: Hyy2001X #
|
|
|
|
###########################################################
|
|
|
|
|
|
|
|
name: Redmi AX6S
|
|
|
|
|
2022-05-06 08:46:16 +00:00
|
|
|
### 以下内容请保持不变 ( 请修改下方的 [环境变量设置] )
|
2022-03-21 15:43:00 +00:00
|
|
|
on:
|
|
|
|
repository_dispatch:
|
|
|
|
workflow_dispatch:
|
|
|
|
inputs:
|
|
|
|
Tempoary_IP:
|
|
|
|
description: '固件 IP 地址 [可选]'
|
|
|
|
default: ''
|
|
|
|
Tempoary_CONFIG:
|
|
|
|
description: '配置文件 [可选]'
|
|
|
|
default: ''
|
|
|
|
Tempoary_FLAG:
|
2022-05-06 08:46:16 +00:00
|
|
|
description: '固件标签 [可选]'
|
2022-03-21 15:43:00 +00:00
|
|
|
default: ''
|
2022-05-06 08:46:16 +00:00
|
|
|
### 控制部分结束 ( 以上内容请保持不变 )
|
2022-03-21 15:43:00 +00:00
|
|
|
|
|
|
|
#push:
|
|
|
|
# branches:
|
|
|
|
# - master
|
|
|
|
|
|
|
|
#schedule:
|
|
|
|
# - cron: 0 8 * * 5
|
|
|
|
|
|
|
|
#watch:
|
|
|
|
# types: [started]
|
|
|
|
|
|
|
|
### 环境变量设置
|
|
|
|
env:
|
|
|
|
# 编译时调用的 [.config] 文件名称
|
|
|
|
CONFIG_FILE: xiaomi_redmi-router-ax6s
|
|
|
|
# 源码仓库:分支
|
2022-04-14 11:05:23 +00:00
|
|
|
DEFAULT_SOURCE: coolsnowwolf/lede:master
|
2022-03-21 15:43:00 +00:00
|
|
|
# 上传固件到 Github Releases
|
|
|
|
UPLOAD_RELEASES: true
|
|
|
|
# 上传固件到 Github Artifacts
|
|
|
|
UPLOAD_ARTIFACTS: false
|
|
|
|
# 上传 bin 文件夹到 Github Artifacts
|
|
|
|
UPLOAD_BIN_ARTIFACTS: false
|
|
|
|
# 删除无用文件以增加编译空间
|
|
|
|
DELETE_USELESS_FILES: true
|
|
|
|
# 删除早期的 workflow 任务
|
2022-05-26 12:33:42 +00:00
|
|
|
DELETE_OLD_WORKFLOW: false
|
2022-08-31 14:19:39 +00:00
|
|
|
# Cache 加速编译
|
|
|
|
CACHE_ACCELERATE: true
|
2022-03-21 15:43:00 +00:00
|
|
|
### 结束
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
Compile:
|
2024-09-22 07:38:15 +00:00
|
|
|
runs-on: ubuntu-latest
|
2022-05-03 13:43:40 +00:00
|
|
|
permissions:
|
|
|
|
issues: write
|
|
|
|
pull-requests: write
|
|
|
|
contents: write
|
|
|
|
|
2022-03-21 15:43:00 +00:00
|
|
|
steps:
|
|
|
|
- name: Maximize Build Space
|
2022-08-31 14:19:39 +00:00
|
|
|
if: env.DELETE_USELESS_FILES == 'true' && !cancelled()
|
2022-03-21 15:43:00 +00:00
|
|
|
uses: easimon/maximize-build-space@master
|
|
|
|
with:
|
|
|
|
root-reserve-mb: 5120
|
|
|
|
swap-size-mb: 512
|
|
|
|
remove-dotnet: 'true'
|
|
|
|
remove-android: 'true'
|
2022-08-31 14:19:39 +00:00
|
|
|
remove-haskell: 'true'
|
2022-03-21 15:43:00 +00:00
|
|
|
|
|
|
|
- name: Checkout
|
|
|
|
uses: actions/checkout@main
|
2022-08-31 14:19:39 +00:00
|
|
|
with:
|
|
|
|
fetch-depth: 0
|
2022-03-21 15:43:00 +00:00
|
|
|
|
2022-08-31 14:19:39 +00:00
|
|
|
- name: Load Custom Variables
|
2022-03-21 15:43:00 +00:00
|
|
|
run: |
|
|
|
|
echo "Free space:"
|
|
|
|
df -h
|
|
|
|
if [ -n "${{ github.event.inputs.Tempoary_CONFIG }}" ]
|
|
|
|
then
|
|
|
|
if [ -f "$GITHUB_WORKSPACE/Configs/${{ github.event.inputs.Tempoary_CONFIG }}" ]
|
|
|
|
then
|
|
|
|
CONFIG_FILE=${{ github.event.inputs.Tempoary_CONFIG }}
|
|
|
|
else
|
|
|
|
CONFIG_FILE=${{ env.CONFIG_FILE }}
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
CONFIG_FILE=${{ env.CONFIG_FILE }}
|
|
|
|
fi
|
|
|
|
if [ ! -f "$GITHUB_WORKSPACE/Configs/$CONFIG_FILE" ]
|
|
|
|
then
|
2022-08-31 14:19:39 +00:00
|
|
|
echo "CONFIG_FILE: [/Config/$CONFIG_FILE] is not detected ..."
|
2022-03-21 15:43:00 +00:00
|
|
|
exit 1
|
|
|
|
else
|
|
|
|
echo "CONFIG_FILE: [/Config/$CONFIG_FILE]"
|
|
|
|
echo "CONFIG_FILE=$CONFIG_FILE" >> $GITHUB_ENV
|
|
|
|
fi
|
|
|
|
if [ -n "${{ github.event.inputs.Tempoary_IP }}" ]
|
|
|
|
then
|
|
|
|
echo "IP: [${{ github.event.inputs.Tempoary_IP }}]"
|
|
|
|
echo "Tempoary_IP=${{ github.event.inputs.Tempoary_IP }}" >> $GITHUB_ENV
|
|
|
|
fi
|
|
|
|
if [ -n "${{ github.event.inputs.Tempoary_FLAG }}" ]
|
|
|
|
then
|
|
|
|
echo "FLAG: [${{ github.event.inputs.Tempoary_FLAG }}]"
|
|
|
|
echo "Tempoary_FLAG=${{ github.event.inputs.Tempoary_FLAG }}" >> $GITHUB_ENV
|
|
|
|
fi
|
2022-08-31 14:19:39 +00:00
|
|
|
REPO_URL="https://github.com/$(cut -d \: -f 1 <<< ${{ env.DEFAULT_SOURCE }})"
|
|
|
|
REPO_BRANCH=$(cut -d \: -f 2 <<< ${{ env.DEFAULT_SOURCE }})
|
2022-03-21 15:43:00 +00:00
|
|
|
echo "REPO_URL=$REPO_URL" >> $GITHUB_ENV
|
|
|
|
echo "REPO_BRANCH=$REPO_BRANCH" >> $GITHUB_ENV
|
|
|
|
echo "Compile_Date=$(date +%Y%m%d%H%M)" >> $GITHUB_ENV
|
|
|
|
echo "Display_Date=$(date +%Y/%m/%d)" >> $GITHUB_ENV
|
|
|
|
|
2022-08-31 14:19:39 +00:00
|
|
|
- name: Initialize Environment
|
2022-03-21 15:43:00 +00:00
|
|
|
env:
|
|
|
|
DEBIAN_FRONTEND: noninteractive
|
|
|
|
run: |
|
|
|
|
sudo -E apt-get update
|
2024-09-22 07:54:00 +00:00
|
|
|
sudo -E apt-get -y install busybox build-essential cmake asciidoc binutils bzip2 gawk gettext git libncurses5-dev zlib1g-dev patch unzip zlib1g-dev lib32gcc-s1 libc6-dev-i386 subversion flex uglifyjs git gcc-multilib g++-multilib p7zip p7zip-full msmtp libssl-dev texinfo libreadline-dev libglib2.0-dev xmlto qemu-utils upx-ucl libelf-dev autoconf automake libtool autopoint ccache curl wget vim nano python3 python3-pip python3-ply haveged lrzsz device-tree-compiler scons antlr3 gperf intltool genisoimage rsync
|
2022-03-21 15:43:00 +00:00
|
|
|
sudo timedatectl set-timezone "Asia/Shanghai"
|
|
|
|
sudo mkdir -p /workdir
|
|
|
|
sudo chown $USER:$GROUPS /workdir
|
|
|
|
if [ "${{ env.DELETE_USELESS_FILES }}" == true ]
|
|
|
|
then
|
|
|
|
docker rmi $(docker images -q)
|
|
|
|
sudo rm -rf /usr/share/dotnet /etc/mysql /etc/php
|
|
|
|
sudo -E apt-get -y autoremove --purge
|
|
|
|
sudo -E apt-get clean
|
|
|
|
fi
|
|
|
|
|
|
|
|
- name: Clone Openwrt Source Code
|
|
|
|
run: |
|
|
|
|
git clone -b $REPO_BRANCH $REPO_URL openwrt
|
|
|
|
ln -sf /workdir/openwrt $GITHUB_WORKSPACE/openwrt
|
|
|
|
cd openwrt
|
|
|
|
./scripts/feeds update -a
|
|
|
|
./scripts/feeds install -a
|
|
|
|
|
2022-08-31 14:19:39 +00:00
|
|
|
- name: Accelerate
|
|
|
|
if: env.CACHE_ACCELERATE == 'true'
|
|
|
|
uses: klever1988/cachewrtbuild@main
|
|
|
|
with:
|
|
|
|
ccache: false
|
|
|
|
toolchain: true
|
|
|
|
skip: true
|
|
|
|
clean: false
|
|
|
|
prefix: ${{ github.workspace }}/openwrt
|
|
|
|
|
|
|
|
- name: Run Diy Scripts
|
2022-03-21 15:43:00 +00:00
|
|
|
run: |
|
|
|
|
chmod +x Scripts/AutoBuild_*.sh
|
|
|
|
cd openwrt
|
2022-08-31 14:19:39 +00:00
|
|
|
if [ "${{ env.CACHE_ACCELERATE }}" == true ]
|
|
|
|
then
|
2024-12-08 15:05:49 +00:00
|
|
|
echo -e "\nCONFIG_DEVEL=y\nCONFIG_CCACHE=n\n" >> $GITHUB_WORKSPACE/Configs/$CONFIG_FILE
|
2022-08-31 14:19:39 +00:00
|
|
|
fi
|
|
|
|
cp $GITHUB_WORKSPACE/Configs/$CONFIG_FILE .config
|
2022-03-21 15:43:00 +00:00
|
|
|
source $GITHUB_WORKSPACE/Scripts/AutoBuild_DiyScript.sh
|
|
|
|
source $GITHUB_WORKSPACE/Scripts/AutoBuild_Function.sh
|
2022-08-31 14:19:39 +00:00
|
|
|
make defconfig
|
2022-03-21 15:43:00 +00:00
|
|
|
Firmware_Diy_Before
|
2022-08-31 14:19:39 +00:00
|
|
|
rm -f .config && cp $GITHUB_WORKSPACE/Configs/$CONFIG_FILE .config
|
2022-03-21 15:43:00 +00:00
|
|
|
Firmware_Diy_Main
|
|
|
|
Firmware_Diy
|
2022-08-31 14:19:39 +00:00
|
|
|
Firmware_Diy_Other
|
2022-03-21 15:43:00 +00:00
|
|
|
|
2022-08-31 14:19:39 +00:00
|
|
|
- name: Pre-download Libraries
|
2022-03-21 15:43:00 +00:00
|
|
|
run: |
|
|
|
|
cd openwrt
|
2022-08-31 14:19:39 +00:00
|
|
|
./scripts/feeds install -a
|
2022-03-21 15:43:00 +00:00
|
|
|
make defconfig
|
2022-08-31 14:19:39 +00:00
|
|
|
make download -j8
|
|
|
|
|
|
|
|
- name: Build OpenWrt
|
|
|
|
run: |
|
|
|
|
cd openwrt
|
2022-03-21 15:43:00 +00:00
|
|
|
make -j$(nproc) || make -j1 V=s
|
2022-08-31 14:19:39 +00:00
|
|
|
[ "$?" == 0 ] && echo "Compile_Result=true" >> $GITHUB_ENV || echo "Compile_Result=false" >> $GITHUB_ENV
|
2022-03-21 15:43:00 +00:00
|
|
|
|
2022-08-31 14:19:39 +00:00
|
|
|
- name: Checkout Firmware
|
|
|
|
if: env.Compile_Result == 'true' && !cancelled()
|
2022-03-21 15:43:00 +00:00
|
|
|
run: |
|
|
|
|
cd openwrt
|
|
|
|
source $GITHUB_WORKSPACE/Scripts/AutoBuild_Function.sh
|
|
|
|
Firmware_Diy_End
|
|
|
|
|
|
|
|
- name: Upload Firmware to Artifacts
|
|
|
|
uses: actions/upload-artifact@main
|
2022-08-31 14:19:39 +00:00
|
|
|
if: env.UPLOAD_ARTIFACTS == 'true' && env.Compile_Result == 'true' && !cancelled()
|
2022-03-21 15:43:00 +00:00
|
|
|
with:
|
|
|
|
name: ${{ env.CONFIG_FILE }}_firmware_${{ env.Compile_Date }}
|
|
|
|
path: openwrt/bin/Firmware
|
|
|
|
|
|
|
|
- name: Upload bin to Artifacts
|
|
|
|
uses: actions/upload-artifact@main
|
2022-08-31 14:19:39 +00:00
|
|
|
if: env.UPLOAD_BIN_ARTIFACTS == 'true' && env.Compile_Result == 'true' && !cancelled()
|
2022-03-21 15:43:00 +00:00
|
|
|
with:
|
|
|
|
name: ${{ env.CONFIG_FILE }}_bin_${{ env.Compile_Date }}
|
|
|
|
path: openwrt/bin
|
|
|
|
|
2022-08-31 14:19:39 +00:00
|
|
|
- name: Upload Firmware to Release
|
2022-03-21 15:43:00 +00:00
|
|
|
uses: svenstaro/upload-release-action@v2
|
2022-08-31 14:19:39 +00:00
|
|
|
if: env.UPLOAD_RELEASES == 'true' && env.Compile_Result == 'true' && !cancelled()
|
2022-03-21 15:43:00 +00:00
|
|
|
with:
|
|
|
|
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
file: openwrt/bin/Firmware/*
|
|
|
|
file_glob: true
|
|
|
|
tag: AutoUpdate
|
|
|
|
overwrite: true
|
|
|
|
|
2022-08-31 14:19:39 +00:00
|
|
|
- name: Download Github API
|
|
|
|
if: env.UPLOAD_RELEASES == 'true' && env.Compile_Result == 'true' && !cancelled()
|
2022-03-21 15:43:00 +00:00
|
|
|
run: |
|
|
|
|
wget https://api.github.com/repos/${{github.repository}}/releases/tags/AutoUpdate -O API
|
|
|
|
|
2022-08-31 14:19:39 +00:00
|
|
|
- name: Upload Github API to Release
|
|
|
|
if: env.UPLOAD_RELEASES == 'true' && env.Compile_Result == 'true' && !cancelled()
|
2022-03-21 15:43:00 +00:00
|
|
|
uses: svenstaro/upload-release-action@v2
|
|
|
|
with:
|
|
|
|
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
file: ./API
|
|
|
|
file_glob: true
|
|
|
|
tag: AutoUpdate
|
|
|
|
overwrite: true
|
|
|
|
|
|
|
|
- name: Delete old Workflow Runs
|
|
|
|
uses: GitRML/delete-workflow-runs@main
|
|
|
|
if: env.DELETE_OLD_WORKFLOW == 'true' && !cancelled()
|
|
|
|
with:
|
|
|
|
retain_days: 1
|
|
|
|
keep_minimum_runs: 3
|