-
Notifications
You must be signed in to change notification settings - Fork 594
80 lines (70 loc) · 2.5 KB
/
oc.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
name: Build OpenClash Installer
on:
push:
branches:
- main
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
# Step 1: Clone makeself repository
- name: Clone makeself repository
run: git clone https://github.com/megastep/makeself.git
# Step 2: Create openclash directory and download the latest OpenClash IPK
- name: Create openclash directory
run: mkdir openclash
- name: Download latest OpenClash IPK
run: |
curl -LO $(curl -s https://api.github.com/repos/vernesong/OpenClash/releases/latest \
| grep -oP '"browser_download_url":\s*".*\.ipk"' \
| cut -d '"' -f 4)
mv *.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