-
Notifications
You must be signed in to change notification settings - Fork 639
134 lines (109 loc) · 5.8 KB
/
mosdns.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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
#=================================================
# https://github.com/wukongdaily/RunFilesBuilder
# Description: Build RunFiles using GitHub Actions
# Lisence: MIT
# Author: wukongdaily
# Blog: wkdaily.cpolar.top
#=================================================
name: Make MosDNS run files
on:
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-22.04
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Fetch latest release tag from mosdns
id: fetch_latest_tag
run: |
latest_tag=$(curl -sk https://api.github.com/repos/sbwml/luci-app-mosdns/releases | grep "tag_name" | grep v5 | head -n 1 | awk -F ":" '{print $2}' | sed 's/\"//g;s/,//;s/ //')
echo "LATEST_TAG=$latest_tag" >> $GITHUB_ENV
- name: Clone makeself repository
run: git clone https://github.com/megastep/makeself.git
- name: Download latest mosdns files
run: |
echo "Downloading MosDNS IPK files..."
# 获取下载链接
curl -sk --connect-timeout 10 "https://api.github.com/repos/sbwml/luci-app-mosdns/releases" | grep "browser_download_url" | grep "$latest_tag" > releases.txt
if [ $? -ne 0 ]; then
echo "Failed to get version information, please check the network status."
exit 1
fi
# 创建存放目录
mkdir -p mosdns_x86_64 mosdns_aarch64_cortex-a53
# 下载文件函数
download_file() {
local url=$1
local output_dir=$2
local filename=$(basename "$url")
echo "Downloading $filename to $output_dir..."
curl --connect-timeout 30 -m 600 -kLo "$output_dir/$filename" "$url"
if [ $? -ne 0 ]; then
echo "Error! Download $filename failed."
exit 1
fi
}
# 提取下载链接
mosdns_x86_64=$(grep "browser_download_url" releases.txt | grep "mosdns_5" | grep "x86_64.ipk" | head -1 | awk -F '"' '{print $4}')
mosdns_aarch64_cortex_a53=$(grep "browser_download_url" releases.txt | grep "mosdns_5" | grep "aarch64_cortex-a53.ipk" | head -1 | awk -F '"' '{print $4}')
v2dat_x86_64=$(grep "browser_download_url" releases.txt | grep "v2dat_" | grep "x86_64.ipk" | head -1 | awk -F '"' '{print $4}')
v2dat_aarch64_cortex_a53=$(grep "browser_download_url" releases.txt | grep "v2dat_" | grep "aarch64_cortex-a53.ipk" | head -1 | awk -F '"' '{print $4}')
luci_app=$(grep "browser_download_url" releases.txt | grep "luci-app-mosdns_" | head -1 | awk -F '"' '{print $4}')
luci_i18n=$(grep "browser_download_url" releases.txt | grep "luci-i18n-mosdns-zh-cn" | head -1 | awk -F '"' '{print $4}')
geoip=$(grep "browser_download_url" releases.txt | grep "v2ray-geoip" | head -1 | awk -F '"' '{print $4}')
geosite=$(grep "browser_download_url" releases.txt | grep "v2ray-geosite" | head -1 | awk -F '"' '{print $4}')
# 下载文件到对应目录
download_file "$mosdns_x86_64" "mosdns_x86_64"
download_file "$mosdns_aarch64_cortex_a53" "mosdns_aarch64_cortex-a53"
download_file "$v2dat_x86_64" "mosdns_x86_64"
download_file "$v2dat_aarch64_cortex_a53" "mosdns_aarch64_cortex-a53"
download_file "$luci_app" "mosdns_x86_64"
download_file "$luci_app" "mosdns_aarch64_cortex-a53"
download_file "$luci_i18n" "mosdns_x86_64"
download_file "$luci_i18n" "mosdns_aarch64_cortex-a53"
download_file "$geoip" "mosdns_x86_64"
download_file "$geoip" "mosdns_aarch64_cortex-a53"
download_file "$geosite" "mosdns_x86_64"
download_file "$geosite" "mosdns_aarch64_cortex-a53"
echo "Download completed."
- name: Create install.sh scripts
run: |
cat <<EOF > mosdns_x86_64/install.sh
#!/bin/sh
opkg update
if [ $? -ne 0 ]; then
echo "update failed。"
exit 1
fi
opkg install *.ipk
EOF
chmod +x mosdns_x86_64/install.sh
cp mosdns_x86_64/install.sh mosdns_aarch64_cortex-a53/install.sh
- name: Move mosdns directories to makeself
run: |
mv mosdns_x86_64 makeself/
mv mosdns_aarch64_cortex-a53 makeself/
- name: Create self-extracting packages
run: |
cd makeself
./makeself.sh mosdns_x86_64/ mosdns_${{ env.LATEST_TAG }}_x86_64.run "by github action" ./install.sh
./makeself.sh mosdns_aarch64_cortex-a53/ mosdns_${{ env.LATEST_TAG }}_aarch64_cortex-a53.run "by github action" ./install.sh
- name: Check file sizes
run: |
ls -lh makeself/mosdns_*.run
- name: Fetch latest release details
id: fetch_release_details
run: |
extra_content=" [](https://wkdaily.cpolar.top/archives/1) "
sed -i "1i$extra_content" "${{ github.workspace }}/common.md"
- name: Upload run files as release assets
uses: softprops/[email protected]
with:
tag_name: ${{ env.LATEST_TAG }}
name: "mosdns-${{ env.LATEST_TAG }}"
files: makeself/mosdns_*.run
body_path: ${{ github.workspace }}/common.md
token: ${{ secrets.GITHUB_TOKEN }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}