OpenWrt-CI #233
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/KFERMercer/OpenWrt-CI> | |
# | |
# Copyright (C) 2019 P3TERX | |
# | |
# Copyright (C) 2020 KFERMercer | |
# | |
name: OpenWrt-CI | |
on: | |
schedule: | |
- cron: 0 20 * * * | |
push: | |
branches: | |
- master | |
permissions: | |
contents: read | |
jobs: | |
build_openwrt: | |
name: Build OpenWrt Firmware | |
runs-on: ubuntu-latest | |
steps: | |
- name: Space cleanup and Initialization environment | |
env: | |
DEBIAN_FRONTEND: noninteractive | |
run: | | |
docker rmi `docker images -q` | |
sudo -E rm -rf /usr/share/dotnet /etc/mysql /etc/php /etc/apt/sources.list.d /usr/local/lib/android | |
sudo -E apt-mark hold grub-efi-amd64-signed | |
sudo -E apt update | |
sudo -E apt -y purge azure-cli* docker* ghc* zulu* llvm* firefox google* dotnet* powershell* openjdk* mysql* php* mongodb* dotnet* snap* | |
sudo -E apt -y full-upgrade | |
sudo -E apt -y install ack antlr3 aria2 asciidoc autoconf automake autopoint binutils bison build-essential bzip2 ccache cmake cpio curl device-tree-compiler fastjar flex gawk gettext gcc-multilib g++-multilib git gperf haveged help2man intltool libc6-dev-i386 libelf-dev libglib2.0-dev libgmp3-dev libltdl-dev libmpc-dev libmpfr-dev libncurses5-dev libncursesw5-dev libreadline-dev libssl-dev libtool lrzsz mkisofs msmtp nano ninja-build p7zip p7zip-full patch pkgconf python3 python3-pip libpython3-dev qemu-utils rsync scons squashfs-tools subversion swig texinfo uglifyjs upx-ucl unzip vim wget xmlto xxd zlib1g-dev | |
sudo -E systemctl daemon-reload | |
sudo -E apt -y autoremove --purge | |
sudo -E apt clean | |
sudo -E timedatectl set-timezone "Asia/Shanghai" | |
- name: Checkout OpenWrt | |
uses: actions/checkout@v3 | |
- name: Update feeds | |
run: | | |
# Clone 项目 | |
mkdir package/luci-app-openclash | |
cd package/luci-app-openclash | |
git init | |
git remote add -f origin https://github.com/vernesong/OpenClash.git | |
git config core.sparsecheckout true | |
echo "luci-app-openclash" >> .git/info/sparse-checkout | |
git pull origin master | |
git branch --set-upstream-to=origin/master master | |
cd - | |
sed -i 's/#src-git helloworld/src-git helloworld/g' ./feeds.conf.default | |
./scripts/feeds update -a | |
./scripts/feeds install -a | |
- name: Generate configuration file | |
run: | | |
rm -f ./.config* | |
touch ./.config | |
# | |
# 在 cat >> .config <<EOF 到 EOF 之间粘贴你的编译配置, 需注意缩进关系 | |
# 例如: | |
cat >> .config <<EOF | |
CONFIG_TARGET_x86_64=y | |
CONFIG_TARGET_x86_64_Generic=y | |
CONFIG_TARGET_IMAGES_GZIP=y | |
CONFIG_PACKAGE_luci-app-autoreboot=y | |
CONFIG_PACKAGE_luci-app-firewall=y | |
CONFIG_PACKAGE_luci-app-ramfree=y | |
CONFIG_PACKAGE_luci-app-ttyd=y | |
CONFIG_PACKAGE_luci-theme-bootstrap=y | |
CONFIG_PACKAGE_luci-app-openclash=y | |
CONFIG_PACKAGE_luci-app-turboacc=y | |
CONFIG_PACKAGE_luci-app-mosdns=y | |
CONFIG_PACKAGE_luci-app-usb-printer=y | |
# CONFIG_VMDK_IMAGES is not set | |
# CONFIG_PACKAGE_luci-app-zerotier is not set | |
# CONFIG_PACKAGE_luci-app-ipsec-server is not set | |
# CONFIG_PACKAGE_luci-app-adbyby-plus is not set | |
# CONFIG_PACKAGE_luci-app-unblockmusic is not set | |
# CONFIG_PACKAGE_luci-app-accesscontrol is not set | |
# CONFIG_PACKAGE_luci-app-diskman is not set | |
# CONFIG_PACKAGE_luci-app-dockerman is not set | |
# CONFIG_PACKAGE_luci-app-arpbind is not set | |
# CONFIG_PACKAGE_luci-app-ipsec-vpnd is not set | |
# CONFIG_PACKAGE_luci-app-n2n_v2 is not set | |
# CONFIG_PACKAGE_luci-app-nlbwmon is not set | |
# CONFIG_PACKAGE_luci-app-qbittorrent is not set | |
# CONFIG_PACKAGE_luci-app-smartdns is not set | |
# CONFIG_PACKAGE_luci-app-upnp is not set | |
# CONFIG_PACKAGE_luci-app-uugamebooster is not set | |
# CONFIG_PACKAGE_luci-app-vsftpd is not set | |
# CONFIG_PACKAGE_luci-app-webadmin is not set | |
# CONFIG_PACKAGE_luci-app-wireguard is not set | |
# CONFIG_PACKAGE_luci-app-xlnetacc is not set | |
# CONFIG_PACKAGE_luci-app-filetransfer is not set | |
# 基础包 | |
# CONFIG_PACKAGE_block-mount is not set | |
# CONFIG_PACKAGE_automount is not set | |
# 设置分区大小 | |
CONFIG_TARGET_KERNEL_PARTSIZE=32 | |
CONFIG_TARGET_ROOTFS_PARTSIZE=760 | |
EOF | |
# | |
# =============================================================== | |
# | |
sed -i 's/^[ \t]*//g' ./.config | |
make defconfig | |
# 网络配置信息,将从 zzz-default-settings 文件的第2行开始添加 | |
sed -i "2i # network config" ./package/lean/default-settings/files/zzz-default-settings | |
# 默认 IP 地址,旁路由时不会和主路由的 192.168.1.1 冲突 | |
sed -i "3i uci set network.lan.ipaddr='192.168.123.111'" ./package/lean/default-settings/files/zzz-default-settings | |
sed -i "4i uci set network.lan.proto='static'" ./package/lean/default-settings/files/zzz-default-settings # 静态 IP | |
sed -i "5i uci set network.lan.type='bridge'" ./package/lean/default-settings/files/zzz-default-settings # 接口类型:桥接 | |
sed -i "6i uci set network.lan.ifname='eth0'" ./package/lean/default-settings/files/zzz-default-settings # 网络端口:默认 eth0,第一个接口 | |
sed -i "7i uci set network.lan.netmask='255.255.255.0'" ./package/lean/default-settings/files/zzz-default-settings # 子网掩码 | |
sed -i "8i uci set network.lan.gateway='192.168.123.1'" ./package/lean/default-settings/files/zzz-default-settings # 默认网关地址(主路由 IP) | |
sed -i "9i uci set network.lan.broadcast='192.168.123.255'" ./package/lean/default-settings/files/zzz-default-settings # ip v4广播 | |
sed -i "10i uci set network.lan.dns='192.168.123.1'" ./package/lean/default-settings/files/zzz-default-settings # 默认上游 DNS 地址 | |
sed -i "11i uci commit network\n" ./package/lean/default-settings/files/zzz-default-settings | |
#旁路由设置 | |
sed -i "12i uci set dhcp.lan=dhcp" ./package/lean/default-settings/files/zzz-default-settings | |
sed -i "13i uci set dhcp.lan.interface='lan'" ./package/lean/default-settings/files/zzz-default-settings | |
sed -i "14i uci set dhcp.lan.ignore='1'" ./package/lean/default-settings/files/zzz-default-settings | |
sed -i "15i uci set dhcp.wan=dhcp" ./package/lean/default-settings/files/zzz-default-settings | |
sed -i "16i uci set dhcp.wan.interface='wan'" ./package/lean/default-settings/files/zzz-default-settings | |
sed -i "17i uci set dhcp.wan.ignore='1'" ./package/lean/default-settings/files/zzz-default-settings | |
sed -i "18i uci delete dhcp.lan.dhcpv6=disabled" ./package/lean/default-settings/files/zzz-default-settings | |
sed -i "19i uci delete dhcp.lan.leasetime='12h'" ./package/lean/default-settings/files/zzz-default-settings | |
sed -i "20i uci delete dhcp.lan.ra='server'" ./package/lean/default-settings/files/zzz-default-settings | |
sed -i "21i uci delete dhcp.lan.ra_management='1'" ./package/lean/default-settings/files/zzz-default-settings | |
sed -i "22i uci delete dhcp.lan.ra_default='1'" ./package/lean/default-settings/files/zzz-default-settings | |
sed -i "23i uci delete dhcp.lan.start='20'" ./package/lean/default-settings/files/zzz-default-settings | |
sed -i "24i uci delete dhcp.lan.limit='40'" ./package/lean/default-settings/files/zzz-default-settings | |
sed -i "25i uci delete dhcp.lan.force='1'" ./package/lean/default-settings/files/zzz-default-settings | |
sed -i "26i uci commit dhcp\n" ./package/lean/default-settings/files/zzz-default-settings | |
- name: Download packages | |
run: make download -j16 | |
- name: Compile firmware | |
run: | | |
make -j$(nproc) || make -j1 V=s | |
echo "=======================" | |
echo "Space usage:" | |
echo "=======================" | |
df -h | |
echo "=======================" | |
du -h --max-depth=1 ./ --exclude=build_dir --exclude=bin | |
du -h --max-depth=1 ./build_dir | |
du -h --max-depth=1 ./bin | |
- name: Prepare artifact | |
run: | | |
mkdir -p ./artifact/package | |
mkdir -p ./artifact/buildinfo | |
rm -rf $(find ./bin/targets/ -type d -name "packages") | |
cp -rf $(find ./bin/packages/ -type f -name "*.ipk") ./artifact/package/ | |
cp -rf $(find ./bin/targets/ -type f -name "*.buildinfo" -o -name "*.manifest") ./artifact/buildinfo/ | |
- name: Upload buildinfo | |
uses: actions/upload-artifact@v3 | |
with: | |
name: OpenWrt_buildinfo | |
path: ./artifact/buildinfo | |
- name: Upload package | |
uses: actions/upload-artifact@v3 | |
with: | |
name: OpenWrt_package | |
path: ./artifact/package/ | |
- name: Upload firmware | |
uses: actions/upload-artifact@v3 | |
with: | |
name: OpenWrt_firmware | |
path: ./bin/targets/ |