Skip to content

Lede Builder #23

Lede Builder

Lede Builder #23

Workflow file for this run

name: Lede Builder
on:
repository_dispatch:
workflow_dispatch:
schedule:
- cron: '0 0 1 * *'
env:
REPO_URL: https://github.com/coolsnowwolf/lede
REPO_BRANCH: master
FEEDS_CONF: feeds.conf.default
CONFIG_FILE: lede.config
DIY_P1_SH: scripts/diy-part1.sh
DIY_P2_SH: scripts/diy-part2.sh
UPLOAD_TO_TG_SH: scripts/upload-to-telegram.sh
ENV_SH: scripts/environment.sh
FREE_DISK_SH: scripts/free_disk_space.sh
PATCHES_DIR: patches
UPLOAD_FIRMWARE: false
UPLOAD_RELEASE: true
TZ: Asia/Shanghai
jobs:
prepare_release:
runs-on: ubuntu-22.04
if: github.event.repository.owner.id == github.event.sender.id || github.event_name == 'schedule'
outputs:
release_tag: ${{ steps.release_tag.outputs.release_tag }}
steps:
- name: Get release tag
id: release_tag
run: |
release_tag="Lede-Rockchip-$(date +%Y-%m-%d)"
echo "release_tag=$release_tag" >> $GITHUB_OUTPUT
build_openwrt:
needs: prepare_release
runs-on: ubuntu-22.04
strategy:
matrix:
KERNEL_VERSION: ['5.15', 'latest']
FREQUENCY: ['1.5', '1.6']
SET: ['docker', 'non-docker']
continue-on-error: true
steps:
- name: Checkout source code
uses: actions/checkout@v4
- name: Set environment variables
run: |
echo "KERNEL_VERSION=${{ matrix.KERNEL_VERSION }}" >> $GITHUB_ENV
echo "FREQUENCY=${{ matrix.FREQUENCY }}" >> $GITHUB_ENV
echo "SET=${{ matrix.SET }}" >> $GITHUB_ENV
- name: Initialize environment
env:
DEBIAN_FRONTEND: noninteractive
run: |
chmod +x ${{ env.FREE_DISK_SH }} && ${{ env.FREE_DISK_SH }}
sudo rm -rf /usr/share/dotnet /usr/local/lib/android /opt/ghc
sudo apt-get -qq update -y && sudo apt-get -qq full-upgrade -y
chmod +x ${{ env.ENV_SH }} && ${{ env.ENV_SH }}
sudo -E apt-get -qq autoremove --purge && sudo -E apt-get -qq clean
sudo mkdir -p /workdir && sudo chown $USER:$GROUPS /workdir
- name: Clone source code
working-directory: /workdir
run: |
df -hT $PWD
git clone ${{ env.REPO_URL }} -b ${{ env.REPO_BRANCH }} openwrt
ln -sf /workdir/openwrt $GITHUB_WORKSPACE/openwrt
- name: Cache build
uses: klever1988/cachewrtbuild@main
with:
ccache: 'true'
mixkey: 'armv8_${{ env.KERNEL_VERSION }}'
prefix: ${{ github.workspace }}/openwrt
- name: Apply patches
run: |
if [ "${{ env.KERNEL_VERSION }}" == "5.15" ]; then
echo "Applying 5.15 patches..."
cp -f lede/armv8.mk openwrt/target/linux/rockchip/image/armv8.mk
cp -f lede/uboot-rockchip-Makefile openwrt/package/boot/uboot-rockchip/Makefile
rm -rf openwrt/target/linux/rockchip/files/arch/arm64/boot/dts/rockchip
cp -rf lede/rockchip/files/arch/arm64/boot/dts/rockchip/. openwrt/target/linux/rockchip/files/arch/arm64/boot/dts/rockchip
rm -rf openwrt/target/linux/rockchip/patches-5.15
cp -rf lede/rockchip/patches-5.15/. openwrt/target/linux/rockchip/patches-5.15
sed -i 's/KERNEL_PATCHVER:=.*/KERNEL_PATCHVER:=5.15/g' openwrt/target/linux/rockchip/Makefile
fi
if [ -d "$PATCHES_DIR" ]; then
echo "Applying custom patches from $PATCHES_DIR..."
if [ "${{ env.FREQUENCY }}" == "1.6" ]; then
echo "Removing frequency-specific patch for 1.6..."
rm -f "$PATCHES_DIR"/*999-rk3328-orangepi-r1-plus-lts-patch.patch
fi
mv "$PATCHES_DIR" openwrt/patches
cd openwrt && git apply --ignore-whitespace patches/*.patch && rm -rf patches
fi
- name: Load custom feeds and update packages
run: |
if [ -e $FEEDS_CONF ]; then
echo "Using custom feeds configuration from $FEEDS_CONF..."
mv $FEEDS_CONF openwrt/feeds.conf.default
fi
chmod +x $DIY_P1_SH
cd openwrt && $GITHUB_WORKSPACE/$DIY_P1_SH
./scripts/feeds update -a
echo "Removing unnecessary packages..."
rm -rf feeds/luci/applications/luci-app-mosdns feeds/packages/net/{alist,adguardhome,mosdns,xray*,v2ray*,sing*,smartdns} feeds/packages/utils/v2dat feeds/packages/lang/golang
git clone https://github.com/kenzok8/golang feeds/packages/lang/golang
./scripts/feeds install -a
- name: Load custom configuration
run: |
if [ -e files ]; then
echo "Moving custom files to openwrt..."
mv files openwrt/files
fi
if [ -e $CONFIG_FILE ]; then
echo "Loading custom configuration from $CONFIG_FILE..."
cp $CONFIG_FILE openwrt/.config
fi
if [ "${{ env.FREQUENCY }}" == "1.5" ]; then
echo "Applying frequency-specific configuration for 1.5..."
# sed -i '/^CONFIG_TARGET_MULTI_PROFILE=y/d' openwrt/.config
sed -i '/^CONFIG_TARGET_rockchip_armv8_/ { /_xunlong_orangepi-r1-plus-lts/!d; }' openwrt/.config
sed -i '/^CONFIG_TARGET_DEVICE_rockchip_armv8_/ { /_xunlong_orangepi-r1-plus-lts/!d; }' openwrt/.config
fi
chmod +x $DIY_P2_SH
cd openwrt && $GITHUB_WORKSPACE/$DIY_P2_SH
- name: Download packages and update defconfig
run: |
cd openwrt
if [ "${{ env.SET }}" == "docker" ]; then
echo "Enabling Docker support in the configuration..."
echo "CONFIG_PACKAGE_luci-app-dockerman=y" >> .config
fi
cat .config
make defconfig
cat .config
make download -j8
find dl -size -1024c -exec rm -f {} \;
- name: Get Kernel Patchver
run: |
cd openwrt
grep "^KERNEL_PATCHVER:=" target/linux/rockchip/Makefile | sed 's/KERNEL_PATCHVER:=//' |
awk '{print "KERNEL_PATCHVER=" $0}' >> $GITHUB_ENV
- name: Compile firmware
run: |
cd openwrt
echo "Compiling firmware with $(nproc) threads..."
make -j$(nproc) || make -j1 || make -j1 V=s
- name: Organize files and set firmware output
if: success()
run: |
echo -e "✅ rockchip平台.\n🔔 长时间无法启动请尝试重启或重刷.\n⏰只有 R1 Plus LTS 版本的频率为 1.5GHz,其他版本的频率为 1.6GHz.\n⚠️ 如出现不稳定可尝试cpu降频." >> release.txt
echo "Organizing firmware files..."
cd openwrt/bin/targets/*/*
rm -rf packages
#rm -rf *.buildinfo
#rm -rf *.json
rm -rf *.manifest
ls
SUFFIX="${{ env.KERNEL_PATCHVER }}-${{ env.FREQUENCY }}"
[ "${{ env.SET }}" == "docker" ] && SUFFIX="${SUFFIX}-docker"
for file in *.img.gz; do
drive=$(echo "$file" | sed -E 's/^(openwrt-rockchip-armv8-)(.*)(-(ext4|squashfs)-sysupgrade\.img\.gz)$/\2-\4/')
new_filename="${drive}-${SUFFIX}.img.gz"
echo "Renaming $file to $new_filename"
mv "$file" "$new_filename"
done
echo "SUFFIX=$SUFFIX" >> $GITHUB_ENV
echo "FIRMWARE=$PWD" >> $GITHUB_ENV
- name: Upload firmware to release
if: success() && env.UPLOAD_FIRMWARE == 'true'
uses: actions/upload-artifact@main
with:
name: OpenWrt_firmware_${{ env.SUFFIX }}
path: ${{ env.FIRMWARE }}
- name: Upload firmware to release
uses: softprops/action-gh-release@master
if: success() && env.UPLOAD_RELEASE == 'true'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ needs.prepare_release.outputs.release_tag }}
body_path: release.txt
files: ${{ env.FIRMWARE }}/*
notice_and_cleanup:
needs: build_openwrt
runs-on: ubuntu-22.04
steps:
- name: Delete workflow runs
uses: Mattraks/delete-workflow-runs@main
with:
retain_days: 0
keep_minimum_runs: 2
- name: Remove old releases
if: env.UPLOAD_RELEASE == 'true'
uses: dev-drprasad/delete-older-releases@master
with:
keep_latest: 10
delete_tags: true
delete_tag_pattern: Lede-Rockchip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}