This repository has been archived by the owner on Nov 16, 2024. It is now read-only.
编译Lede_lxc_nk固件 #1
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
#================================================= | |
# https://github.com/roacn/openwrt | |
# Description: Build OpenWrt using GitHub Actions | |
# Lisence: GNU General Public License v3.0 | |
# Author: Ss. | |
#================================================= | |
name: 编译固件-无内核 | |
on: | |
repository_dispatch: | |
types: [编译Lede_lxc_nk固件] | |
env: | |
GITHUB_REPOSITORY_URL: https://github.com/${{ github.repository }} | |
GITHUB_REPOSITORY: ${{ github.repository }} | |
GITHUB_REPOSITORY_REFNAME: ${{ github.ref_name }} | |
GITHUB_REPOSITORY_REF: ${{ github.ref }} | |
GITHUB_ACTOR: ${{ github.actor }} | |
GITHUB_WORKFLOW: ${{ github.workflow }} | |
CLIENT_PAYLOAD_TARGET: ${{ github.event.client_payload.target }} | |
REPO_TOKEN: ${{ secrets.REPO_TOKEN }} | |
TELEGRAM_CHAT_ID: ${{ secrets.TELEGRAM_CHAT_ID }} | |
TELEGRAM_BOT_TOKEN: ${{ secrets.TELEGRAM_BOT_TOKEN }} | |
PUSH_PLUS_TOKEN: ${{ secrets.PUSH_PLUS_TOKEN }} | |
TZ: Asia/Shanghai | |
jobs: | |
build: | |
name: Compile ${{ matrix.target }} | |
runs-on: ubuntu-latest | |
if: github.event.repository.owner.id == github.event.sender.id || ! github.event.sender.id | |
env: | |
MATRIX_TARGET: ${{ matrix.target }} | |
strategy: | |
fail-fast: false | |
matrix: | |
target: ["${{ github.event.client_payload.target }}"] | |
steps: | |
- name: 准备工作 | |
uses: actions/checkout@main | |
with: | |
fetch-depth: 0 | |
- name: 获取设置 | |
run: | | |
cd $GITHUB_WORKSPACE | |
common_sh_url="https://raw.githubusercontent.com/518512/roacn-common/main/common.sh" | |
curl -fsSL $common_sh_url -o $GITHUB_WORKSPACE/common.sh | |
if [[ $? -ne 0 ]]; then | |
wget -q $common_sh_url -O $GITHUB_WORKSPACE/common.sh | |
fi | |
chmod +x $GITHUB_WORKSPACE/common.sh | |
source $GITHUB_WORKSPACE/common.sh && parse_settings | |
- name: 编译开始TG或pushplus通知 | |
if: env.PUSH_PLUS_TOKEN && env.NOTICE_TYPE == 'PUSH' || env.TELEGRAM_CHAT_ID && env.TELEGRAM_BOT_TOKEN && env.NOTICE_TYPE == 'TG' | |
run: | | |
source $GITHUB_WORKSPACE/common.sh && notice_begin | |
- name: 释放磁盘空间 | |
uses: jlumbroso/free-disk-space@main | |
with: | |
tool-cache: true | |
android: true | |
dotnet: true | |
haskell: true | |
large-packages: true | |
swap-storage: true | |
- name: 部署编译环境 | |
env: | |
DEBIAN_FRONTEND: noninteractive | |
run: | | |
source $GITHUB_WORKSPACE/common.sh && init_environment | |
- name: 下载"${{ matrix.target }}"源码 | |
working-directory: /${{ matrix.target }} | |
run: | | |
source $GITHUB_WORKSPACE/common.sh && git_clone_source | |
- name: 缓存加速 | |
if: env.ENABLE_CCACHE == 'true' || env.ENABLE_CCACHE == 'normal' || env.ENABLE_CCACHE == 'fast' | |
uses: stupidloud/cachewrtbuild@main | |
with: | |
ccache: 'true' | |
mixkey: "${{ env.MATRIX_TARGET }}" | |
prefix: ${{ env.HOME_PATH }} | |
- name: 更新源,补丁和自定义设置 | |
if: env.REPO_TOKEN | |
run: | | |
source $GITHUB_WORKSPACE/common.sh && do_diy | |
- name: 生成.config文件 | |
if: env.REPO_TOKEN | |
run: | | |
source $GITHUB_WORKSPACE/common.sh && make_defconfig | |
- name: 编译信息 | |
continue-on-error: true | |
run: | | |
source $GITHUB_WORKSPACE/common.sh && compile_info | |
- name: 下载软件包 | |
id: package | |
if: env.REPO_TOKEN | |
run: | | |
cd ${HOME_PATH} | |
make defconfig | |
make download -j16 | |
- name: 开始编译固件 | |
id: compile | |
if: env.REPO_TOKEN | |
run: | | |
cd ${HOME_PATH} | |
echo -e "$(nproc) thread compile" | |
make -j$(($(nproc) + 1)) || make -j1 V=s | |
- name: 整理固件文件夹 | |
continue-on-error: true | |
id: organize | |
if: steps.compile.outcome == 'success' | |
run: | | |
source $GITHUB_WORKSPACE/common.sh && organize_firmware | |
- name: 上传固件至artifacts | |
continue-on-error: true | |
if: steps.compile.outcome == 'success' && env.UPLOAD_FIRMWARE == 'true' | |
uses: actions/upload-artifact@main | |
with: | |
name: ${{ env.SOURCE }}-${{ env.LUCI_EDITION }}-${{ env.LINUX_KERNEL }}-${{ env.TARGET_PROFILE }}-firmware-${{ env.COMPILE_DATE_HM }} | |
path: ${{ env.FIRMWARE_PATH }} | |
- name: 发布固件 | |
continue-on-error: true | |
if: steps.compile.outcome == 'success' && env.UPLOAD_RELEASE == 'true' | |
uses: ncipollo/release-action@main | |
with: | |
name: ${{ env.SOURCE }}-${{ env.LUCI_EDITION }}-${{ env.TARGET_PROFILE }} | |
tag: ${{ env.RELEASE_TAG }} | |
token: ${{ secrets.REPO_TOKEN }} | |
allowUpdates: true | |
removeArtifacts: true | |
bodyFile: "${{ env.RELEASE_MD }}" | |
artifacts: "${{ env.FIRMWARE_PATH }}/*" | |
- name: 发布自动更新固件-固件 | |
id: autoupdate | |
if: steps.compile.outcome == 'success' | |
uses: ncipollo/release-action@main | |
with: | |
allowUpdates: true | |
token: ${{ secrets.REPO_TOKEN }} | |
tag: ${{ env.AUTOUPDATE_TAG }} | |
bodyFile: "${{ env.RELEASEINFO_MD }}" | |
artifacts: "${{ env.AUTOUPDATE_PATH }}/*" | |
- name: 发布自动更新固件-获取API | |
if: steps.compile.outcome == 'success' | |
run: | | |
mkdir -p Github_Api | |
cd Github_Api | |
curl -H "Authorization: Bearer ${{ secrets.REPO_TOKEN }}" https://api.github.com/repos/${{ github.repository }}/releases/tags/${{ env.AUTOUPDATE_TAG }} -o ${{ env.GITHUB_API }} | |
if [[ $? -ne 0 ]]; then | |
wget -q --no-cookie --no-check-certificate https://api.github.com/repos/${{ github.repository }}/releases/tags/${{ env.AUTOUPDATE_TAG }} -O ${{ env.GITHUB_API }} | |
fi | |
- name: 发布自动更新固件-固件信息 | |
if: steps.compile.outcome == 'success' | |
uses: ncipollo/release-action@main | |
with: | |
allowUpdates: true | |
token: ${{ secrets.REPO_TOKEN }} | |
tag: ${{ env.AUTOUPDATE_TAG }} | |
bodyFile: "${{ env.RELEASEINFO_MD }}" | |
artifacts: "Github_Api/*" | |
- name: 编译完成TG或pushplus通知 | |
if: steps.compile.outcome == 'success' && env.PUSH_PLUS_TOKEN && env.NOTICE_TYPE == 'PUSH' || steps.compile.outcome == 'success' && env.TELEGRAM_CHAT_ID && env.TELEGRAM_BOT_TOKEN && env.NOTICE_TYPE == 'TG' | |
run: | | |
source $GITHUB_WORKSPACE/common.sh && notice_end | |
delete-releases-artifacts: | |
name: Delete releases artifacts | |
if: ${{ always() && github.event.repository.owner.id == github.event.sender.id || ! github.event.sender.id }} | |
needs: [build] | |
runs-on: ubuntu-latest | |
steps: | |
- name: 清理Actions | |
if: env.REPO_TOKEN | |
uses: Mattraks/delete-workflow-runs@main | |
with: | |
token: ${{ secrets.REPO_TOKEN }} | |
repository: ${{ github.repository }} | |
keep_minimum_runs: 0 | |
retain_days: 7 | |
- name: 删除releases | |
if: env.REPO_TOKEN | |
uses: dev-drprasad/delete-older-releases@master | |
with: | |
repo: ${{ github.repository }} | |
keep_latest: 7 | |
delete_tags: true | |
env: | |
GITHUB_TOKEN: ${{ secrets.REPO_TOKEN }} |