forked from wukongdaily/RunFilesBuilder
-
Notifications
You must be signed in to change notification settings - Fork 0
115 lines (94 loc) · 4.4 KB
/
Copy pathmosdns.yml
File metadata and controls
115 lines (94 loc) · 4.4 KB
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
#=================================================
# https://github.com/wukongdaily/RunFilesBuilder
# Description: Build RunFiles using GitHub Actions
# Lisence: MIT
# Author: wukongdaily
# Blog: wkdaily.cpolar.cn
#=================================================
name: Make MosDNS run files
on:
workflow_dispatch:
permissions:
contents: write
jobs:
build:
runs-on: ubuntu-22.04
steps:
- name: Checkout repository
uses: actions/checkout@v7.0.1
- name: Fetch latest release tag from mosdns
id: fetch_latest_tag
run: |
latest_tag=$(curl --fail --silent --show-error --location \
https://api.github.com/repos/sbwml/luci-app-mosdns/releases/latest \
| jq -er '.tag_name // empty')
test -n "$latest_tag"
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 $LATEST_TAG 24.10 archives..."
mkdir -p mosdns_x86_64 mosdns_aarch64_cortex-a53
release_json=$(curl --fail --silent --show-error --location \
"https://api.github.com/repos/sbwml/luci-app-mosdns/releases/tags/${LATEST_TAG}")
download_archive() {
local pattern=$1
local output_dir=$2
local url
local archive
url=$(echo "$release_json" | jq -er --arg pattern "$pattern" \
'.assets[] | select(.name | test($pattern)) | .browser_download_url')
archive="$RUNNER_TEMP/$(basename "$url")"
echo "Downloading $(basename "$url") to $output_dir..."
curl --fail --location --retry 3 -o "$archive" "$url"
tar -xzf "$archive" -C "$output_dir"
test -d "$output_dir/packages_ci"
cp "$output_dir"/packages_ci/*.ipk "$output_dir/"
rm -rf "$output_dir/packages_ci"
}
download_archive '^x86_64-openwrt-24\.10\.tar\.gz$' mosdns_x86_64
download_archive '^aarch64_cortex-a53-openwrt-24\.10\.tar\.gz$' mosdns_aarch64_cortex-a53
test -n "$(find mosdns_x86_64 -maxdepth 1 -name '*.ipk' -print -quit)"
test -n "$(find mosdns_aarch64_cortex-a53 -maxdepth 1 -name '*.ipk' -print -quit)"
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.cn/archives/1) "
sed -i "1i$extra_content" "${{ github.workspace }}/common.md"
- name: Upload run files as release assets
uses: softprops/action-gh-release@v3.0.2
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 }}