Update oc.yml #10
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 OpenClash Installer | |
on: | |
push: | |
branches: | |
- master | |
workflow_dispatch: | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
# Step 1: Clone OpenClash repository (replacing download step) | |
- name: Clone OpenClash repository | |
uses: actions/checkout@v4 | |
with: | |
repository: vernesong/OpenClash | |
ref: package | |
- name: Verify Clone Integrity | |
run: | | |
git rev-parse HEAD && echo "Clone successful!" | |
- name: list OpenClash directory | |
run: ls -la | |
# Step 2: Create little openclash directory | |
- name: Create little openclash directory | |
run: mkdir openclash | |
# Step 3: Copy latest IPK file from master | |
- name: Copy latest OpenClash IPK | |
run: cp OpenClash/master/*.ipk openclash/ | |
# Step 3: Download and prepare the latest Mihomo file | |
- name: Download latest Mihomo GZ | |
run: | | |
curl -LO $(curl -s https://api.github.com/repos/MetaCubeX/mihomo/releases/latest \ | |
| grep -oP '"browser_download_url":\s*".*linux-amd64-v.*\.gz"' \ | |
| cut -d '"' -f 4) | |
tar -xzf *.gz | |
mv linux-amd64-v*/clash_meta openclash/ | |
chmod +x openclash/clash_meta | |
# Step 4: Create install.sh script | |
- name: Create install.sh script | |
run: | | |
cat << 'EOF' > openclash/install.sh | |
opkg update | |
if [ $? -ne 0 ]; then | |
echo "update failed。" | |
exit 1 | |
fi | |
opkg install *.ipk || exit 1 | |
mv clash_meta /etc/openclash/core/ | |
sleep 10s | |
ifconfig br-lan > /dev/null 2>&1 | |
if [ $? -ne 0 ]; then | |
echo "接口错误,重启网络。" | |
/etc/init.d/network restart | |
echo "重启完毕" | |
exit 0 | |
fi | |
EOF | |
chmod +x openclash/install.sh | |
# Step 5: Move openclash to makeself directory | |
- name: Move openclash to makeself | |
run: mv openclash makeself/ | |
# Step 6: Create self-extracting installer | |
- name: Create self-extracting installer | |
run: | | |
cd makeself | |
./makeself.sh openclash/ openclash.run "by github action" ./install.sh | |
# Step 7: Upload openclash.run to Release | |
- name: Upload to Release | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ github.event.release.upload_url }} | |
asset_path: makeself/openclash.run | |
asset_name: openclash.run | |
asset_content_type: application/x-sh |