master-mtkfilogic #20
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: master-mtkfilogic | |
permissions: write-all | |
#开启写权限,防止无法上传到release | |
on: | |
repository_dispatch: | |
workflow_dispatch: | |
schedule: | |
- cron: 0 22 * * 6 | |
# 分,时,日,月,星期。每周 日 22时执行一次 (UTC时间) | |
env: | |
REPO_URL: https://github.com/immortalwrt/immortalwrt | |
REPO_BRANCH: master | |
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.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" | |
sudo mkdir -p /workdir | |
sudo chown $USER:$GROUPS /workdir | |
- name: 检查空间使用情况 | |
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: 'master-filogic' | |
prefix: ${{ github.workspace }}/openwrt | |
- name: 更新 & 安装 feeds & 执行脚本 | |
run: | | |
cd openwrt | |
./scripts/feeds update -a && ./scripts/feeds update -a | |
chmod +x $GITHUB_WORKSPACE/$SETTINGS_SH && $GITHUB_WORKSPACE/$SETTINGS_SH | |
chmod +x $GITHUB_WORKSPACE/$PACKAGES_SH && $GITHUB_WORKSPACE/$PACKAGES_SH | |
./scripts/feeds install -a && ./scripts/feeds install -a | |
- name: 导入补丁和配置 & 下载文件 | |
run: | | |
[ -e files ] && mv files openwrt/files | |
cat configs/Platform-filogic.txt >> openwrt/.config | |
cat configs/Packages-reduce.txt >> 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 | |
make defconfig | |
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 "✅ master 源码 MTK filogic 平台 \n⁉️ 刷不进去的,可以尝试同机型ubootmod版本(应该是闪存有坏快的缘故)\nℹ 256M运存建议设置每天重启一次,不然容易出现爆运存导致卡网" >> release.txt | |
echo "release_tag=$(date +"%Y.%m.%d-master_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: 10 | |
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 |