使用7763-编译-Lede-18.06-x86-64固件 #1979
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
# | |
# 编译主程序,请勿修改文件名称(compile.yml) | |
# | |
name: 编译主程序 | |
on: | |
push: | |
branches: | |
- main | |
paths: | |
- 'build/Lede/relevance/start' | |
env: | |
GITHUB_LINK: https://github.com/${{github.repository}} | |
GIT_ACTOR: ${{github.actor}} | |
GIT_REPOSITORY: ${{github.repository}} | |
RUN_NUMBER: ${{github.run_number}} | |
RUN_WORKFLOW: ${{github.workflow}} | |
REPO_TOKEN: ${{ secrets.REPO_TOKEN }} | |
PUSH_PLUS_TOKEN: ${{ secrets.PUSH_PLUS_TOKEN }} | |
TELEGRAM_BOT_TOKEN: ${{ secrets.TELEGRAM_BOT_TOKEN }} | |
TELEGRAM_CHAT_ID: ${{ secrets.TELEGRAM_CHAT_ID }} | |
WX_TOKEN: ${{ secrets.WX_TOKEN }} | |
CURL: ${{ secrets.CURL }} | |
TZ: Asia/Shanghai | |
jobs: | |
build: | |
name: 编译 "${{matrix.target}}" | |
runs-on: ubuntu-22.04 | |
if: ${{ github.event.repository.owner.id }} == ${{ github.event.sender.id }} | |
env: | |
FOLDER_NAME: ${{ matrix.target }} | |
strategy: | |
fail-fast: false | |
matrix: | |
target: [Lede] | |
steps: | |
- name: 准备结束 | |
uses: actions/checkout@v4 | |
- name: 检测文件和对比上游版本 | |
run: | | |
cd ${GITHUB_WORKSPACE} | |
bash <(curl -fsSL https://raw.githubusercontent.com/shidahuilang/common/main/custom/first.sh) | |
if [[ -n "${{ github.event.workflow }}" ]] || [[ -n "${{ github.event.schedule }}" ]]; then | |
source ${GITHUB_WORKSPACE}/build/${FOLDER_NAME}/settings.ini | |
else | |
source ${GITHUB_WORKSPACE}/build/${FOLDER_NAME}/relevance/settings.ini | |
fi | |
source ${GITHUB_WORKSPACE}/build/${{ env.FOLDER_NAME }}/common.sh && Diy_menu1 | |
- name: 清理因转换CPU而停止的工作流程 | |
run: | | |
cd ${GITHUB_WORKSPACE} | |
source build/${FOLDER_NAME}/common.sh && Diy_delruns | |
- name: CPU检测 | |
run: | | |
cd ${GITHUB_WORKSPACE} | |
source build/${FOLDER_NAME}/common.sh && CPU_Priority | |
- name: 清理空间 | |
uses: jlumbroso/free-disk-space@main | |
with: | |
# 这可能会移除实际需要的工具 | |
# 如果设置为“true”,但释放约6 GB | |
tool-cache: true | |
# 所有这些都默认为true | |
# "false" 可以随时关闭 | |
android: true | |
dotnet: true | |
haskell: true | |
large-packages: true | |
swap-storage: true | |
- name: 部署编译环境 | |
env: | |
DEBIAN_FRONTEND: noninteractive | |
run: | | |
source ${GITHUB_WORKSPACE}/build/${{matrix.target}}/common.sh && Diy_update | |
sudo timedatectl set-timezone "$TZ" | |
sudo mkdir -p /${{ env.DIY_WORK }} | |
sudo chown ${USER}:${GROUPS} /${{ env.DIY_WORK }} | |
#- name: 升级rustc到1.70.0 | |
#run: | | |
#curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain 1.70.0 | |
#source $HOME/.cargo/env | |
- name: 下载"${{matrix.target}}"源码 | |
working-directory: /${{ env.DIY_WORK }} | |
run: | | |
git clone -b "${REPO_BRANCH}" --single-branch "${REPO_URL}" openwrt | |
ln -sf /${{ env.DIY_WORK }}/openwrt ${GITHUB_WORKSPACE}/openwrt | |
cp -Rf ${GITHUB_WORKSPACE}/build ${GITHUB_WORKSPACE}/openwrt/build | |
chmod -R +x ${GITHUB_WORKSPACE}/openwrt/build | |
- name: 修改 feeds.conf.default | |
run: | | |
cd openwrt | |
echo "当前 SOURCE_CODE 值是: $SOURCE_CODE" | |
# 判断是否为 COOLSNOWWOLF 编译 | |
if [ "$SOURCE_CODE" == "COOLSNOWWOLF" ]; then | |
echo "正在编译 COOLSNOWWOLF,启用 luci feed" | |
# 使用 sed 修改 feeds.conf.default 文件 | |
sed -i 's@src-git luci@# src-git luci@g' feeds.conf.default | |
sed -i 's@## src-git luci@src-git luci@g' feeds.conf.default | |
elif [ "$SOURCE_CODE" == "IMMORTALWRT" ]; then | |
echo "当前是 IMMORTALWRT 编译,跳过 luci feed 配置" | |
else | |
echo "未检测到 COOLSNOWWOLF 或 IMMORTALWRT 编译,跳过 luci feed 配置" | |
fi | |
- name: 公 告 | |
run: | | |
cd openwrt | |
source ${BUILD_PATH}/common.sh && Diy_menu2 | |
- name: 更新插件源 | |
run: | | |
cd openwrt | |
source ${BUILD_PATH}/common.sh && Diy_menu3 | |
- name: 加载自定义设置 | |
run: | | |
cd openwrt | |
source ${BUILD_PATH}/common.sh && Diy_menu4 | |
- name: 安装插件源 | |
run: | | |
cd openwrt | |
source ${BUILD_PATH}/common.sh && Diy_menu5 | |
- name: 生成"${{matrix.target}}"配置文件 | |
run: | | |
cd openwrt | |
source ${BUILD_PATH}/common.sh && Diy_menu6 | |
- name: 编译信息 | |
continue-on-error: true | |
if: env.COMPILATION_INFORMATION == 'true' | |
run: | | |
cd openwrt | |
source ${BUILD_PATH}/common.sh && Diy_xinxi | |
- name: 缓存加速 | |
if: env.CACHEWRTBUILD_SWITCH == 'true' | |
uses: stupidloud/cachewrtbuild@main | |
with: | |
ccache: 'true' | |
mixkey: "${{ env.TARGET_PROFILE }}" | |
prefix: ${{ github.workspace }}/openwrt | |
- name: 下载软件包 | |
id: package | |
run: | | |
cd openwrt | |
make defconfig | |
make download -j16 | |
- name: 开始编译固件 | |
id: compile | |
run: | | |
cd openwrt | |
echo -e "$(nproc) thread compile" | |
make -j$(($(nproc) + 1)) || make -j1 V=s | |
echo "date=$(date "+%Y%m%d%H%M%S")" >> ${GITHUB_ENV} | |
source ${BUILD_PATH}/common.sh && firmware_jiance | |
- name: 自动打包Amlogic_Rockchip系列固件 | |
if: steps.compile.outcome == 'success' && env.PACKAGING_FIRMWARE == 'true' | |
uses: ncipollo/release-action@main | |
with: | |
name: rootfs.tar.gz | |
tag: targz | |
token: ${{ secrets.REPO_TOKEN }} | |
allowUpdates: true | |
replacesArtifacts: true | |
artifacts: openwrt/targz/*rootfs.tar.gz | |
- name: 整理固件文件夹(需配合diy-part.sh设定使用) | |
continue-on-error: true | |
if: steps.compile.outcome == 'success' | |
id: organizer | |
run: | | |
cd openwrt | |
source ${BUILD_PATH}/common.sh && Diy_firmware | |
- name: 上传固件在 github Artifacts | |
if: steps.compile.outcome == 'success' && env.UPLOAD_FIRMWARE == 'true' | |
uses: actions/upload-artifact@main | |
with: | |
name: ${{ env.SOURCE }}-${{ env.LUCI_EDITION }}-${{ env.TARGET_PROFILE }}-firmware-${{ env.Firmware_Date }} | |
path: ${{ env.FIRMWARE_PATH }} | |
- name: 发布固件 | |
if: steps.compile.outcome == 'success' && env.UPLOAD_RELEASE == 'true' && env.ING_FIRMWAR == 'true' && env.REPO_TOKEN | |
uses: ncipollo/release-action@main | |
with: | |
name: ${{ env.SOURCE }}-${{ env.PROMPT_TING }} | |
tag: a${{ env.date }} | |
token: ${{ secrets.REPO_TOKEN }} | |
allowUpdates: true | |
artifacts: "${{ env.FIRMWARE_PATH }}/*" | |
body: | | |
🎁 编译仓库:${{ env.WAREHOUSE_MAN }} | |
🌴 源码分支:${{ env.REPO_BRANCH }} | |
🔥 编译版本:${{ env.Openwrt_Version }} | |
🛸 LUCI版本:${{ env.LUCI_EDITION }} | |
✨ 内核版本:${{ env.LINUX_KERNEL }} | |
⏰ 编译时间:${{ env.Compte_Date }} | |
- name: 发送[在线更新固件]至云端1 | |
id: autoup | |
if: steps.compile.outcome == 'success' && env.UPDATE_FIRMWARE_ONLINE == 'true' && env.REPO_TOKEN | |
uses: ncipollo/release-action@main | |
with: | |
name: AutoUpdate | |
tag: ${{ env.Update_tag }} | |
token: ${{ secrets.REPO_TOKEN }} | |
allowUpdates: true | |
body: ${{ env.Tongzhi_Date }} | |
artifacts: "${{ env.BIN_PATH }}/*" | |
- name: 发送[在线更新固件]至云端2 | |
if: steps.autoup.outcome == 'success' && env.UPDATE_FIRMWARE_ONLINE == 'true' && env.REPO_TOKEN | |
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.Update_tag }} -o zzz_api | |
if [[ $? -ne 0 ]]; then | |
curl -H "Authorization: Bearer ${REPO_TOKEN}" https://api.github.com/repos/${GIT_REPOSITORY}/releases/tags/${Update_tag} > zzz_api | |
fi | |
- name: 发送[在线更新固件]至云端3 | |
if: steps.autoup.outcome == 'success' && env.UPDATE_FIRMWARE_ONLINE == 'true' && env.REPO_TOKEN | |
uses: ncipollo/release-action@main | |
with: | |
name: AutoUpdate-${{ env.TARGET_BOARD }} | |
tag: ${{ env.Update_tag }} | |
token: ${{ secrets.REPO_TOKEN }} | |
artifacts: "Github_Api/*" | |
allowUpdates: true | |
body: ${{ env.Tongzhi_Date }} | |
- name: Telegram或pushplus信息通知 | |
if: env.PUSH_PLUS_TOKEN && env.INFORMATION_NOTICE == 'PUSH' || env.TELEGRAM_BOT_TOKEN && env.INFORMATION_NOTICE == 'TG' || env.WX_TOKEN && env.INFORMATION_NOTICE == 'WX' | |
run: | | |
if [[ "${{ env.INFORMATION_NOTICE }}" == "TG" ]]; then | |
if [[ "${{steps.compile.outcome}}" == 'success' ]]; then | |
curl -k --data chat_id="${{ secrets.TELEGRAM_CHAT_ID }}" \ | |
--data text="🎉 主人您的${{ env.TARGET_PROFILE }}固件成功编译完成了! | |
🎁 编译仓库:${{ env.WAREHOUSE_MAN }} | |
🌴 源码分支:${{ env.REPO_BRANCH }} | |
🔥 编译版本:${{ env.Openwrt_Version }} | |
🛸 LUCI版本:${{ env.LUCI_EDITION }} | |
✨ 内核版本:${{ env.LINUX_KERNEL }} | |
⏰ 编译时间:${{ env.Compte_Date }} | |
⏰ 累计编译:${{ env.RUN_NUMBER }} | |
🎉 发布地址:${{ env.Github_Release }} | |
🏅 固件已经编译完成 🎈!!!" \ | |
"https://api.telegram.org/bot${{ secrets.TELEGRAM_BOT_TOKEN }}/sendMessage" >/dev/null 2>&1 && echo "Telegram通知成功" | |
fi | |
fi | |
if [[ "${{ env.INFORMATION_NOTICE }}" == "PUSH" ]]; then | |
if [[ "${{steps.compile.outcome}}" == 'success' ]]; then | |
curl -k --data token="${{ secrets.PUSH_PLUS_TOKEN }}" \ | |
--data title="[${{ env.SOURCE }}-${{ env.TARGET_PROFILE }}]编译成功" \ | |
--data content="🎉 主人您的${{ env.FIRMWARE_MESSAGE }}固件成功编译完成了! | |
🎁 编译仓库:${{ env.WAREHOUSE_MAN }} | |
🌴 源码分支:${{ env.REPO_BRANCH }} | |
🔥 编译版本:${{ env.Openwrt_Version }} | |
🛸 LUCI版本:${{ env.LUCI_EDITION }} | |
✨ 内核版本:${{ env.LINUX_KERNEL }} | |
⏰ 编译时间:${{ env.Compte_Date }} | |
⏰ 累计编译:${{ env.RUN_NUMBER }} | |
🎉 发布地址:${{ env.Github_Release }} | |
🏅 固件已经编译完成 🎈!!!" \ | |
"http://www.pushplus.plus/send" >/dev/null 2>&1 && echo "PUSH通知成功" | |
fi | |
fi | |
if [[ "${{ env.INFORMATION_NOTICE }}" == "WX" ]]; then | |
if [[ "${{steps.gitpush.outcome}}" == 'success' ]] && [[ "${{steps.compile.outcome}}" == 'success' ]]; then | |
curl -k --data token="${{ secrets.WX_TOKEN }}" \ | |
--data title="编译成功" \ | |
--data message="🎉 主人您的${{ env.FIRMWARE_MESSAGE }}固件成功编译完成了! | |
🎁 编译仓库:${{ env.WAREHOUSE_MAN }} | |
🌴 源码分支:${{ env.REPO_BRANCH }} | |
🔥 编译版本:${{ env.Openwrt_Version }} | |
🛸 LUCI版本:${{ env.LUCI_EDITION }} | |
✨ 内核版本:${{ env.LINUX_KERNEL }} | |
⏰ 编译时间:${{ env.Compte_Date }} | |
⏰ 累计编译:${{ env.RUN_NUMBER }} | |
🎉 发布地址:${{ env.Github_Release }} | |
🏅 固件已经编译完成 🎈!!!" \ | |
"http://${{ secrets.CURL }}/push?token=${{ secrets.WX_TOKEN }}&" >/dev/null 2>&1 && echo "WX通知成功" | |
else | |
curl -k --data token="${{ secrets.WX_TOKEN }}" \ | |
--data title="触发启动失败" \ | |
--data message="💥 主人❌ :上游扩展错误或者脚本错误, 触发启动【${{ env.FOLDER_NAME }}】失败, 请点击触发脚本步骤查看详情!(${{env.Tongzhi_Date}})" \ | |
"http://${{ secrets.CURL }}/push?token=${{ secrets.WX_TOKEN }}&" >/dev/null 2>&1 && echo "WX通知失败" | |
exit 1 | |
fi | |
fi |