Skip to content

0.47.112

0.47.112 #439

name: Compile The New Version OpenClash
on:
push:
branches:
- dev
paths:
- 'luci-app-openclash/Makefile'
workflow_dispatch:
jobs:
Get-Version:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
current_version: ${{ steps.current_version.outputs.version }}
steps:
- name: Clone Repository
uses: actions/checkout@v6
with:
ref: ${{ github.ref_name }}
- name: New Version
id: version
run: |
echo "version=$(grep 'PKG_VERSION:=' ./luci-app-openclash/Makefile |awk -F '=' '{print $2}')" >> $GITHUB_OUTPUT
- name: Clone Repository
uses: actions/checkout@v6
with:
ref: package
- name: Current Version
id: current_version
run: |
echo "version=$(sed -n 1p ./${{ github.ref_name }}/version |awk -F 'v' '{print $2}')" >> $GITHUB_OUTPUT
Compile:
runs-on: ubuntu-latest
needs: Get-Version
if: ${{ needs.Get-Version.outputs.version != needs.Get-Version.outputs.current_version }}
strategy:
matrix:
target:
- { name: ipk, sdk_url: "https://mirrors.pku.edu.cn/openwrt/releases/22.03.0/targets/x86/64/openwrt-sdk-22.03.0-x86-64_gcc-11.2.0_musl.Linux-x86_64.tar.xz", sdk_tar: "SDK.tar.xz", sdk_backup_tar: "SDK.tar.bz2", sdk_dir: "SDK", artifact_pattern: "luci-app-openclash_*.ipk" }
- { name: apk, sdk_url: "snapshot", sdk_tar: "SNAPSDK.tar.zst", sdk_backup_tar: "SNAPSDK.tar.zst", sdk_dir: "SNAPSDK", artifact_pattern: "luci-app-openclash-*.apk" }
steps:
- name: Checkout OpenClash Source
uses: actions/checkout@v6
with:
ref: ${{ github.ref_name }}
- name: Install Dependencies
env:
DEBIAN_FRONTEND: noninteractive
run: |
sudo apt-get update
sudo apt-get -y install curl git tar zstd python3 python3-pyelftools python3-setuptools
- name: Download SDK
run: |
mkdir -p tmp
if [ "${{ matrix.target.name }}" = "ipk" ]; then
if ! curl -SLk --connect-timeout 30 --retry 2 "${{ matrix.target.sdk_url }}" -o "./tmp/${{ matrix.target.sdk_tar }}"; then
curl -SLk --connect-timeout 30 --retry 2 "https://archive.openwrt.org/chaos_calmer/15.05.1/ar71xx/generic/OpenWrt-SDK-15.05.1-ar71xx-generic_gcc-4.8-linaro_uClibc-0.9.33.2.Linux-x86_64.tar.bz2" -o "./tmp/SDK.tar.xz"
cd tmp
tar xjf ${{ matrix.target.sdk_backup_tar }}
mv OpenWrt-SDK-* ${{ matrix.target.sdk_dir }}
else
cd tmp
tar xf ${{ matrix.target.sdk_tar }}
mv openwrt-sdk-* ${{ matrix.target.sdk_dir }}
fi
else
BASE_URL="https://downloads.openwrt.org/snapshots/targets/x86/64/"
SDK_NAME=$(curl -s $BASE_URL | grep -oE 'openwrt-sdk-x86-64[^"]+\.tar\.zst' | head -n 1)
if ! curl -SLk --connect-timeout 30 --retry 2 "$BASE_URL/$SDK_NAME" -o "./tmp/${{ matrix.target.sdk_tar }}"; then
BASE_URL2="https://mirrors.pku.edu.cn/files/openwrt/snapshots/targets/x86/64/"
SDK_NAME=$(curl -s $BASE_URL2 | grep -oE 'openwrt-sdk-x86-64[^"]+\.tar\.zst' | head -n 1)
curl -SLk --connect-timeout 30 --retry 2 "$BASE_URL2/$SDK_NAME" -o "./tmp/${{ matrix.target.sdk_tar }}"
fi
cd tmp
zstd -d ${{ matrix.target.sdk_tar }}
tar xf SNAPSDK.tar
SDK_DIR=$(tar tf SNAPSDK.tar | head -n 1 | cut -d/ -f1)
mv "$SDK_DIR" "${{ matrix.target.sdk_dir }}"
fi
- name: Copy OpenClash Source Codes
run: |
mkdir -p tmp/${{ matrix.target.sdk_dir }}/package/luci-app-openclash
cp -rf ./luci-app-openclash/. tmp/${{ matrix.target.sdk_dir }}/package/luci-app-openclash/
if [ "${{ matrix.target.name }}" = "apk" ]; then
find tmp/${{ matrix.target.sdk_dir }}/package/luci-app-openclash -type f -name "Makefile" -exec sed -i 's/DEPENDS:=+dnsmasq-full/DEPENDS:=+dnsmasq-full +luci-compat/g' {} \;
fi
- name: Update Third-Party Resources
run: |
CHNR_PATH=tmp/${{ matrix.target.sdk_dir }}/package/luci-app-openclash/root/etc/openclash/china_ip_route.ipset
CHNR6_PATH=tmp/${{ matrix.target.sdk_dir }}/package/luci-app-openclash/root/etc/openclash/china_ip6_route.ipset
ZASHBOARD_PATH=tmp/${{ matrix.target.sdk_dir }}/package/luci-app-openclash/root/usr/share/openclash/ui/zashboard
METACUBEXD_PATH=tmp/${{ matrix.target.sdk_dir }}/package/luci-app-openclash/root/usr/share/openclash/ui/metacubexd
GEOSITE_PATH=tmp/${{ matrix.target.sdk_dir }}/package/luci-app-openclash/root/etc/openclash/GeoSite.dat
COUNTRY_MMDB_PATH=tmp/${{ matrix.target.sdk_dir }}/package/luci-app-openclash/root/etc/openclash/Country.mmdb
# 更新 China IP Route
mkdir -p tmp
curl -sSL https://ispip.clang.cn/all_cn.txt -o tmp/china_ip_route.ipset
mkdir -p $(dirname $CHNR_PATH)
cp tmp/china_ip_route.ipset $CHNR_PATH
curl -sSL https://ispip.clang.cn/all_cn_ipv6.txt -o tmp/china_ip6_route.ipset
mkdir -p $(dirname $CHNR6_PATH)
cp tmp/china_ip6_route.ipset $CHNR6_PATH
# 更新 MetaCubeXD UI
mkdir -p tmp/metacubexd_zip
curl -sSL https://github.com/MetaCubeX/metacubexd/archive/refs/heads/gh-pages.zip -o tmp/metacubexd.zip
unzip -q -o tmp/metacubexd.zip -d tmp/metacubexd_zip
METACUBEXD_UNZIP_PATH="tmp/metacubexd_zip/metacubexd-gh-pages"
mkdir -p "$METACUBEXD_PATH"
rm -rf "$METACUBEXD_PATH"/*
cp -rf "$METACUBEXD_UNZIP_PATH"/* "$METACUBEXD_PATH"
# 更新 ZashBoard UI
mkdir -p tmp/zashboard_zip
curl -sSL https://github.com/Zephyruso/zashboard/releases/latest/download/dist-cdn-fonts.zip -o tmp/zashboard.zip
unzip -q -o tmp/zashboard.zip -d tmp/zashboard_zip
mkdir -p "$ZASHBOARD_PATH"
rm -rf "$ZASHBOARD_PATH"/*
cp -rf tmp/zashboard_zip/dist/* "$ZASHBOARD_PATH"
# 更新 GeoSite.dat
RULES_RELEASE=$(curl -s https://api.github.com/repos/Loyalsoldier/v2ray-rules-dat/releases/latest | jq -r '.tag_name')
curl -sSL "https://github.com/Loyalsoldier/v2ray-rules-dat/releases/download/${RULES_RELEASE}/geosite.dat" -o tmp/GeoSite.dat
mkdir -p $(dirname "$GEOSITE_PATH")
cp tmp/GeoSite.dat "$GEOSITE_PATH"
# 更新 Country.mmdb
curl -sSL "https://github.com/alecthw/mmdb_china_ip_list/releases/latest/download/Country-lite.mmdb" -o tmp/Country.mmdb
mkdir -p $(dirname "$COUNTRY_MMDB_PATH")
cp tmp/Country.mmdb "$COUNTRY_MMDB_PATH"
- uses: actions/setup-node@v4
with:
node-version: '20'
- name: Minify CSS (lightningcss)
run: |
CSS_PATH="tmp/${{ matrix.target.sdk_dir }}/package/luci-app-openclash/root/www/luci-static/resources/openclash/css/oc.css"
SIZE_BEFORE=$(wc -c < "$CSS_PATH")
npx --yes --package lightningcss-cli lightningcss --minify --targets 'iOS >= 12, safari >= 12, android >= 4.4' "$CSS_PATH" -o "$CSS_PATH.tmp"
mv "$CSS_PATH.tmp" "$CSS_PATH"
SIZE_AFTER=$(wc -c < "$CSS_PATH")
echo "CSS minified: ${SIZE_BEFORE} -> ${SIZE_AFTER} bytes ($(( 100 - SIZE_AFTER * 100 / SIZE_BEFORE ))% reduction)"
- name: Compile po2lmo
run: |
cd tmp/${{ matrix.target.sdk_dir }}/package/luci-app-openclash/tools/po2lmo
make && sudo make install
- name: Compile OpenClash
run: |
cd tmp/${{ matrix.target.sdk_dir }}
if [ -f ../${{ matrix.target.sdk_tar }} ]; then
make defconfig
fi
make package/luci-app-openclash/compile V=99
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: openclash-${{ matrix.target.name }}
path: tmp/${{ matrix.target.sdk_dir }}/bin/packages/x86_64/base/${{ matrix.target.artifact_pattern }}
Post-Process:
runs-on: ubuntu-latest
needs: [Compile, Get-Version]
steps:
- name: Checkout package branch
uses: actions/checkout@v6
with:
ref: package
- name: Download IPK Artifact
uses: actions/download-artifact@v4
with:
name: openclash-ipk
path: ./
- name: Download APK Artifact
uses: actions/download-artifact@v4
with:
name: openclash-apk
path: ./
- name: Commit and Push New Version
run: |
rm -rf ./${{ github.ref_name }}/luci-app-openclash*
echo "v${{ needs.Get-Version.outputs.version }}" > ./${{ github.ref_name }}/version
echo "https://img.shields.io/badge/New Release-v${{ needs.Get-Version.outputs.version }}-orange.svg" >> ./${{ github.ref_name }}/version
cp ./luci-app-openclash_*.ipk "./${{ github.ref_name }}/"
cp ./luci-app-openclash-*.apk "./${{ github.ref_name }}/"
rm -f ./luci-app-openclash_*.ipk
rm -f ./luci-app-openclash-*.apk
git config user.name 'github-actions[bot]'
git config user.email 'github-actions[bot]@users.noreply.github.com'
git add .
git commit -m "Auto Release: v${{ needs.Get-Version.outputs.version }}"
git push