Skip to content

Update main.yml

Update main.yml #159

Workflow file for this run

name: Openwrt Build Bot
on:
push:
branches: master
# schedule:
# - cron: 0 0 * * *
workflow_dispatch:
jobs:
buildpkg:
name: Build Openwrt Package
runs-on: ubuntu-latest
permissions:
contents: write
strategy:
fail-fast: false
matrix:
SDK_URL:
- https://downloads.openwrt.org/releases/23.05.4/targets/ipq806x/generic/openwrt-sdk-23.05.4-ipq806x-generic_gcc-12.3.0_musl_eabi.Linux-x86_64.tar.xz
- https://downloads.openwrt.org/releases/23.05.4/targets/x86/64/openwrt-sdk-23.05.4-x86-64_gcc-12.3.0_musl.Linux-x86_64.tar.xz
steps:
- uses: actions/checkout@main
- name: Env for Openwrt SDK
run: sudo apt update && sudo apt install -y libev-dev libc-ares-dev libudns-dev libncurses-dev libfuse-dev
- name: Download Openwrt SDK
env:
SDK_URL: ${{ matrix.SDK_URL }}
run: |
SDK_HOME=$(head -c -8 <<< $(basename $SDK_URL))
wget -nv $SDK_URL
tar xf $(basename $SDK_URL) -C ~/
mv ~/$SDK_HOME ~/sdk
cp key-build ~/sdk/
- name: Download Packages
run: |
cd ~/sdk
# Shadowsocks
git clone --depth 1 -b master https://github.com/shadowsocks/luci-app-shadowsocks package/luci-app-shadowsocks
git clone --depth 1 -b master https://github.com/shadowsocks/openwrt-shadowsocks package/shadowsocks-libev
git clone --depth 1 -b master https://github.com/aa65535/openwrt-simple-obfs package/simple-obfs
# Misc
git clone --depth 1 -b master https://github.com/aa65535/openwrt-chinadns package/chinadns
git clone --depth 1 -b master https://github.com/aa65535/openwrt-dns-forwarder package/dns-forwarder
git clone --depth 1 -b master https://github.com/aa65535/openwrt-dist-luci package/openwrt-dist-luci
# Vlmcsd
git clone --depth 1 -b master https://github.com/cokebar/openwrt-vlmcsd package/vlmcsd
git clone --depth 1 -b master https://github.com/cokebar/luci-app-vlmcsd package/luci-app-vlmcsd
# Clash
git clone --depth 1 -b master https://github.com/vernesong/OpenClash package/openclash
# Smartdns
git clone --depth 1 -b master https://github.com/pymumu/openwrt-smartdns package/smartdns
git clone --depth 1 -b master https://github.com/pymumu/luci-app-smartdns package/luci-app-smartdns
sed -i 's|../../luci.mk|$(TOPDIR)/feeds/luci/luci.mk|g; 7iPKG_NAME:=luci-app-smartdns' package/luci-app-smartdns/Makefile
# lisaac
pushd /tmp
git clone --depth 1 -b master https://github.com/lisaac/luci-lib-docker
mv luci-lib-docker/collections/luci-lib-docker ~/sdk/package/luci-lib-docker
git clone --depth 1 -b master https://github.com/lisaac/luci-app-dockerman
mv luci-app-dockerman/applications/luci-app-dockerman ~/sdk/package/luci-app-dockerman
git clone --depth 1 -b master https://github.com/lisaac/luci-app-diskman
mv luci-app-diskman/applications/luci-app-diskman ~/sdk/package/luci-app-diskman
popd
# sbwml
git clone --depth 1 https://github.com/sbwml/luci-app-alist package/alist
git clone --depth 1 -b v5 https://github.com/sbwml/luci-app-mosdns package/mosdns
git clone --depth 1 https://github.com/sbwml/v2ray-geodata package/v2ray-geodata
# homeproxy
git clone --depth 1 https://github.com/immortalwrt/homeproxy package/homeproxy
# luci-app-xray
git clone --depth 1 https://github.com/yichya/luci-app-xray package/luci-app-xray
# luci-app-passwall
git clone --depth 1 https://github.com/xiaorouji/openwrt-passwall package/luci-app-passwall
mv package/luci-app-passwall/luci-app-passwall/* package/luci-app-passwall/
# luci-app-passwall2
git clone --depth 1 https://github.com/xiaorouji/openwrt-passwall2 package/luci-app-passwall2
mv package/luci-app-passwall2/luci-app-passwall2/* package/luci-app-passwall2/
# openwrt-passwall-packages (selective)
git clone --depth 1 https://github.com/xiaorouji/openwrt-passwall-packages package/openwrt-passwall-packages
for f in dns2socks dns2tcp tcping chinadns-ng sing-box hysteria; do mv package/openwrt-passwall-packages/$f package/; done
rm -rf package/openwrt-passwall-packages/*
# # libudns for shadowsocksr-libev
# git clone --depth 1 https://github.com/hqvv/openwrt-udns package/network/utils/openwrt-udns
# Dependency
#git clone -b master https://github.com/shadowsocks/openwrt-feeds package/custom
pushd package/openwrt-dist-luci/tools/po2lmo ; make && sudo make install ; popd
./scripts/feeds update -a
# Patch Golang version to be >= 1.22 for alist
curl -L https://raw.githubusercontent.com/openwrt/packages/master/lang/golang/golang/Makefile > feeds/packages/lang/golang/golang/Makefile
# curl -L https://raw.githubusercontent.com/openwrt/packages/master/lang/rust/Makefile > feeds/packages/lang/rust/Makefile
# for p in feeds/packages/lang/rust/patches/*; do
# curl -L -o $p https://raw.githubusercontent.com/openwrt/packages/master/lang/rust/patches/$(basename $p);
# done
./scripts/feeds install golang c-ares libev libopenssl libsodium mbedtls pcre libncursesw6 # rust boost
- name: Compile
run: |
cd ~/sdk
make defconfig
# Edit config
make -j$(nproc) || make V=s
- name: Upload
env:
SDK_URL: ${{ matrix.SDK_URL }}
run: |
BRANCH=$(sed -n 's/.*targets\/\(\w*\)\/\(\w*\)\/.*/packages\/\1\/\2/p' <<< $SDK_URL)
# Switch branch with shallow clone
git remote set-branches origin $BRANCH
git fetch --depth 1 origin $BRANCH
git checkout --track origin/$BRANCH
git branch -avv
# Upload base only
rm -rf *
rsync -av ~/sdk/bin/packages/*/base/ .
git config user.name "GitHub Action"
git config user.email "[email protected]"
git add .
git commit -m "$BRANCH$(TZ='Asia/Shanghai' date +@%Y%m%d)"
git push
# Purge jsdelivr CDN
for file in $(ls); do
curl -i "https://purge.jsdelivr.net/gh/${{ github.repository }}@$BRANCH/${file}"
done
buildimg:
name: Build Openwrt Image
needs: buildpkg
runs-on: ubuntu-latest
permissions:
contents: write
strategy:
fail-fast: false
matrix:
include:
- PROFILE: generic.x86_64
IB_URL: https://downloads.openwrt.org/releases/23.05.4/targets/x86/64/openwrt-imagebuilder-23.05.4-x86-64.Linux-x86_64.tar.xz
PACKAGES: ca-bundle ca-certificates block-mount usbutils coreutils coreutils-base64 curl iperf3 ip-full kmod-ipt-tproxy kmod-nft-tproxy ebtables kmod-ebtables-ipv6 kmod-usb-storage-extras kmod-usb-storage-uas kmod-fs-exfat kmod-fs-vfat kmod-fs-ntfs kmod-fs-ext4 kmod-ipt-nat6 kmod-tun dosfstools ntfs-3g e2fsprogs fdisk libmbedtls luci luci-compat luci-app-samba4 mount-utils uhttpd iperf3 mtr htop tmux lsblk ethtool tcpdump dnsmasq-full -dnsmasq kmod-inet-diag luci-app-statistics xray-core v2ray-geosite v2ray-geoip sing-box openssh-server openssh-sftp-server ss collectd-mod-ping bash vim-full vim-runtime rsync bind-dig hdparm wget-ssl
INCLUDE_FILES: false
ROOTFS_PARTSIZE: 4000
- PROFILE: netgear_r7800
IB_URL: https://downloads.openwrt.org/releases/23.05.4/targets/ipq806x/generic/openwrt-imagebuilder-23.05.4-ipq806x-generic.Linux-x86_64.tar.xz
PACKAGES: ca-bundle ca-certificates block-mount usbutils coreutils coreutils-base64 curl iperf3 ip-full kmod-ipt-tproxy kmod-nft-tproxy kmod-usb-storage-extras kmod-usb-storage-uas kmod-fs-exfat kmod-fs-vfat kmod-fs-ntfs kmod-fs-ext4 kmod-ipt-nat6 kmod-tun dosfstools ntfs-3g e2fsprogs fdisk libmbedtls luci luci-app-wireguard luci-app-samba4 luci-app-shadowsocks luci-app-smartdns luci-app-dns-forwarder luci-app-openclash kmod-inet-diag stubby mount-utils shadowsocks-libev smartdns uhttpd iperf3 mtr htop tmux lsblk ethtool tcpdump wpad-mbedtls -wpad-basic-mbedtls dnsmasq-full -dnsmasq luci-app-statistics xray-core v2ray-geosite v2ray-geoip sing-box openssh-server openssh-sftp-server ss collectd-mod-ping bash vim-full vim-runtime rsync bind-dig hdparm wget-ssl
INCLUDE_FILES: true
ROOTFS_PARTSIZE: 0
steps:
- uses: actions/checkout@main
- name: Env for Openwrt ImageBuilder
run: sudo apt install -y libncurses-dev
- name: Download Openwrt ImageBuilder
env:
IB_URL: ${{ matrix.IB_URL }}
run: |
wget $IB_URL
tar xf $(basename $IB_URL) -C ~/
- name: Fetch Files
env:
IB_URL: ${{ matrix.IB_URL }}
if: matrix.INCLUDE_FILES
run: |
IB_HOME=~/$(basename $IB_URL|head -c -8)
BRANCH=$(sed -n 's/.*targets\/\(\w*\)\/\(\w*\)\/.*/packages\/\1\/\2/p' <<< $IB_URL)
cd $IB_HOME
mkdir -p files/root/
mkdir -p files/etc/opkg/
cp ${{ github.workspace }}/simonsmh-dist.pub files/root/
echo "src/gz 2fact https://github.com/2fact/openwrt-dist/raw/$BRANCH" > files/etc/opkg/customfeeds.conf
- name: Build Image
shell: bash
env:
PROFILE: ${{ matrix.PROFILE }}
IB_URL: ${{ matrix.IB_URL }}
PACKAGES: ${{ matrix.PACKAGES }}
ROOTFS_PARTSIZE: ${{ matrix.ROOTFS_PARTSIZE }}
run: |
IB_HOME=~/$(basename $IB_URL|head -c -8)
BRANCH=$(sed -n 's/.*targets\/\(\w*\)\/\(\w*\)\/.*/packages\/\1\/\2/p' <<< $IB_URL)
cd $IB_HOME
sed -i "/check_signature/d" repositories.conf
echo "src/gz 2fact https://github.com/2fact/openwrt-dist/raw/$BRANCH" >> repositories.conf
makeopts=("PROFILE=${PROFILE%.*}" "PACKAGES=$PACKAGES")
[[ -d files ]] && makeopts+=("FILES=files/")
[[ $ROOTFS_PARTSIZE -gt 0 ]] && makeopts+=("ROOTFS_PARTSIZE=$ROOTFS_PARTSIZE")
make info
TERM=xterm-256color make image "${makeopts[@]}"
- name: Upload
id: upload
env:
PROFILE: ${{ matrix.PROFILE }}
IB_URL: ${{ matrix.IB_URL }}
run: |
IB_HOME=~/$(basename $IB_URL|head -c -8)
TAG=$(sed -n 's/.*targets\/\(\w*\)\/\(\w*\)\/.*/packages\/\1\/\2/p' <<< $IB_URL)
IMAGES=$IB_HOME/bin/targets/$(cut -b 10- <<< $TAG)
# Upload image
BRANCH="image/$PROFILE"
git remote set-branches origin $BRANCH
git fetch --depth 1 origin $BRANCH
git checkout --track origin/$BRANCH
git branch -avv
rm -rf *
rsync -av $IMAGES/ .
git config user.name "GitHub Action"
git config user.email "[email protected]"
git add .
git commit -m "$PROFILE$(TZ='Asia/Shanghai' date +@%Y%m%d)"
git push
- uses: actions/upload-artifact@main
with:
name: image_${{ matrix.PROFILE }}
path: |
./
!./.git