-
Notifications
You must be signed in to change notification settings - Fork 39
288 lines (255 loc) · 13.8 KB
/
run.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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
name: Generate shadowrocket rules
on:
workflow_dispatch:
schedule:
- cron: "0 0 * * *"
push:
branches:
- main
jobs:
build_rules_list:
runs-on: ubuntu-latest
steps:
- name: Создаем файл domains_community.list
run: |
# curl -sSL https://raw.githubusercontent.com/misha-tgshv/shadowrocket-configuration-file/main/community.list \
# | sed -E '/^[^#].*./s/^/DOMAIN-SUFFIX,/' > domains_community.list
# sed -i "1s/^/#special\n/" domain_community.list
# sed -i "2s/^/DOMAIN-KEYWORD,instagram\n/" domain_community.list
# sed -i "3s/^/DOMAIN-KEYWORD,4pda\n/" domain_community.list
# sed -i "4s/^/DOMAIN,spotify.com\n/" domain_community.list
curl -s https://raw.githubusercontent.com/misha-tgshv/shadowrocket-configuration-file/main/community.list \
| awk '
NR==2 {print "DOMAIN-KEYWORD," $0; next}
NR==3 {print "DOMAIN-KEYWORD," $0; next}
NR==4 {print "DOMAIN," $0; next}
!/^#/ && NF>0 {print "DOMAIN-SUFFIX," $0}
/^#/ || NF==0 {print $0} # Добавляем это условие для пустых строк и строк с #
' > domains_community.list
- name: Создаем файл domains_antifilter.list
run: |
# curl -sSL https://community.antifilter.download/list/domains.lst \
# | sed -E 's/^\+\./DOMAIN-SUFFIX,/; s/^[^D]/DOMAIN-SUFFIX,&/' > domains_antifilter.list
# sed -i -E '/www|DOMAIN-SUFFIX,spotify.com/d' domains_antifilter.list
# awk '!seen[$0]++' domains_antifilter.list
curl -sSL https://community.antifilter.download/list/domains.lst \
| sed -E 's/^\+\./DOMAIN-SUFFIX,/; s/^[^D]/DOMAIN-SUFFIX,&/' \
| sed '/www|spotify.com/d' \
| awk '!seen[$0]++' > temp_list.txt \
&& echo "# Количество доменов: $(wc -l < temp_list.txt)" > domains_antifilter.list \
&& cat temp_list.txt >> domains_antifilter.list \
&& rm temp_list.txt
- name: Создаем файл ips_antifilter.list
run: |
curl -s https://community.antifilter.download/list/community.lst \
| sed 's/^/IP-CIDR,/g' \
| sort -u > temp_aips.txt \
&& echo "# Количество IP-адресов: $(wc -l < temp_aips.txt)" > ips_antifilter.list \
&& cat temp_aips.txt >> ips_antifilter.list \
&& rm temp_aips.txt
- name: Создаем файл domains_refilter.list
run: |
# curl -s https://raw.githubusercontent.com/1andrevich/Re-filter-lists/main/domains_all.lst > domains1.txt \
# && curl -s https://raw.githubusercontent.com/1andrevich/Re-filter-lists/main/community.lst >> domains1.txt \
# && sed 's/^www\.//; s/^/DOMAIN-SUFFIX,/g; /ww.*ww/d' domains1.txt | sort -u > temp_refilter.list \
# && echo "# Количество доменов в списке: $(wc -l < temp_refilter.list)" > domains_refilter.list \
# && cat temp_refilter.list >> domains_refilter.list \
# && rm domains1.txt temp_refilter.list
# curl -s https://raw.githubusercontent.com/1andrevich/Re-filter-lists/main/domains_all.lst > domains1.txt \
# && curl -s https://raw.githubusercontent.com/1andrevich/Re-filter-lists/main/community.lst >> domains1.txt \
# && sed '
# s/^/DOMAIN-SUFFIX,/g;
# /http\|https/d;
# /[wW]\{3,\}[[:alnum:]]*/d;
# /vvv\|vvvv\|vwv\|vwvv\|vwvw\|vww\|vwwv/d
# ' domains1.txt | sort -u > temp_refilter.list \
# && echo "# Количество доменов в списке: $(wc -l < temp_refilter.list)" > domains_refilter.list \
# && cat temp_refilter.list >> domains_refilter.list \
# && rm domains1.txt temp_refilter.list
curl -s https://raw.githubusercontent.com/1andrevich/Re-filter-lists/main/community.lst > temp.txt && curl -s https://raw.githubusercontent.com/1andrevich/Re-filter-lists/main/domains_all.lst >> temp.txt && sed 's/^/DOMAIN-SUFFIX,/g' temp.txt | split -l 1000 - domains_file_ && for i in domains_file_*; do mv "$i" "${i/_/.}.txt"; done && rm temp.txt
- name: Создаем файл domains_youtube.list
run: |
curl -sSL https://raw.githubusercontent.com/dsvip/Quantumult-X/dec9019816ba55897c162c3dbd3ac997ac160f09/blackmatrix7/rule/Shadowrocket/YouTube.list \
| sed -n '/DOMAIN-SUFFIX,/p' > domains_youtube.list
sed -i "1s/^/DOMAIN-KEYWORD,youtube\n/" domains_youtube.list
sed -i "1s/^/DOMAIN-KEYWORD,googlevideo\n/" domains_youtube.list
- name: Создаем файл domains_discord.list
run: |
curl -sSL https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/refs/heads/master/rule/Shadowrocket/Discord/Discord.list \
| sed -n '/DOMAIN-SUFFIX,/p' > domains_discord.list
sed -i "1s/^/DOMAIN-KEYWORD,discord\n/" domains_discord.list
sed -i "1s/^/DOMAIN-KEYWORD,discordapp\n/" domains_discord.list
- name: Создаем файл ips_refilter.list
run: |
# curl -sSL https://raw.githubusercontent.com/1andrevich/Re-filter-lists/refs/heads/main/ipsum.lst | sed 's/^/IP-CIDR,/' > ip_refilter.list
curl -s https://raw.githubusercontent.com/1andrevich/Re-filter-lists/refs/heads/main/community_ips.lst > ips1.txt \
&& curl -s https://raw.githubusercontent.com/1andrevich/Re-filter-lists/refs/heads/main/discord_ips.lst >> ips1.txt \
&& curl -s https://raw.githubusercontent.com/1andrevich/Re-filter-lists/refs/heads/main/ipsum.lst >> ips1.txt \
&& sed 's/^/IP-CIDR,/g' ips1.txt | sort -u > temp_ips.list \
&& echo "# Количество IP-адресов: $(wc -l < temp_ips.list)" > ips_refilter.list \
&& cat temp_ips.list >> ips_refilter.list \
&& rm ips1.txt temp_ips.list
- name: Перемещаем файлы в директорю rules
run: |
mkdir -p rules.d
cp *.list ./rules.d/
- name: Загружаем список файлов rules через artifact
uses: actions/upload-artifact@v4
with:
name: rules
path: ./rules.d/
build_scripts_js:
runs-on: ubuntu-latest
steps:
- name: Создаем файл rewrite.youtube.response.preview.js
run: |
curl -sSL "https://raw.githubusercontent.com/Maasea/sgmodule/master/Script/Youtube/dist/youtube.response.preview.js" > temp.txt && sed 's/;e!/;e/g' temp.txt > rewrite.youtube.response.preview.js && rm temp.txt
- name: Перемещаем файлы в директорю scripts
run: |
mkdir -p scripts.d
cp *.js ./scripts.d/
- name: Загружаем список файлов sctipts через artifact
uses: actions/upload-artifact@v4
with:
name: scripts
path: ./scripts.d/
build_YT_premium_v1_module:
runs-on: ubuntu-latest
steps:
- name: Создаем файл YT-Premium-V1-RU.module
run: |
curl -sSL https://raw.githubusercontent.com/YanbingJiang/Shadowrocket_diy_rules/9b86dfbca387fa69e8d4b02d3f8ba01250eaad16/Modules/YT-Premium-V1.module \
| sed -E 's/captionLang:zh-Hans/captionLang:off/g; s/lyricLang:zh-Hans/lyricLang:ru-ru/g' > YT-Premium-V1-RU.module
sed -i 's/https:\/\/raw\.githubusercontent\.com\/Maasea\/sgmodule\/master\/Script\/Youtube\/dist\/youtube\.response\.preview\.js/https:\/\/raw\.githubusercontent\.com\/misha-tgshv\/shadowrocket-configuration-file\/refs\/heads\/release\/scripts\/rewrite\.youtube\.response\.preview\.js/g' YT-Premium-V1-RU.module
- name: Перемещаем файлы в директорю modules
run: |
mkdir -p modules.d
cp *.module ./modules.d/
- name: Загружаем список файлов modules через artifact
uses: actions/upload-artifact@v4
with:
name: modules
path: ./modules.d/
build_Shadowrocket_conf_file:
runs-on: ubuntu-latest
needs: build_rules_list
steps:
- name: Создаем папку
run: |
mkdir -p conf.d
- name: Получаем шаблон файла General
uses: actions/checkout@v4
with:
repository: ${{ github.repository }}
ref: 'Custom'
token: ${{ secrets.ACCESS_TOKEN }}
sparse-checkout: |
General.txt
sparse-checkout-cone-mode: false
path: conf.d
- name: Добавляем списки правил в конец файла General
run: |
cat <<EOF >> ./conf.d/General.txt
# Выборочные правила маршрутизации
[Rule]
# Список доменов телеграм-чата «Про Shadowrocket на русском»
RULE-SET,https://raw.githubusercontent.com/misha-tgshv/shadowrocket-configuration-file/refs/heads/release/rules/domains_community.list,PROXY
# Список доменов antifilter
RULE-SET,https://raw.githubusercontent.com/misha-tgshv/shadowrocket-configuration-file/refs/heads/release/rules/domains_antifilter.list,PROXY
# Список доменов refilter
# RULE-SET,https://raw.githubusercontent.com/misha-tgshv/shadowrocket-configuration-file/refs/heads/release/rules/domains_refilter.list,PROXY
# Список ip-адресов antifilter
# RULE-SET,https://raw.githubusercontent.com/misha-tgshv/shadowrocket-configuration-file/refs/heads/release/rules/ips_antifilter.list,PROXY
# Список ip-адресов refilter
RULE-SET,https://raw.githubusercontent.com/misha-tgshv/shadowrocket-configuration-file/refs/heads/release/rules/ips_refilter.list,PROXY,no-resolve
# Список доменов Youtube
RULE-SET,https://raw.githubusercontent.com/misha-tgshv/shadowrocket-configuration-file/refs/heads/release/rules/domains_youtube.list,PROXY
# Список доменов Discord
RULE-SET,https://raw.githubusercontent.com/misha-tgshv/shadowrocket-configuration-file/refs/heads/release/rules/domains_discord.list,PROXY
# Список портов Discord
RULE-SET,https://raw.githubusercontent.com/helmiau/clashrules/refs/heads/main/shadowrocket/Game_Discord_Ports.list,PROXY
# Финальное правило маршрутизации
FINAL,DIRECT
EOF
# - name: Generate HTTPS decrypted configuration file
# run: |
# sed -i 's/hostname = /hostname = *instagram.com,/' MITM.txt
# cp MITM.txt ./conf.d
- name: Создаем конфиг sr_ru_public_lists.conf
run: |
cat ./conf.d/*.txt > ./conf.d/sr_ru_public_lists.conf
sed -i "1s/^/# @misha-tgshv, built on $(TZ="Asia/Novokuznetsk" date)\n/" ./conf.d/sr_ru_public_lists.conf
- name: Загружаем artifact
uses: actions/upload-artifact@v4
with:
name: conf
path: ./conf.d/sr_ru_public_lists.conf
retention-days: 1
publish:
runs-on: ubuntu-latest
needs: [build_rules_list,build_scripts_js,build_YT_premium_v1_module,build_Shadowrocket_conf_file]
steps:
- name: Настраиваем переменные
run: |
echo "RELEASE_NAME=Built on $(TZ="Asia/Novokuznetsk" date +%Y%m%d%H%M)" >> $GITHUB_ENV
echo "TAG_NAME=$(TZ="Asia/Novokuznetsk" date +%Y%m%d%H%M)" >> $GITHUB_ENV
mkdir -p rules
- name: Скачиваем artifact
uses: actions/download-artifact@v4
with:
path: ./rules
- name: Публикуем и загружаем artifacts
uses: softprops/action-gh-release@v2
with:
name: ${{ env.RELEASE_NAME }}
tag_name: ${{ env.TAG_NAME }}
draft: false
prerelease: false
files: |
./rules/*
env:
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}
- name: Загружаем artifact в ветку "release"
run: |
cd rules || exit 1
git init
git config --local user.name ${{ secrets.USER_NAME }}
git config --local user.email ${{ secrets.USER_EMAIL }}
git checkout -b release
git add .
git commit -m "${{ env.RELEASE_NAME }}"
git remote add origin "https://${{ github.actor }}:${{ secrets.ACCESS_TOKEN }}@github.com/${{ github.repository }}"
git push -f origin release
# git push --delete origin $( git ls-remote --tags origin | awk '{print $2}' | grep -vE "$(echo -e ${TAG_NAME})")
- name: Очищаем jsdelivr CDN
run: |
cd rules || exit 1
for file in $(ls); do
curl -i "https://purge.jsdelivr.net/gh/${{ github.repository }}@release/${file}"
done
Delete_Historical_Data:
runs-on: ubuntu-latest
needs: publish
steps:
- name: Delete old artifacts
uses: geekyeggo/delete-artifact@v5
with:
name: |
rules
modules
conf
- name: Удаляем старые теги и релизы
uses: dev-drprasad/delete-older-releases@v0.3.4
with:
keep_latest: 3
delete_expired_data: 7
delete_tags: true
env:
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}
- name: Удаляем старый workflow
uses: Mattraks/delete-workflow-runs@v2
with:
token: ${{ secrets.ACCESS_TOKEN }}
repository: ${{ github.repository }}
retain_days: 7
keep_minimum_runs: 3