Skip to content

Build and Release OpenClash Lite IPK #15

Build and Release OpenClash Lite IPK

Build and Release OpenClash Lite IPK #15

Workflow file for this run

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: Update and install feeds
run: |
cd openwrt-sdk
./scripts/feeds update -a
./scripts/feeds install -a
- name: Get Dev Version
id: get_dev_version
run: |
cd Openclash\ dev/luci-app-openclash
echo "dev_version=$(grep 'PKG_VERSION:=' Makefile | awk -F '=' '{print $2}' | tr -d ' ')" >> $GITHUB_OUTPUT
- 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) || echo "BUILD_FAILED=true" >> $GITHUB_ENV
if [ "${{ env.BUILD_FAILED }}" != "true" ]; then
mv bin/packages/x86_64/base/luci-app-openclash*.ipk ../openclash-lite-beta-dev-${{ steps.get_dev_version.outputs.dev_version }}.ipk
fi
- name: Get Stable Version
id: get_stable_version
run: |
cd Openclash\ stable/luci-app-openclash
echo "stable_version=$(grep 'PKG_VERSION:=' Makefile | awk -F '=' '{print $2}' | tr -d ' ')" >> $GITHUB_OUTPUT
- 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) || echo "BUILD_FAILED=true" >> $GITHUB_ENV
if [ "${{ env.BUILD_FAILED }}" != "true" ]; then
mv bin/packages/x86_64/base/luci-app-openclash*.ipk ../openclash-lite-beta-stable-${{ steps.get_stable_version.outputs.stable_version }}.ipk
fi
- name: Check Existing Release
id: check_release
run: |
if [ -n "${{ steps.get_dev_version.outputs.dev_version }}" ]; then
dev_exists=$(curl -s -o /dev/null -w "%{http_code}" https://github.com/${{ github.repository }}/releases/download/${{ github.ref_name }}/openclash-lite-beta-dev-${{ steps.get_dev_version.outputs.dev_version }}.ipk)
echo "dev_exists=${dev_exists}" >> $GITHUB_OUTPUT
else
echo "dev_exists=404" >> $GITHUB_OUTPUT
fi
if [ -n "${{ steps.get_stable_version.outputs.stable_version }}" ]; then
stable_exists=$(curl -s -o /dev/null -w "%{http_code}" https://github.com/${{ github.repository }}/releases/download/${{ github.ref_name }}/openclash-lite-beta-stable-${{ steps.get_stable_version.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_name }}
release_name: Release ${{ github.ref_name }}
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.get_dev_version.outputs.dev_version }}.ipk
asset_name: openclash-lite-beta-dev-${{ steps.get_dev_version.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.get_stable_version.outputs.stable_version }}.ipk
asset_name: openclash-lite-beta-stable-${{ steps.get_stable_version.outputs.stable_version }}.ipk
asset_content_type: application/octet-stream