Build and Release OpenClash Lite IPK #13
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
name: Build and Release OpenClash Lite IPK | |
on: | |
push: | |
tags: | |
- 'v*' | |
workflow_dispatch: | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup OpenWrt SDK | |
run: | | |
sudo apt update | |
sudo apt install build-essential clang flex bison g++ gawk gcc-multilib g++-multilib gettext git libncurses-dev libssl-dev python3-distutils rsync unzip zlib1g-dev file wget tar -y | |
wget https://downloads.openwrt.org/releases/23.05.5/targets/x86/64/openwrt-sdk-23.05.5-x86-64_gcc-12.3.0_musl.Linux-x86_64.tar.xz | |
tar xJf openwrt-sdk-23.05.5-x86-64_gcc-12.3.0_musl.Linux-x86_64.tar.xz | |
mv openwrt-sdk-23.05.5-x86-64_gcc-12.3.0_musl.Linux-x86_64 openwrt-sdk | |
- name: Verify system dependencies | |
run: | | |
missing_pkgs=() | |
for pkg in build-essential clang flex bison g++ gawk gcc-multilib g++-multilib gettext git libncurses-dev libssl-dev python3-distutils rsync unzip zlib1g-dev file wget tar; do | |
if ! dpkg -s $pkg >/dev/null 2>&1; then | |
missing_pkgs+=($pkg) | |
fi | |
done | |
if [ ${#missing_pkgs[@]} -ne 0 ]; then | |
echo "Missing packages: ${missing_pkgs[*]}" | |
exit 1 | |
fi | |
echo "All required packages are installed." | |
- name: Update and install feeds | |
run: | | |
cd openwrt-sdk | |
for i in 1 2 3; do | |
./scripts/feeds update -a && break || { echo "Feed update failed, retrying..."; sleep 10; } | |
done | |
for i in 1 2 3; do | |
./scripts/feeds install -a && break || { echo "Feed install failed, retrying..."; sleep 10; } | |
done | |
- name: Prepare Dev OpenClash | |
run: | | |
cd openwrt-sdk | |
mkdir -p package/luci-app-openclash | |
cp -R ../Openclash\ dev/luci-app-openclash/* package/luci-app-openclash/ | |
- name: Compile po2lmo | |
run: | | |
cd openwrt-sdk/package/luci-app-openclash/tools/po2lmo | |
make && sudo make install | |
- name: Build Dev OpenClash | |
id: build_dev | |
run: | | |
cd openwrt-sdk && make defconfig | |
make package/luci-app-openclash/compile V=s -j$(nproc) 2>&1 | tee /tmp/openwrt-build.log || echo "BUILD_FAILED=true" >> $GITHUB_ENV | |
if [ "${{ env.BUILD_FAILED }}" != "true" ]; then | |
version=$(grep "PKG_VERSION" package/luci-app-openclash/Makefile | cut -d '=' -f 2 | tr -d ' ') | |
mv bin/packages/x86_64/base/luci-app-openclash*.ipk ../openclash-lite-beta-dev-${version}.ipk | |
echo "dev_version=${version}" >> $GITHUB_OUTPUT | |
fi | |
- name: Prepare Stable OpenClash | |
run: | | |
cd openwrt-sdk | |
make package/luci-app-openclash/clean V=s -j$(nproc) | |
rm -rf package/luci-app-openclash | |
mkdir -p package/luci-app-openclash | |
cp -R ../Openclash\ stable/luci-app-openclash/* package/luci-app-openclash/ | |
- name: Build Stable OpenClash | |
id: build_stable | |
run: | | |
cd openwrt-sdk | |
make package/luci-app-openclash/compile V=s -j$(nproc) 2>&1 | tee -a /tmp/openwrt-build.log || echo "BUILD_FAILED=true" >> $GITHUB_ENV | |
if [ "${{ env.BUILD_FAILED }}" != "true" ]; then | |
version=$(grep "PKG_VERSION" package/luci-app-openclash/Makefile | cut -d '=' -f 2 | tr -d ' ') | |
mv bin/packages/x86_64/base/luci-app-openclash*.ipk ../openclash-lite-beta-stable-${version}.ipk | |
echo "stable_version=${version}" >> $GITHUB_OUTPUT | |
fi | |
- name: Log compile | |
if: always() | |
run: | | |
if [ -f /tmp/openwrt-build.log ]; then | |
echo "Compilation log summary:" | |
echo "------------------------" | |
echo "First line of the log:" | |
head -n 1 /tmp/openwrt-build.log | |
echo "------------------------" | |
echo "Last 20 lines of the log:" | |
tail -n 20 /tmp/openwrt-build.log | |
echo "------------------------" | |
echo "Searching for error messages:" | |
grep -i "error" /tmp/openwrt-build.log | tail -n 5 | |
echo "------------------------" | |
echo "Total log lines: $(wc -l < /tmp/openwrt-build.log)" | |
else | |
echo "Compilation log file not found." | |
fi | |
- name: Check Existing Release | |
id: check_release | |
run: | | |
if [ -n "${{ steps.build_dev.outputs.dev_version }}" ]; then | |
dev_exists=$(curl -s -o /dev/null -w "%{http_code}" https://github.com/bobbyunknown/OpenClash-lite/releases/download/${{ github.ref_name }}/openclash-lite-beta-dev-${{ steps.build_dev.outputs.dev_version }}.ipk) | |
echo "dev_exists=${dev_exists}" >> $GITHUB_OUTPUT | |
else | |
echo "dev_exists=404" >> $GITHUB_OUTPUT | |
fi | |
if [ -n "${{ steps.build_stable.outputs.stable_version }}" ]; then | |
stable_exists=$(curl -s -o /dev/null -w "%{http_code}" https://github.com/bobbyunknown/OpenClash-lite/releases/download/${{ github.ref_name }}/openclash-lite-beta-stable-${{ steps.build_stable.outputs.stable_version }}.ipk) | |
echo "stable_exists=${stable_exists}" >> $GITHUB_OUTPUT | |
else | |
echo "stable_exists=404" >> $GITHUB_OUTPUT | |
fi | |
- name: Create Release | |
if: env.BUILD_FAILED != 'true' | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ github.ref }} | |
release_name: Release ${{ github.ref }} | |
draft: false | |
prerelease: false | |
- name: Upload Dev IPK | |
if: env.BUILD_FAILED != 'true' && steps.check_release.outputs.dev_exists != '200' | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./openclash-lite-beta-dev-${{ steps.build_dev.outputs.dev_version }}.ipk | |
asset_name: openclash-lite-beta-dev-${{ steps.build_dev.outputs.dev_version }}.ipk | |
asset_content_type: application/octet-stream | |
- name: Upload Stable IPK | |
if: env.BUILD_FAILED != 'true' && steps.check_release.outputs.stable_exists != '200' | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./openclash-lite-beta-stable-${{ steps.build_stable.outputs.stable_version }}.ipk | |
asset_name: openclash-lite-beta-stable-${{ steps.build_stable.outputs.stable_version }}.ipk | |
asset_content_type: application/octet-stream |