Skip to content

Auto compile with openwrt sdk #41

Auto compile with openwrt sdk

Auto compile with openwrt sdk #41

#
# Copyright (c) 2022-2023 SMALLPROGRAM <https://github.com/smallprogram>
# Description: Auto compile
#
name: "Auto compile with openwrt sdk"
on:
schedule:
- cron: "30 23 * * 0"
#- cron: "10 5 * * *"
repository_dispatch:
workflow_dispatch:
inputs:
branch:
description: 'branch'
required: true
default: 'luci-smartdns-dev'
type: choice
options:
- luci-smartdns-dev
- main
env:
TZ: Asia/Shanghai
passwall: xiaorouji/openwrt-passwall
packages: xiaorouji/openwrt-passwall-packages
branch: luci-smartdns-dev
jobs:
job_check:
name: Check Version
runs-on: ubuntu-latest
outputs:
passwall_version: ${{ steps.check_version.outputs.latest_version }}
has_update: ${{ steps.check_version.outputs.has_update }}
steps:
- name: Check branch
if: ${{ github.event.inputs.branch }}
env:
branch: ${{ github.event.inputs.branch }}
run: |
echo "branch: ${{env.branch}}"
- name: Checkout
uses: actions/checkout@main
with:
fetch-depth: 0
ref: 'luci-smartdns-new-version'
- name: Check version
id: check_version
env:
url_release: https://api.github.com/repos/yoier/passwall-smartdns-dev-build/releases/latest
url_lastest_version: https://raw.githubusercontent.com/xiaorouji/openwrt-passwall/main/luci-app-passwall/Makefile
run: |
cd luci-app-passwall
latest_version=$(wget -qO- -t1 -T2 ${{env.url_lastest_version}} | awk -F ':=' '/PKG_VERSION|PKG_RELEASE/ {print $2}' | sed ':a;N;s/\n$//;s/\n/-/;ba')
latest_release=$(wget -qO- -t1 -T2 ${{env.url_release}} | awk -F '"' '/tag_name/{print $4}' )
has_update=$([ "${latest_version}" != "${latest_release}" ] && echo true || echo false)
echo "latest_version=${latest_version}" >> $GITHUB_OUTPUT
echo "has_update=${has_update}" >> $GITHUB_OUTPUT
echo "latest_version: ${latest_version}"
echo "latest_release: ${latest_release}"
echo "has_update: ${has_update}"
- name: Prepare release
if: steps.check_version.outputs.has_update == 'true'
run: |
echo "### Passwall Info" >> release.txt
echo "**:minidisc: Passwall Version: ${{steps.check_version.outputs.latest_version}}**" >> release.txt
touch release.txt
- name: Generate new tag & release
if: steps.check_version.outputs.has_update == 'true'
uses: softprops/action-gh-release@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{steps.check_version.outputs.latest_version}}
body_path: release.txt
job_build_passwall:
name: Build passwall [Luci ${{ matrix.luci_ver }}]
needs: job_check
if: needs.job_check.outputs.has_update == 'true'
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- sdk_ver: 21.02
luci_ver: 19.07
sdk_url: https://downloads.openwrt.org/releases/21.02.5/targets/x86/64/openwrt-sdk-21.02.5-x86-64_gcc-8.4.0_musl.Linux-x86_64.tar.xz
- sdk_ver: 23.05
luci_ver: 23.05
sdk_url: https://downloads.openwrt.org/releases/23.05.0/targets/x86/64/openwrt-sdk-23.05.0-x86-64_gcc-12.3.0_musl.Linux-x86_64.tar.xz
steps:
- name: Install packages
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
echo "Install packages"
sudo -E apt-get -qq update
sudo -E apt-get -qq install build-essential clang flex bison g++ gawk gcc-multilib g++-multilib gettext git libncurses5-dev libssl-dev python3-distutils rsync unzip zlib1g-dev file wget
sudo -E apt-get -qq autoremove --purge
sudo -E apt-get -qq clean
- name: Cache openwrt SDK
if: false
id: cache-sdk
uses: actions/cache@v4
with:
path: sdk
key: openwrt-luci-${{ matrix.luci_ver }}-x86_64
- name: Initialization environment
if: steps.cache-sdk.outputs.cache-hit != 'true'
run: |
wget ${{ matrix.sdk_url }}
file_name=$(echo ${{ matrix.sdk_url }} | awk -F/ '{print $NF}')
mkdir sdk && tar -xJf $file_name -C ./sdk --strip-components=1
cd sdk
echo "src-git base https://github.com/openwrt/openwrt.git;openwrt-${{ matrix.sdk_ver }}" > feeds.conf
echo "src-git packages https://github.com/openwrt/packages.git;openwrt-${{ matrix.sdk_ver }}" >> feeds.conf
echo "src-git luci https://github.com/openwrt/luci.git;openwrt-${{ matrix.luci_ver }}" >> feeds.conf
echo "src-git routing https://git.openwrt.org/feed/routing.git;openwrt-${{ matrix.sdk_ver }}" >> feeds.conf
echo "src-git passwall_packages https://github.com/${{ env.packages }}.git;main" >> feeds.conf
echo "src-git passwall https://github.com/${{ env.passwall }}.git;${{ env.branch }}" >> feeds.conf
./scripts/feeds update -a
echo "CONFIG_PACKAGE_luci-app-passwall=m" > .config
./scripts/feeds install -d n luci-app-passwall
make download -j8
- name: Configure passwall
run: |
cd sdk
./scripts/feeds update passwall_packages
./scripts/feeds update passwall
./scripts/feeds install luci-app-passwall
echo "CONFIG_ALL_NONSHARED=n" > .config
echo "CONFIG_ALL_KMODS=n" >> .config
echo "CONFIG_ALL=n" >> .config
echo "CONFIG_AUTOREMOVE=n" >> .config
echo "CONFIG_LUCI_LANG_zh_Hans=y" >> .config
echo "CONFIG_PACKAGE_luci-app-passwall=m" >> .config
echo "CONFIG_PACKAGE_luci-app-passwall_Iptables_Transparent_Proxy=n" >> .config
echo "CONFIG_PACKAGE_luci-app-passwall_Nftables_Transparent_Proxy=n" >> .config
echo "CONFIG_PACKAGE_luci-app-passwall_INCLUDE_ChinaDNS_NG=n" >> .config
echo "CONFIG_PACKAGE_luci-app-passwall_INCLUDE_Haproxy=n" >> .config
echo "CONFIG_PACKAGE_luci-app-passwall_INCLUDE_Hysteria=n" >> .config
echo "CONFIG_PACKAGE_luci-app-passwall_INCLUDE_NaiveProxy=n" >> .config
echo "CONFIG_PACKAGE_luci-app-passwall_INCLUDE_Shadowsocks_Libev_Client=n" >> .config
echo "CONFIG_PACKAGE_luci-app-passwall_INCLUDE_Shadowsocks_Libev_Server=n" >> .config
echo "CONFIG_PACKAGE_luci-app-passwall_INCLUDE_Shadowsocks_Rust_Client=n" >> .config
echo "CONFIG_PACKAGE_luci-app-passwall_INCLUDE_Shadowsocks_Rust_Server=n" >> .config
echo "CONFIG_PACKAGE_luci-app-passwall_INCLUDE_ShadowsocksR_Libev_Client=n" >> .config
echo "CONFIG_PACKAGE_luci-app-passwall_INCLUDE_ShadowsocksR_Libev_Server=n" >> .config
echo "CONFIG_PACKAGE_luci-app-passwall_INCLUDE_Simple_Obfs=n" >> .config
echo "CONFIG_PACKAGE_luci-app-passwall_INCLUDE_SingBox=n" >> .config
echo "CONFIG_PACKAGE_luci-app-passwall_INCLUDE_Trojan_Plus=n" >> .config
echo "CONFIG_PACKAGE_luci-app-passwall_INCLUDE_tuic_client=n" >> .config
echo "CONFIG_PACKAGE_luci-app-passwall_INCLUDE_V2ray_Geodata=n" >> .config
echo "CONFIG_PACKAGE_luci-app-passwall_INCLUDE_V2ray_Plugin=n" >> .config
echo "CONFIG_PACKAGE_luci-app-passwall_INCLUDE_Xray=n" >> .config
echo "CONFIG_PACKAGE_luci-app-passwall_INCLUDE_Xray_Plugin=n" >> .config
make defconfig
- name: Compile passwall
id: compile
run: |
cd sdk
echo "make package/luci-app-passwall/{clean,compile} -j$(nproc)"
make package/luci-app-passwall/{clean,compile} -j$(nproc)
mv bin/packages/x86_64/passwall/ ../
make clean
rm .config .config.old
cd ../passwall
for i in $(ls); do mv $i luci-${{ matrix.luci_ver }}_$i; done
cd ..
echo "status=success" >> $GITHUB_OUTPUT
echo "FIRMWARE=$PWD" >> $GITHUB_ENV
- name: Upload passwall ipks to release
uses: softprops/action-gh-release@master
if: steps.compile.outputs.status == 'success'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{needs.job_check.outputs.passwall_version}}
files: ${{ env.FIRMWARE }}/passwall/*.ipk