coolsnowwolf Source Code Update #225
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: Build coolsnowwolf-LEDE for XIAOMI_R4 FULL | |
on: | |
repository_dispatch: | |
types: coolsnowwolf Source Code Update | |
workflow_dispatch: | |
inputs: | |
ssh: | |
description: 'SSH connection to Actions' | |
required: false | |
default: 'false' | |
# repo_url: | |
# description: 'The URL of the source code repository' | |
# required: true | |
# default: https://github.com/coolsnowwolf/lede | |
push: | |
branches: | |
- master | |
# schedule: | |
# - cron: 0 20 * * * | |
env: | |
REPO_URL: https://github.com/coolsnowwolf/lede | |
REPO_BRANCH: master | |
FEEDS_CONF: feeds.conf.default | |
CONFIG_FILE: config_for_coolsnowwolf | |
DIY_P1_SH: diy-part1.sh | |
DIY_P2_SH: diy-part2.sh | |
UPLOAD_BIN_DIR: true | |
UPLOAD_FIRMWARE: true | |
UPLOAD_COWTRANSFER: false | |
UPLOAD_WETRANSFER: false | |
UPLOAD_RELEASE: true | |
TZ: Asia/Shanghai | |
jobs: | |
build: | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Maximize build space | |
uses: easimon/maximize-build-space@master | |
with: | |
root-reserve-mb: 10240 | |
# temp-reserve-mb: 150 | |
# swap-size-mb: 1024 | |
remove-dotnet: 'true' | |
remove-android: 'true' | |
remove-haskell: 'true' | |
remove-codeql: 'true' | |
remove-docker-images: 'true' | |
- name: Checkout | |
uses: actions/checkout@main | |
- name: Initialization environment | |
env: | |
DEBIAN_FRONTEND: noninteractive | |
run: | | |
sudo rm -rf /etc/apt/sources.list.d/* /usr/share/dotnet /usr/local/lib/android /opt/ghc | |
sudo -E apt-get -y purge azure-cli* docker* ghc* zulu* hhvm* llvm* firefox* google* dotnet* aspnetcore* powershell* openjdk* adoptopenjdk* mysql* php* mongodb* moby* snap* || true | |
sudo -E apt-get -qq update | |
# sudo -E apt-get -qq install $(curl -fsSL git.io/depends-ubuntu-2004) | |
sudo -E apt-get -qq install libpam0g-dev liblzma-dev libsnmp-dev gcc g++ build-essential asciidoc binutils bzip2 gawk gettext git libncurses5-dev libz-dev patch flex bison make autoconf texinfo unzip sharutils subversion ncurses-term zlib1g-dev ccache upx lib32gcc-s1 libc6-dev-i386 uglifyjs git-core gcc-multilib p7zip p7zip-full msmtp libssl-dev libglib2.0-dev xmlto qemu-utils automake libtool | |
sudo -E apt-get -qq install libcrypto++-dev qtbase5-dev qtbase5-dev-tools qtchooser qt5-qmake qtbase5-private-dev libqt5sql5 libqt5sql5-mysql libqt5sql5-odbc libqt5sql5-psql libqt5sql5-sqlite libqt5sql5-tds qttools5-dev-tools | |
# 检查Ubuntu版本并安装相应的包 | |
UBUNTU_VERSION=$(lsb_release -rs) | |
if [[ $UBUNTU_VERSION == 20.04 ]]; then | |
sudo apt-get -y install lib32gcc1 | |
elif [[ $UBUNTU_VERSION == 22.04 ]]; then | |
sudo apt-get -y install lib32gcc-s1 | |
else | |
sudo apt-get -y install lib32gcc-s1 | |
echo "非Ubuntu20.04或22.04系统,安装lib32gcc可能失败,如果失败请检查对应系统安装libgcc32的命令" | |
fi | |
sudo -E apt-get -qq autoremove --purge | |
sudo -E apt-get -qq clean | |
sudo timedatectl set-timezone "$TZ" | |
sudo mkdir -p /workdir/openwrt | |
# sudo chown -R $USER:$GROUPS ${{ github.repository }} 解析为Fatty911/AutoBuild~ | |
sudo chown -R $USER:$GROUPS /workdir | |
sudo chown -R $USER:$GROUPS $GITHUB_WORKSPACE | |
- name: Clone source code | |
working-directory: ${{ github.workspace }} | |
run: | | |
df -hT $PWD | |
git clone $REPO_URL -b $REPO_BRANCH openwrt | |
ln -sf /workdir $GITHUB_WORKSPACE | |
- name: Load custom feeds | |
run: | | |
[ -e $FEEDS_CONF ] && mv $FEEDS_CONF openwrt/feeds.conf.default | |
chmod +x $DIY_P1_SH | |
cd openwrt | |
$GITHUB_WORKSPACE/$DIY_P1_SH | |
# echo 'src-git routing https://github.com/coolsnowwolf/routing.git;5437d2c91fd9f15e06fbea46677abb529ed3547c' >>feeds.conf.default | |
# sed -i 's/src-git routing https:\/\/github.com\/coolsnowwolf\/routing.git.*/src-git routing https:\/\/github.com\/coolsnowwolf\/routing.git;5437d2c91fd9f15e06fbea46677abb529ed3547c/g' feeds.conf.default | |
#sed -i '/^src-git routing.*/c\src-git routing https:\/\/github.com\/coolsnowwolf\/routing.git;5437d2c91fd9f15e06fbea46677abb529ed3547c' feeds.conf.default | |
- name: Update feeds and Install feeds | |
run: cd openwrt && ./scripts/feeds update -a && ./scripts/feeds install -a | |
- name: Load custom configuration | |
run: | | |
[ -e files ] && mv files openwrt/files | |
[ -e $CONFIG_FILE ] && mv $CONFIG_FILE openwrt/.config | |
chmod +x $DIY_P2_SH | |
cd openwrt | |
$GITHUB_WORKSPACE/$DIY_P2_SH | |
- name: Download package | |
id: package | |
run: | | |
cd openwrt | |
make defconfig | |
make download -j8 | |
find dl -size -1024c -exec ls -l {} \; | |
find dl -size -1024c -exec rm -f {} \; | |
- name: Check space usage after download | |
if: (!cancelled()) | |
run: df -hT | |
- name: SSH connection to Actions | |
uses: P3TERX/[email protected] | |
if: (github.event.inputs.ssh == 'true' && github.event.inputs.ssh != 'false') || contains(github.event.action, 'ssh') | |
env: | |
TELEGRAM_CHAT_ID: ${{ secrets.TELEGRAM_CHAT_ID }} | |
TELEGRAM_BOT_TOKEN: ${{ secrets.TELEGRAM_BOT_TOKEN }} | |
# - name: Specify kernel version | |
# run: | | |
# cd openwrt | |
# sed -i 's/^KERNEL_PATCHVER:=.*/KERNEL_PATCHVER:=6.1/' target/linux/ramips/Makefile | |
# sed -i 's/^KERNEL_TESTING_PATCHVER:=.*/KERNEL_TESTING_PATCHVER:=6.6/' target/linux/ramips/Makefile | |
# - name: Modify overclocking settings | |
# run: | | |
# cd openwrt | |
# #超频5.10内核至1000Mhz | |
# mv target/linux/ramips/patches-5.10/322-mt7621-fix-cpu-clk-add-clkdev.patch ./322-mt7621-fix-cpu-clk-add-clkdev.patch.bak | |
# wget -O target/linux/ramips/patches-5.10/322-mt7621-fix-cpu-clk-add-clkdev.patch https://raw.githubusercontent.com/Fatty911/AutoBuild_OpenWRT_for_Mi_R4/main/mt7621_overclocking-322-mt7621-fix-cpu-clk-add-clkdev.patch | |
- name: Fix batman-adv bug | |
run: | | |
cd openwrt | |
git config --global user.email [email protected] | |
git config --global user.name Fatty911 | |
cd package/feeds/ && rm -rf routing && git clone https://github.com/coolsnowwolf/routing.git routing && cd routing && git checkout 5437d2c91fd9f15e06fbea46677abb529ed3547c | |
# # wget https://github.com/coolsnowwolf/lede/files/14081054/2023.3-batman-adv.tar.gz | |
# wget https://downloads.open-mesh.org/batman/releases/batman-adv-2024.1/batman-adv-2024.1.tar.gz | |
# tar -xvzf batman-adv-2024.1.tar.gz && mv batman-adv-2024.1 batman-adv && mv -f batman-adv package/feeds/routing/ | |
# # make package/feeds/routing/batman-adv/compile V=s | make -j1 package/feeds/routing/batman-adv/compile V=s | |
# tar -xvzf 2023.3-batman-adv.tar.gz -C package/network/services/batman-adv | |
# tar -xvzf 2023.3-batman-adv.tar.gz && mv batman-adv/* build_dir/target-mipsel_24kc_musl/linux-ramips_mt7621/batman-adv-2023.3/ | |
# wget https://github.com/coolsnowwolf/lede/files/14080071/0006-fix-build-with-kernel-6.6.patch | |
# cp 0006-fix-build-with-kernel-6.6.patch build_dir/target-mipsel_24kc_musl/linux-ramips_mt7621/batman-adv-2023.3/ && cd build_dir/target-mipsel_24kc_musl/linux-ramips_mt7621/batman-adv-2023.3/ && git am 0006-fix-build-with-kernel-6.6.patch | |
- name: Compile the firmware | |
id: compile | |
run: | | |
#开始编译 | |
cd openwrt | |
echo -e "$(nproc) thread compile" | |
make -j$(nproc) || make -j1 || make -j1 V=s || sed -i 's/--set=llvm.download-ci-llvm=true/--set=llvm.download-ci-llvm=false/g' ${{ github.workspace }}/openwrt/feeds/packages/lang/rust/Makefile && make -j1 V=s | |
echo "status=success" >> $GITHUB_OUTPUT | |
# KERNEL_VERSION=$(cat bin/targets/*/version.buildinfo | grep 'kernel_version' | cut -d'=' -f2) | |
# # echo "kernel_version=$KERNEL_VERSION" >> $GITHUB_ENV 调用env.kernel_version会报错 | |
# echo "kernel_version=$KERNEL_VERSION" >> $GITHUB_OUTPUT | |
grep '^CONFIG_TARGET.*DEVICE.*=y' .config | sed -r 's/.*DEVICE_(.*)=y/\1/' > DEVICE_NAME | |
[ -s DEVICE_NAME ] && echo "DEVICE_NAME=_$(cat DEVICE_NAME)" >> $GITHUB_ENV | |
echo "FILE_DATE=_$(date +"%Y%m%d%H%M")" >> $GITHUB_ENV | |
TARGET_BOARD=$(grep '^CONFIG_TARGET_BOARD=' .config | sed -r 's/.*="(.*)"/\1/') | |
echo "检测TARGET_BOARD是否在.config中成功找到:$TARGET_BOARD" | |
echo "TARGET_BOARD=$TARGET_BOARD" >> $GITHUB_ENV | |
TARGET_SUBTARGET=$(grep '^CONFIG_TARGET_SUBTARGET=' .config | sed -r 's/.*="(.*)"/\1/') | |
echo "检测TARGET_SUBTARGET是否在.config中成功找到:$TARGET_SUBTARGET" | |
echo "TARGET_SUBTARGET=$TARGET_SUBTARGET" >> $GITHUB_ENV | |
TARGET_PROFILE=$(grep '^CONFIG_TARGET_PROFILE=' .config | sed -r 's/.*="(.*)"/\1/' | sed 's/^DEVICE_//') | |
echo "检测TARGET_PROFILE是否在.config中成功找到:$TARGET_PROFILE" | |
echo "TARGET_PROFILE=$TARGET_PROFILE" >> $GITHUB_ENV | |
echo "DEVICE_NAME=$TARGET_PROFILE" >> $GITHUB_ENV | |
KERNEL_VERSION=$(ls build_dir/target-*_*/linux-*/ | grep -oP 'linux-\K\d+\.\d+\.\d+') | |
echo "检查是否获取到内核版本号:$KERNEL_VERSION" | |
echo "kernel_version=$KERNEL_VERSION" >> $GITHUB_ENV | |
- name: Rename | |
run: | | |
cd openwrt/bin/targets/${{ env.TARGET_BOARD }}/${{ env.TARGET_SUBTARGET }} | |
for file in openwrt-${{ env.TARGET_BOARD }}-${{ env.TARGET_SUBTARGET }}-${{ env.TARGET_PROFILE}}-*; do | |
if [ -f "$file" ]; then | |
new_file="openwrt_coolsnowwolf_${{ env.TARGET_BOARD }}_${{ env.TARGET_SUBTARGET }}_${{ env.TARGET_PROFILE}}_Kernel_${{ env.kernel_version }}_${{ env.FILE_DATE }}${file#*${{ env.TARGET_PROFILE}}}" | |
mv "$file" "$new_file" | |
echo "Renamed $file to $new_file" | |
fi | |
done | |
- name: Check space usage after compile | |
if: (!cancelled()) | |
run: df -hT | |
- name: Upload bin directory | |
uses: actions/upload-artifact@master | |
if: steps.compile.outputs.status == 'success' && env.UPLOAD_BIN_DIR == 'true' | |
with: | |
name: OpenWrt_LEDE_coolsnowwolf_bin_${{ env.DEVICE_NAME }}_Kernel_${{ env.kernel_version }}_${{ env.FILE_DATE }} | |
path: | | |
openwrt/bin | |
openwrt/.config | |
- name: Organize files | |
id: organize | |
if: env.UPLOAD_FIRMWARE == 'true' && !cancelled() | |
run: | | |
cd openwrt/bin/targets/*/* | |
rm -rf packages | |
echo "firmware_path=$(pwd)" >> $GITHUB_ENV | |
echo "status=success" >> $GITHUB_OUTPUT | |
- name: Upload firmware directory | |
uses: actions/upload-artifact@master | |
if: steps.organize.outputs.status == 'success' && !cancelled() | |
with: | |
name: OpenWrt_LEDE_coolsnowwolf_firmware_${{ env.DEVICE_NAME }}_Kernel_${{ env.kernel_version }}_${{ env.FILE_DATE }} | |
path: ${{ env.firmware_path }} | |
- name: Upload firmware to cowtransfer | |
id: cowtransfer | |
if: steps.organize.outputs.status == 'success' && env.UPLOAD_COWTRANSFER == 'true' && !cancelled() | |
run: | | |
curl -fsSL git.io/file-transfer | sh | |
./transfer cow --block 2621440 -s -p 64 --no-progress ${FIRMWARE} 2>&1 | tee cowtransfer.log | |
echo "::warning file=cowtransfer.com::$(cat cowtransfer.log | grep https)" | |
#echo "::set-output name=url::$(cat cowtransfer.log | grep https | cut -f3 -d" ")" | |
echo "url=$(cat cowtransfer.log | grep https | cut -f3 -d" ")" >> $GITHUB_OUTPUT | |
- name: Upload firmware to WeTransfer | |
id: wetransfer | |
if: steps.organize.outputs.status == 'success' && env.UPLOAD_WETRANSFER == 'true' | |
run: | | |
curl -fsSL git.io/file-transfer | sh | |
./transfer wet -s -p 16 --no-progress ${FIRMWARE} 2>&1 | tee wetransfer.log | |
echo "::warning file=wetransfer.com::$(cat wetransfer.log | grep https)" | |
#echo "::set-output name=url::$(cat wetransfer.log | grep https | cut -f3 -d" ")" | |
echo "url=$(cat wetransfer.log | grep https | cut -f3 -d" ")" >> $GITHUB_OUTPUT | |
- name: Generate release tag | |
id: generate_release_tag | |
if: env.UPLOAD_RELEASE == 'true' && !cancelled() | |
run: | | |
echo "release_tag=${{ env.DEVICE_NAME }}_Kernel_${{ env.kernel_version }}_$(date +"%Y.%m.%d-%H%M")" >> $GITHUB_OUTPUT | |
touch release.txt | |
[ $UPLOAD_COWTRANSFER = true ] && echo "🔗 [Cowtransfer](${{ steps.cowtransfer.outputs.url }})" >> release.txt | |
[ $UPLOAD_WETRANSFER = true ] && echo "🔗 [WeTransfer](${{ steps.wetransfer.outputs.url }})" >> release.txt | |
echo "release_tag_status=success" >> $GITHUB_OUTPUT | |
echo "release_tag_status: ${{steps.generate_release_tag.outputs.release_tag_status}}" | |
- name: Upload firmware to release | |
uses: softprops/action-gh-release@master | |
if: steps.generate_release_tag.outputs.release_tag_status == 'success' && env.UPLOAD_RELEASE == 'true' | |
env: | |
GITHUB_TOKEN: ${{ secrets.ACTIONS_TRIGGER_PAT }} | |
with: | |
token: ${{ secrets.ACTIONS_TRIGGER_PAT }} | |
files: | | |
${{ env.firmware_path }}/* | |
openwrt/.config | |
name: OpenWRT_LEDE_coolsnowwolf_${{ steps.generate_release_tag.outputs.release_tag }} | |
tag_name: OpenWRT_LEDE_coolsnowwolf_${{ steps.generate_release_tag.outputs.release_tag }} | |
- name: Delete workflow runs | |
uses: Mattraks/delete-workflow-runs@v2 | |
with: | |
token: ${{ secrets.ACTIONS_TRIGGER_PAT }} | |
repository: ${{ github.repository }} | |
retain_days: 5 | |
keep_minimum_runs: 2 | |
- name: Delete Older Releases | |
uses: dev-drprasad/delete-older-releases@master | |
with: | |
#repo: <owner>/<repoName> # defaults to current repo | |
keep_latest: 5 | |
#delete_tag_pattern: beta # defaults to "" | |
env: | |
GITHUB_TOKEN: ${{ secrets.ACTIONS_TRIGGER_PAT }} |