23.05-mtkfilogic #15
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# 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: 23.05-mtkfilogic | |
permissions: write-all | |
#开启写权限,防止无法上传到release | |
on: | |
repository_dispatch: | |
workflow_dispatch: | |
schedule: | |
- cron: 0 20 * * 3 | |
# 分,时,日,月,星期。每周 四 20时执行一次 (UTC时间) | |
env: | |
REPO_URL: https://github.com/immortalwrt/immortalwrt | |
REPO_BRANCH: openwrt-23.05 | |
PLATFORM_FILE: configs/Platform-filogic.txt | |
CONFIG_FILE: configs/Packages-reduce.txt | |
FREE_DISK_SH: scripts/free_disk_space.sh | |
ENV_SH: scripts/environment.sh | |
SETTINGS_SH: scripts/init-settings.sh | |
PACKAGES_SH: scripts/packages.sh | |
CLASH_CORE_SH: scripts/preset-clash-core-arm64-L.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: | | |
chmod +x $FREE_DISK_SH && $FREE_DISK_SH | |
sudo -E apt-get -qq update -y | |
sudo -E apt-get -qq full-upgrade -y | |
chmod +x $ENV_SH && $ENV_SH | |
sudo rm -rf /etc/apt/sources.list.d/* /usr/share/dotnet /usr/local/lib/android /opt/ghc | |
sudo timedatectl set-timezone "$TZ" | |
docker image prune -a -f | |
docker container prune -f | |
sudo mkdir -p /workdir | |
sudo chown $USER:$GROUPS /workdir | |
- name: 检查空间使用情况1 | |
if: (!cancelled()) | |
run: df -hT | |
- name: 克隆源码 | |
working-directory: /workdir | |
run: | | |
git clone $REPO_URL -b $REPO_BRANCH openwrt | |
ln -sf /workdir/openwrt $GITHUB_WORKSPACE/openwrt | |
- name: 开启缓存 | |
uses: klever1988/cachewrtbuild@main | |
with: | |
ccache: 'true' | |
mixkey: '23.05-filogic' | |
prefix: ${{ github.workspace }}/openwrt | |
- name: 更新 & 安装 feeds & 执行脚本 | |
run: | | |
cd openwrt | |
./scripts/feeds update -a | |
./scripts/feeds install -a | |
chmod +x $GITHUB_WORKSPACE/$SETTINGS_SH && $GITHUB_WORKSPACE/$SETTINGS_SH | |
chmod +x $GITHUB_WORKSPACE/$PACKAGES_SH && $GITHUB_WORKSPACE/$PACKAGES_SH | |
chmod +x $GITHUB_WORKSPACE/$CLASH_CORE_SH && $GITHUB_WORKSPACE/$CLASH_CORE_SH | |
- name: 导入补丁和配置 & 下载文件 | |
run: | | |
[ -d files ] && mv files openwrt/files || echo "files not found" | |
[ -f $CPLATFORM_FILE ] && cat $PLATFORM_FILE >> openwrt/.config | |
[ -f $CONFIG_FILE ] && cat $CONFIG_FILE >> openwrt/.config | |
cd openwrt | |
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: 空间使用情况2 | |
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 "✅ 23.05 源码 MTK filogic 平台 \n⁉️ 刷不进去的,可以尝试同机型ubootmod版本(应该是闪存有坏快的缘故)\nℹ 256M运存建议设置每天重启一次,不然容易出现爆运存导致卡网" >> release.txt | |
echo "release_tag=$(date +"%Y.%m.%d-23.05_filogic")" >> $GITHUB_OUTPUT | |
echo "status=success" >> $GITHUB_OUTPUT | |
- name: 上传固件到发布 | |
uses: softprops/[email protected] | |
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: 15 | |
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: 5 |