Files
Archive/openwrt-passwall2/.github/workflows/Auto compile with openwrt sdk.yml
2024-08-31 20:34:35 +02:00

376 lines
18 KiB
YAML

#
# Copyright (c) 2022-2023 SMALLPROGRAM <https://github.com/smallprogram>
# Description: Auto compile
#
name: "Auto compile with openwrt sdk"
on:
repository_dispatch:
workflow_dispatch:
inputs:
ssh:
description: 'SSH connection to Actions'
required: false
default: 'false'
push:
branches:
- 'main'
paths:
- 'luci-app-passwall2/Makefile'
env:
TZ: Asia/Shanghai
passwall2: ${{ github.repository }}
packages: xiaorouji/openwrt-passwall-packages
jobs:
job_check:
name: Check Version
runs-on: ubuntu-latest
outputs:
passwall2_version: ${{ steps.check_version.outputs.latest_version }}
has_update: ${{ steps.check_version.outputs.has_update }}
steps:
- name: Checkout
uses: actions/checkout@main
with:
fetch-depth: 0
ref: 'main'
- name: Check version
id: check_version
env:
url_release: https://api.github.com/repos/${{ env.passwall2 }}/releases/latest
run: |
cd luci-app-passwall2
latest_version=$(awk -F ':=' '/PKG_VERSION|PKG_RELEASE/ {print $2}' Makefile | 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 "## :mega:Update content" >> release.txt
echo "![](https://img.shields.io/github/downloads/${{ env.passwall2 }}/${{steps.check_version.outputs.latest_version}}/total?style=flat-square)" >> release.txt
echo "### Passwall2 Info" >> release.txt
echo "**:minidisc: Passwall2 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_passwall2:
name: Build passwall2 [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
df -hT
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
id: cache-sdk
uses: actions/cache@v4
with:
path: sdk
key: openwrt-sdk-23.05-rc3-x86_64
- name: Initialization environment
if: steps.cache-sdk.outputs.cache-hit != 'true'
env:
url_sdk: 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
run: |
wget ${{ env.url_sdk }}
file_name=$(echo ${{env.url_sdk}} | 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 passwall2 https://github.com/${{ env.passwall2 }}.git;main" >> feeds.conf
./scripts/feeds update -a
echo "CONFIG_PACKAGE_luci-app-passwall2=m" > .config
./scripts/feeds install -d n luci-app-passwall2
make download -j8
- name: Configure passwall2
run: |
cd sdk
./scripts/feeds update passwall_packages
./scripts/feeds update passwall2
./scripts/feeds install luci-app-passwall2
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-passwall2=m" >> .config
echo "CONFIG_PACKAGE_luci-app-passwall2_Iptables_Transparent_Proxy=n" >> .config
echo "CONFIG_PACKAGE_luci-app-passwall2_Nftables_Transparent_Proxy=n" >> .config
echo "CONFIG_PACKAGE_luci-app-passwall2_INCLUDE_Haproxy=n" >> .config
echo "CONFIG_PACKAGE_luci-app-passwall2_INCLUDE_Hysteria=n" >> .config
echo "CONFIG_PACKAGE_luci-app-passwall2_INCLUDE_IPv6_Nat=n" >> .config
echo "CONFIG_PACKAGE_luci-app-passwall2_INCLUDE_NaiveProxy=n" >> .config
echo "CONFIG_PACKAGE_luci-app-passwall2_INCLUDE_Shadowsocks_Libev_Client=n" >> .config
echo "CONFIG_PACKAGE_luci-app-passwall2_INCLUDE_Shadowsocks_Libev_Server=n" >> .config
echo "CONFIG_PACKAGE_luci-app-passwall2_INCLUDE_Shadowsocks_Rust_Client=n" >> .config
echo "CONFIG_PACKAGE_luci-app-passwall2_INCLUDE_Shadowsocks_Rust_Server=n" >> .config
echo "CONFIG_PACKAGE_luci-app-passwall2_INCLUDE_ShadowsocksR_Libev_Client=n" >> .config
echo "CONFIG_PACKAGE_luci-app-passwall2_INCLUDE_ShadowsocksR_Libev_Server=n" >> .config
echo "CONFIG_PACKAGE_luci-app-passwall2_INCLUDE_Simple_Obfs=n" >> .config
echo "CONFIG_PACKAGE_luci-app-passwall2_INCLUDE_SingBox=n" >> .config
echo "CONFIG_PACKAGE_luci-app-passwall2_INCLUDE_tuic_client=n" >> .config
echo "CONFIG_PACKAGE_luci-app-passwall2_INCLUDE_V2ray_Plugin=n" >> .config
make defconfig
- name: Compile passwall2
id: compile
run: |
cd sdk
echo "make package/luci-app-passwall2/{clean,compile} -j$(nproc)"
make package/luci-app-passwall2/{clean,compile} -j1
mv bin/packages/x86_64/passwall2/ ../
rm .config .config.old
cd ../passwall2
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 passwall2 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.passwall2_version}}
files: ${{ env.FIRMWARE }}/passwall2/*.ipk
job_auto_compile:
if: needs.job_check.outputs.has_update == 'true'
needs: job_check
runs-on: ubuntu-latest
name: build (${{ matrix.platform }})
strategy:
fail-fast: false
matrix:
include:
- platform: x86_64
url_sdk: 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
- platform: aarch64_generic
url_sdk: https://downloads.openwrt.org/releases/23.05.0/targets/rockchip/armv8/openwrt-sdk-23.05.0-rockchip-armv8_gcc-12.3.0_musl.Linux-x86_64.tar.xz
- platform: aarch64_cortex-a53
url_sdk: https://downloads.openwrt.org/releases/23.05.0/targets/mvebu/cortexa53/openwrt-sdk-23.05.0-mvebu-cortexa53_gcc-12.3.0_musl.Linux-x86_64.tar.xz
- platform: aarch64_cortex-a72
url_sdk: https://downloads.openwrt.org/releases/23.05.0/targets/mvebu/cortexa72/openwrt-sdk-23.05.0-mvebu-cortexa72_gcc-12.3.0_musl.Linux-x86_64.tar.xz
- platform: arm_cortex-a7
url_sdk: https://downloads.openwrt.org/releases/23.05.0/targets/mediatek/mt7629/openwrt-sdk-23.05.0-mediatek-mt7629_gcc-12.3.0_musl_eabi.Linux-x86_64.tar.xz
- platform: arm_cortex-a7_neon-vfpv4
url_sdk: https://downloads.openwrt.org/releases/23.05.0/targets/sunxi/cortexa7/openwrt-sdk-23.05.0-sunxi-cortexa7_gcc-12.3.0_musl_eabi.Linux-x86_64.tar.xz
- platform: arm_cortex-a8_vfpv3
url_sdk: https://downloads.openwrt.org/releases/23.05.0/targets/sunxi/cortexa8/openwrt-sdk-23.05.0-sunxi-cortexa8_gcc-12.3.0_musl_eabi.Linux-x86_64.tar.xz
- platform: arm_cortex-a9
url_sdk: https://downloads.openwrt.org/releases/23.05.0/targets/bcm53xx/generic/openwrt-sdk-23.05.0-bcm53xx-generic_gcc-12.3.0_musl_eabi.Linux-x86_64.tar.xz
- platform: arm_cortex-a9_neon
url_sdk: https://downloads.openwrt.org/releases/23.05.0/targets/zynq/generic/openwrt-sdk-23.05.0-zynq-generic_gcc-12.3.0_musl_eabi.Linux-x86_64.tar.xz
- platform: arm_cortex-a9_vfpv3-d16
url_sdk: https://downloads.openwrt.org/releases/23.05.0/targets/mvebu/cortexa9/openwrt-sdk-23.05.0-mvebu-cortexa9_gcc-12.3.0_musl_eabi.Linux-x86_64.tar.xz
- platform: arm_cortex-a15_neon-vfpv4
url_sdk: https://downloads.openwrt.org/releases/23.05.0/targets/ipq806x/generic/openwrt-sdk-23.05.0-ipq806x-generic_gcc-12.3.0_musl_eabi.Linux-x86_64.tar.xz
- platform: mips_24kc
url_sdk: https://downloads.openwrt.org/releases/23.05.0/targets/ath79/generic/openwrt-sdk-23.05.0-ath79-generic_gcc-12.3.0_musl.Linux-x86_64.tar.xz
- platform: mips_4kec
url_sdk: https://downloads.openwrt.org/releases/23.05.0/targets/realtek/rtl838x/openwrt-sdk-23.05.0-realtek-rtl838x_gcc-12.3.0_musl.Linux-x86_64.tar.xz
- platform: mips_mips32
url_sdk: https://downloads.openwrt.org/releases/23.05.0/targets/bcm63xx/generic/openwrt-sdk-23.05.0-bcm63xx-generic_gcc-12.3.0_musl.Linux-x86_64.tar.xz
- platform: mipsel_24kc
url_sdk: https://downloads.openwrt.org/releases/23.05.0/targets/ramips/rt288x/openwrt-sdk-23.05.0-ramips-rt288x_gcc-12.3.0_musl.Linux-x86_64.tar.xz
- platform: mipsel_74kc
url_sdk: https://downloads.openwrt.org/releases/23.05.0/targets/ramips/rt3883/openwrt-sdk-23.05.0-ramips-rt3883_gcc-12.3.0_musl.Linux-x86_64.tar.xz
- platform: mipsel_mips32
url_sdk: https://downloads.openwrt.org/releases/23.05.0/targets/bcm47xx/generic/openwrt-sdk-23.05.0-bcm47xx-generic_gcc-12.3.0_musl.Linux-x86_64.tar.xz
steps:
- name: Initialization ${{ matrix.platform }} compile environment
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
df -hT
echo "install packages!!!!!!"
sudo -E apt-get -qq update
sudo -E apt-get -qq install $(curl -fsSL https://github.com/smallprogram/OpenWrtAction/raw/main/diy_script/official_dependence)
sudo -E apt-get -qq autoremove --purge
sudo -E apt-get -qq clean
- name: ${{ matrix.platform }} sdk download
run: |
wget ${{ matrix.url_sdk }}
file_name=$(echo ${{matrix.url_sdk}} | awk -F/ '{print $NF}')
mkdir sdk && tar -xJf $file_name -C ./sdk --strip-components=1
cd sdk
- name: SSH connection to Actions
uses: mxschmitt/action-tmate@v3.13
if: (github.event.inputs.ssh == 'true' && github.event.inputs.ssh != 'false') || contains(github.event.action, 'ssh')
- name: ${{ matrix.platform }} feeds configuration packages
run: |
cd sdk
echo "src-git base https://github.com/openwrt/openwrt.git;openwrt-23.05" > feeds.conf
echo "src-git packages https://github.com/openwrt/packages.git;openwrt-23.05" >> feeds.conf
echo "src-git luci https://github.com/openwrt/luci.git;openwrt-23.05" >> feeds.conf
echo "src-git routing https://git.openwrt.org/feed/routing.git;openwrt-23.05" >> feeds.conf
echo "src-git passwall_packages https://github.com/${{ env.packages}}.git;main" >> feeds.conf
echo "src-git passwall2 https://github.com/${{ env.passwall2 }}.git;main" >> feeds.conf
./scripts/feeds update -a
./scripts/feeds install -a -f -p passwall_packages
./scripts/feeds install luci-app-passwall2
rm -rf feeds/packages/lang/golang
git clone https://github.com/sbwml/packages_lang_golang -b 22.x feeds/packages/lang/golang
echo "CONFIG_ALL_NONSHARED=n" > .config
echo "CONFIG_ALL_KMODS=n" >> .config
echo "CONFIG_ALL=n" >> .config
echo "CONFIG_AUTOREMOVE=n" >> .config
echo "CONFIG_PACKAGE_luci-app-passwall2=m" >> .config
echo "CONFIG_PACKAGE_luci-app-passwall2_Iptables_Transparent_Proxy=y" >> .config
echo "CONFIG_PACKAGE_luci-app-passwall2_Nftables_Transparent_Proxy=y" >> .config
echo "CONFIG_PACKAGE_luci-app-passwall2_INCLUDE_Haproxy=y" >> .config
echo "CONFIG_PACKAGE_luci-app-passwall2_INCLUDE_Hysteria=y" >> .config
echo "CONFIG_PACKAGE_luci-app-passwall2_INCLUDE_IPv6_Nat=y" >> .config
echo "CONFIG_PACKAGE_luci-app-passwall2_INCLUDE_NaiveProxy=y" >> .config
echo "CONFIG_PACKAGE_luci-app-passwall2_INCLUDE_Shadowsocks_Libev_Client=y" >> .config
echo "CONFIG_PACKAGE_luci-app-passwall2_INCLUDE_Shadowsocks_Libev_Server=y" >> .config
echo "CONFIG_PACKAGE_luci-app-passwall2_INCLUDE_Shadowsocks_Rust_Client=y" >> .config
echo "CONFIG_PACKAGE_luci-app-passwall2_INCLUDE_Shadowsocks_Rust_Server=y" >> .config
echo "CONFIG_PACKAGE_luci-app-passwall2_INCLUDE_ShadowsocksR_Libev_Client=y" >> .config
echo "CONFIG_PACKAGE_luci-app-passwall2_INCLUDE_ShadowsocksR_Libev_Server=y" >> .config
echo "CONFIG_PACKAGE_luci-app-passwall2_INCLUDE_Simple_Obfs=y" >> .config
echo "CONFIG_PACKAGE_luci-app-passwall2_INCLUDE_SingBox=y" >> .config
echo "CONFIG_PACKAGE_luci-app-passwall2_INCLUDE_tuic_client=y" >> .config
echo "CONFIG_PACKAGE_luci-app-passwall2_INCLUDE_V2ray_Plugin=y" >> .config
make defconfig
- name: ${{ matrix.platform }} download
run: |
cd sdk
make download -j8
find dl -size -1024c -exec ls -l {} \;
- name: ${{ matrix.platform }} compile
id: compile
run: |
cd sdk
for package in $(ls feeds/passwall_packages); do
if [ -d "feeds/passwall_packages/$package" ]; then
make package/feeds/passwall_packages/$package/compile -j$(nproc) 2>/dev/null
fi
done
echo "status=success" >> $GITHUB_OUTPUT
- name: Organize ${{ matrix.platform }} files
id: organize
if: steps.compile.outputs.status == 'success'
run: |
cd sdk
mkdir upload
zip -jr upload/passwall2_packages_ipk_${{ matrix.platform }}.zip bin/packages/*/passwall_packages/
echo "FIRMWARE=$PWD" >> $GITHUB_ENV
echo "status=success" >> $GITHUB_OUTPUT
- name: Generate release info
id: info
if: steps.compile.outputs.status == 'success'
run: |
cd sdk
echo "## :mega:Update content" >> release.txt
echo "![](https://img.shields.io/github/downloads/${{ env.passwall2 }}/${{needs.job_check.outputs.passwall2_version}}/total?style=flat-square)" >> release.txt
echo "### Passwall2 Info" >> release.txt
echo "**:minidisc: Passwall2 Version: ${{needs.job_check.outputs.passwall2_version}}**" >> release.txt
echo "### Packages Version" >> release.txt
echo "**package name**|**package version**" >> release.txt
echo "-|-" >> release.txt
pkgs=$(ls feeds/passwall_packages -I v2ray-geodata)
for pkg in $pkgs; do
version=$(awk -F ':=' '/PKG_VERSION:=/{print $2}' feeds/passwall_packages/$pkg/Makefile | sed 's/\r//g')
[ -z "${version}" ] && version=$(awk -F ':=' '/PKG_SOURCE_DATE:=/{print $2}' feeds/passwall_packages/$pkg/Makefile | sed 's/\r//g')
echo "**:ice_cube: $pkg**|**${version}**" >> release.txt
done
echo "**:ice_cube: v2ray-geoip**|**$(awk -F ':=' '/GEOIP_VER:=/{print $2}' feeds/passwall_packages/v2ray-geodata/Makefile)**" >> release.txt
echo "**:ice_cube: v2ray-geosite**|**$(awk -F ':=' '/GEOSITE_VER:=/{print $2}' feeds/passwall_packages/v2ray-geodata/Makefile)**" >> release.txt
touch release.txt
echo "status=success" >> $GITHUB_OUTPUT
- name: Upload firmware to release
uses: softprops/action-gh-release@master
if: steps.info.outputs.status == 'success'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{needs.job_check.outputs.passwall2_version}}
body_path: ${{ env.FIRMWARE }}/release.txt
files: ${{ env.FIRMWARE }}/upload/*