mirror of
https://github.com/MetaCubeX/meta-rules-dat.git
synced 2024-11-10 16:05:42 +08:00
303 lines
17 KiB
YAML
303 lines
17 KiB
YAML
name: Build rules dat files
|
|
on:
|
|
workflow_dispatch:
|
|
schedule:
|
|
- cron: "0 22 * * *"
|
|
push:
|
|
branches:
|
|
- master
|
|
paths-ignore:
|
|
- "**/README.md"
|
|
jobs:
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Setup Go 1.19.6
|
|
uses: actions/setup-go@v3
|
|
with:
|
|
go-version: 1.19.6
|
|
|
|
- name: Set variables
|
|
run: |
|
|
echo "RELEASE_NAME=Released on $(date +%Y%m%d%H%M)" >> $GITHUB_ENV
|
|
echo "TAG_NAME=$(date +%Y%m%d%H%M)" >> $GITHUB_ENV
|
|
echo "CHINA_DOMAINS_URL=https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/rule/Clash/ChinaMax/ChinaMax_Domain.txt" >> $GITHUB_ENV
|
|
echo "GOOGLE_DOMAINS_URL=https://raw.githubusercontent.com/felixonmars/dnsmasq-china-list/master/google.china.conf" >> $GITHUB_ENV
|
|
echo "APPLE_DOMAINS_URL=https://raw.githubusercontent.com/felixonmars/dnsmasq-china-list/master/apple.china.conf" >> $GITHUB_ENV
|
|
# echo "EASYLISTCHINA_EASYLIST_REJECT_URL=https://easylist-downloads.adblockplus.org/easylistchina+easylist.txt" >> $GITHUB_ENV
|
|
# echo "EASYPRIVACY_REJECT_URL=https://easylist-downloads.adblockplus.org/easyprivacy.txt" >> $GITHUB_ENV
|
|
# echo "PETERLOWE_REJECT_URL=https://pgl.yoyo.org/adservers/serverlist.php?hostformat=hosts&showintro=1&mimetype=plaintext" >> $GITHUB_ENV
|
|
# echo "ADGUARD_DNS_REJECT_URL=https://adguardteam.github.io/AdGuardSDNSFilter/Filters/filter.txt" >> $GITHUB_ENV
|
|
# echo "DANPOLLOCK_REJECT_URL=https://someonewhocares.org/hosts/hosts" >> $GITHUB_ENV
|
|
# echo "ANTIAD_DOMAINS_URL=https://raw.githubusercontent.com/privacy-protection-tools/anti-AD/master/anti-ad-domains.txt" >> $GITHUB_ENV
|
|
echo "CUSTOM_DIRECT=https://raw.githubusercontent.com/Loyalsoldier/domain-list-custom/release/cn.txt" >> $GITHUB_ENV
|
|
echo "CUSTOM_PROXY=https://raw.githubusercontent.com/Loyalsoldier/domain-list-custom/release/geolocation-!cn.txt" >> $GITHUB_ENV
|
|
echo "WIN_SPY=https://raw.githubusercontent.com/crazy-max/WindowsSpyBlocker/master/data/hosts/spy.txt" >> $GITHUB_ENV
|
|
echo "WIN_UPDATE=https://raw.githubusercontent.com/crazy-max/WindowsSpyBlocker/master/data/hosts/update.txt" >> $GITHUB_ENV
|
|
echo "WIN_EXTRA=https://raw.githubusercontent.com/crazy-max/WindowsSpyBlocker/master/data/hosts/extra.txt" >> $GITHUB_ENV
|
|
shell: bash
|
|
|
|
- name: Checkout the "hidden" branch of this repo
|
|
uses: actions/checkout@v3
|
|
with:
|
|
ref: hidden
|
|
|
|
- name: Checkout Loyalsoldier/domain-list-custom
|
|
uses: actions/checkout@v3
|
|
with:
|
|
repository: Loyalsoldier/domain-list-custom
|
|
path: custom
|
|
|
|
- name: Checkout v2fly/domain-list-community
|
|
uses: actions/checkout@v3
|
|
with:
|
|
repository: v2fly/domain-list-community
|
|
path: community
|
|
|
|
- name: Checkout cokebar/gfwlist2dnsmasq
|
|
uses: actions/checkout@v3
|
|
with:
|
|
repository: cokebar/gfwlist2dnsmasq
|
|
path: gfwlist2dnsmasq
|
|
|
|
- name: Get geoip.dat relative files
|
|
run: |
|
|
wget -O cn.dat https://github.com/xishang0128/geoip/raw/release/geoip.dat
|
|
wget https://github.com/Loyalsoldier/geoip/raw/release/geoip.dat
|
|
|
|
- name: Generate GFWList domains
|
|
run: |
|
|
cd gfwlist2dnsmasq || exit 1
|
|
chmod +x ./gfwlist2dnsmasq.sh
|
|
./gfwlist2dnsmasq.sh -l -o ./temp-gfwlist.txt
|
|
|
|
- name: Get and add direct domains into temp-direct.txt file
|
|
run: |
|
|
curl -sSL ${CHINA_DOMAINS_URL} | sed '/^\s*#/d' | sed '/^[^\.]/ s/^/full: /' | sed 's/^\.\([^.]*\)/\1/' > temp-direct.txt
|
|
curl -sSL ${CUSTOM_DIRECT} | perl -ne '/^(domain):([^:]+)(\n$|:@.+)/ && print "$2\n"' >> temp-direct.txt
|
|
|
|
- name: Get and add proxy domains into temp-proxy.txt file
|
|
run: |
|
|
cat ./gfwlist2dnsmasq/temp-gfwlist.txt | perl -ne '/^((?=^.{3,255})[a-zA-Z0-9][-_a-zA-Z0-9]{0,62}(\.[a-zA-Z0-9][-_a-zA-Z0-9]{0,62})+)/ && print "$1\n"' > temp-proxy.txt
|
|
curl -sSL $GOOGLE_DOMAINS_URL | perl -ne '/^server=\/([^\/]+)\// && print "$1\n"' >> temp-proxy.txt
|
|
curl -sSL $APPLE_DOMAINS_URL | perl -ne '/^server=\/([^\/]+)\// && print "$1\n"' >> temp-proxy.txt
|
|
curl -sSL ${CUSTOM_PROXY} | grep -Ev ":@cn" | perl -ne '/^(domain):([^:]+)(\n$|:@.+)/ && print "$2\n"' >> temp-proxy.txt
|
|
|
|
# - name: Get and add reject domains into temp-reject.txt file
|
|
# run: |
|
|
# curl -sSL $EASYLISTCHINA_EASYLIST_REJECT_URL | perl -ne '/^\|\|([-_0-9a-zA-Z]+(\.[-_0-9a-zA-Z]+){1,64})\^$/ && print "$1\n"' | perl -ne 'print if not /^[0-9]{1,3}(\.[0-9]{1,3}){3}$/' > temp-reject.txt
|
|
# curl -sSL $EASYPRIVACY_REJECT_URL | perl -ne '/^\|\|([-_0-9a-zA-Z]+(\.[-_0-9a-zA-Z]+){1,64})\^$/ && print "$1\n"' | perl -ne 'print if not /^[0-9]{1,3}(\.[0-9]{1,3}){3}$/' >> temp-reject.txt
|
|
# curl -sSL $ADGUARD_DNS_REJECT_URL | perl -ne '/^\|\|([-_0-9a-zA-Z]+(\.[-_0-9a-zA-Z]+){1,64})\^$/ && print "$1\n"' | perl -ne 'print if not /^[0-9]{1,3}(\.[0-9]{1,3}){3}$/' >> temp-reject.txt
|
|
# curl -sSL $ANTIAD_DOMAINS_URL | perl -ne '/^((?=^.{3,255})[a-zA-Z0-9][-_a-zA-Z0-9]{0,62}(\.[a-zA-Z0-9][-_a-zA-Z0-9]{0,62})+)/ && print "$1\n"' >> temp-reject.txt
|
|
# curl -sSL $PETERLOWE_REJECT_URL | perl -ne '/^127\.0\.0\.1\s([-_0-9a-zA-Z]+(\.[-_0-9a-zA-Z]+){1,64})$/ && print "$1\n"' >> temp-reject.txt
|
|
# curl -sSL $DANPOLLOCK_REJECT_URL | perl -ne '/^127\.0\.0\.1\s([-_0-9a-zA-Z]+(\.[-_0-9a-zA-Z]+){1,64})/ && print "$1\n"' | sed '1d' >> temp-reject.txt
|
|
|
|
- name: Reserve `full`, `regexp` and `keyword` type of rules from custom lists to "reserve" files
|
|
run: |
|
|
curl -sSL ${CUSTOM_DIRECT} | perl -ne '/^((full|regexp|keyword):[^:]+)(\n$|:@.+)/ && print "$1\n"' | sort --ignore-case -u > direct-reserve.txt
|
|
curl -sSL ${CUSTOM_PROXY} | grep -Ev ":@cn" | perl -ne '/^((full|regexp|keyword):[^:]+)(\n$|:@.+)/ && print "$1\n"' | sort --ignore-case -u > proxy-reserve.txt
|
|
|
|
- name: Add proxy, direct and reject domains from "hidden" branch to appropriate temp files
|
|
run: |
|
|
cat proxy.txt >> temp-proxy.txt
|
|
cat direct.txt >> temp-direct.txt
|
|
# cat reject.txt >> temp-reject.txt
|
|
|
|
- name: Sort and generate redundant lists
|
|
run: |
|
|
cat temp-proxy.txt | sort --ignore-case -u > proxy-list-with-redundant
|
|
cat temp-direct.txt | sort --ignore-case -u > direct-list-with-redundant
|
|
# cat temp-reject.txt | sort --ignore-case -u > reject-list-with-redundant
|
|
|
|
- name: Remove redundant domains
|
|
run: |
|
|
chmod +x findRedundantDomain.py
|
|
./findRedundantDomain.py ./direct-list-with-redundant ./direct-list-deleted-unsort
|
|
./findRedundantDomain.py ./proxy-list-with-redundant ./proxy-list-deleted-unsort
|
|
# ./findRedundantDomain.py ./reject-list-with-redundant ./reject-list-deleted-unsort
|
|
[ ! -f "direct-list-deleted-unsort" ] && touch direct-list-deleted-unsort
|
|
[ ! -f "proxy-list-deleted-unsort" ] && touch proxy-list-deleted-unsort
|
|
# [ ! -f "reject-list-deleted-unsort" ] && touch reject-list-deleted-unsort
|
|
sort ./direct-list-deleted-unsort > ./direct-list-deleted-sort
|
|
sort ./proxy-list-deleted-unsort > ./proxy-list-deleted-sort
|
|
# sort ./reject-list-deleted-unsort > ./reject-list-deleted-sort
|
|
diff ./direct-list-deleted-sort ./direct-list-with-redundant | awk '/^>/{print $2}' > ./direct-list-without-redundant
|
|
diff ./proxy-list-deleted-sort ./proxy-list-with-redundant | awk '/^>/{print $2}' > ./proxy-list-without-redundant
|
|
# diff ./reject-list-deleted-sort ./reject-list-with-redundant | awk '/^>/{print $2}' > ./reject-list-without-redundant
|
|
|
|
- name: Remove domains from "need-to-remove" lists in "hidden" branch
|
|
run: |
|
|
diff ./direct-need-to-remove.txt ./direct-list-without-redundant | awk '/^>/{print $2}' > temp-cn.txt
|
|
diff ./proxy-need-to-remove.txt ./proxy-list-without-redundant | awk '/^>/{print $2}' > temp-geolocation-\!cn.txt
|
|
# diff ./reject-need-to-remove.txt ./reject-list-without-redundant | awk '/^>/{print $2}' > temp-category-ads-all.txt
|
|
|
|
- name: Remove domains end with ".cn" in "temp-geolocation-!cn.txt" and write lists to data directory
|
|
run: |
|
|
cat temp-cn.txt | sort --ignore-case -u | perl -ne '/^((?=^.{1,255})[a-zA-Z0-9][-_a-zA-Z0-9]{0,62}(\.[a-zA-Z0-9][-_a-zA-Z0-9]{0,62})*)/ && print "$1\n"' > ./community/data/cn
|
|
cat temp-cn.txt | sort --ignore-case -u | perl -ne 'print if not /^((?=^.{3,255})[a-zA-Z0-9][-_a-zA-Z0-9]{0,62}(\.[a-zA-Z0-9][-_a-zA-Z0-9]{0,62})+)/' > direct-tld-list.txt
|
|
cat temp-geolocation-\!cn.txt | sort --ignore-case -u | perl -ne '/^((?=^.{1,255})[a-zA-Z0-9][-_a-zA-Z0-9]{0,62}(\.[a-zA-Z0-9][-_a-zA-Z0-9]{0,62})*)/ && print "$1\n"' | perl -ne 'print if not /\.cn$/' > ./community/data/geolocation-\!cn
|
|
cat temp-geolocation-\!cn.txt | sort --ignore-case -u | perl -ne 'print if not /^((?=^.{3,255})[a-zA-Z0-9][-_a-zA-Z0-9]{0,62}(\.[a-zA-Z0-9][-_a-zA-Z0-9]{0,62})+)/' > proxy-tld-list.txt
|
|
# cat temp-category-ads-all.txt | sort --ignore-case -u | perl -ne '/^((?=^.{1,255})[a-zA-Z0-9][-_a-zA-Z0-9]{0,62}(\.[a-zA-Z0-9][-_a-zA-Z0-9]{0,62})*)/ && print "$1\n"' > ./community/data/category-ads-all
|
|
# cat temp-category-ads-all.txt | sort --ignore-case -u | perl -ne 'print if not /^((?=^.{3,255})[a-zA-Z0-9][-_a-zA-Z0-9]{0,62}(\.[a-zA-Z0-9][-_a-zA-Z0-9]{0,62})+)/' > reject-tld-list.txt
|
|
|
|
- name: Add `full`, `regexp` and `keyword` type of rules back into "cn", "geolocation-!cn" and "category-ads-all" list
|
|
run: |
|
|
[ -f "direct-reserve.txt" ] && cat direct-reserve.txt >> ./community/data/cn
|
|
[ -f "proxy-reserve.txt" ] && cat proxy-reserve.txt >> ./community/data/geolocation-\!cn
|
|
# [ -f "reject-reserve.txt" ] && cat reject-reserve.txt >> ./community/data/category-ads-all
|
|
cp ./community/data/cn direct-list.txt
|
|
cp ./community/data/geolocation-\!cn proxy-list.txt
|
|
# cp ./community/data/category-ads-all reject-list.txt
|
|
# awk '{print "0.0.0.0 " $0}' reject-list.txt > hosts
|
|
|
|
- name: Create `google-cn`、`apple-cn`、`gfw` lists
|
|
run: |
|
|
curl -sSL $GOOGLE_DOMAINS_URL | perl -ne '/^server=\/([^\/]+)\// && print "full:$1\n"' > ./community/data/google-cn
|
|
curl -sSL $APPLE_DOMAINS_URL | perl -ne '/^server=\/([^\/]+)\// && print "full:$1\n"' > ./community/data/apple-cn
|
|
cat ./gfwlist2dnsmasq/temp-gfwlist.txt | perl -ne '/^((?=^.{3,255})[a-zA-Z0-9][-_a-zA-Z0-9]{0,62}(\.[a-zA-Z0-9][-_a-zA-Z0-9]{0,62})+)/ && print "$1\n"' >> ./community/data/gfw
|
|
curl -sSL $WIN_SPY | grep "0.0.0.0" | awk '{print $2}' > ./community/data/win-spy
|
|
curl -sSL $WIN_UPDATE | grep "0.0.0.0" | awk '{print $2}' > ./community/data/win-update
|
|
curl -sSL $WIN_EXTRA | grep "0.0.0.0" | awk '{print $2}' > ./community/data/win-extra
|
|
|
|
- name: merge 'ios_rule_script/SteamCN'
|
|
env:
|
|
SED: sed '/^\s*#/d' | sed 's/DOMAIN,//g' | sed 's/DOMAIN-SUFFIX,//g' | sed 's/DOMAIN-KEYWORD,/keyword:/g'
|
|
run: |
|
|
curl -sSL https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/rule/Clash/SteamCN/SteamCN.list | ${{ env.SED }} > steamcn.txt
|
|
while read line; do grep -q "$line @cn" ./community/data/steam || sed -i "/$line/ s/$/ @cn/" ./community/data/steam; done < steamcn.txt
|
|
cat ./community/data/steam
|
|
|
|
- name: Add `meta` data
|
|
env:
|
|
SED: sed '/^\s*#/d' | sed 's/^PROCESS-NAME,//' | sed 's/DOMAIN,/full:/g' | sed 's/DOMAIN-SUFFIX,//g' | sed 's/DOMAIN-KEYWORD,/keyword:/g'
|
|
run: |
|
|
curl -sSL https://raw.githubusercontent.com/xishang0128/rules/main/biliintl.list > ./community/data/biliintl
|
|
curl -sSL https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/rule/Clash/OneDrive/OneDrive.list | ${{ env.SED }} > ./community/data/onedrive
|
|
echo "sharepoint.cn" >> ./community/data/onedrive && sort ./community/data/onedrive | uniq -i > tmp.txt && mv tmp.txt ./community/data/onedrive
|
|
curl -sSL https://raw.githubusercontent.com/xishang0128/rules/main/sharepoint.list > ./community/data/sharepoint
|
|
curl -sSL https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/rule/Clash/PrivateTracker/PrivateTracker.list | ${{ env.SED }} > ./community/data/tracker1
|
|
curl -sSL https://gitea.com/XIU2/TrackersListCollection/raw/branch/master/all.txt | grep -i "\.[A-Z]" | grep -v tracker | sed 's/^.*\/\///g' | sed 's/:.*\/.*//g' >> ./community/data/tracker1
|
|
sort ./community/data/tracker1 | uniq -i > ./community/data/tracker
|
|
rm ./community/data/tracker1
|
|
|
|
- name: Build geosite.dat file
|
|
run: |
|
|
cd custom || exit 1
|
|
go run ./ --datapath=../community/data
|
|
|
|
- name: Build geosite-lite.dat file
|
|
env:
|
|
NO_SKIP: true
|
|
run: |
|
|
cd community || exit 1
|
|
mkdir -p data-lite
|
|
curl -sSL https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/rule/Clash/ChinaMax/ChinaMax_Domain.txt | sed '/^\s*#/d' | sed '/^[^\.]/ s/^/full: /' | sed 's/^\.\([^.]*\)/\1/' > cn
|
|
curl -sSL https://raw.githubusercontent.com/Loyalsoldier/domain-list-custom/release/cn.txt | perl -ne '/^((full|regexp|keyword):[^:]+)(\n$|:@.+)/ && print "$1\n"' | sort --ignore-case -u >> cn
|
|
curl -sSL https://raw.githubusercontent.com/Loyalsoldier/domain-list-custom/release/cn.txt | perl -ne '/^(domain):([^:]+)(\n$|:@.+)/ && print "$2\n"' >> cn
|
|
sort ./cn | uniq -i > ./data-lite/cn
|
|
go run ./ --datapath=./data-lite --outputname geosite-lite.dat
|
|
|
|
- name: Checkout SagerNet/sing-geosite
|
|
uses: actions/checkout@v3
|
|
with:
|
|
repository: SagerNet/sing-geosite
|
|
path: sing-geosite
|
|
|
|
|
|
- name: Build geosite-lite.db file
|
|
env:
|
|
NO_SKIP: true
|
|
run: |
|
|
cd sing-geosite || exit 1
|
|
cp ../community/geosite-lite.dat ./
|
|
go run -v . geosite-lite.dat geosite.db
|
|
mv geosite.db geosite-lite.db
|
|
|
|
- name: Build geosite.db file
|
|
env:
|
|
NO_SKIP: true
|
|
run: |
|
|
cd sing-geosite || exit 1
|
|
cp ../custom/publish/geosite.dat ./
|
|
go run -v . geosite.dat geosite.db
|
|
|
|
- name: Checkout SagerNet/sing-geoip
|
|
uses: actions/checkout@v3
|
|
with:
|
|
repository: SagerNet/sing-geoip
|
|
path: sing-geoip
|
|
|
|
- name: Build geoip.db file
|
|
env:
|
|
NO_SKIP: true
|
|
run: |
|
|
cd sing-geoip || exit 1
|
|
sed -i 's/Dreamacro\/maxmind-geoip/xishang0128\/geoip/g' main.go
|
|
go run -v .
|
|
mv geoip.db cn.db
|
|
|
|
- name: Build geoip.db
|
|
env:
|
|
NO_SKIP: true
|
|
run: |
|
|
cd sing-geoip || exit 1
|
|
sed -i 's/xishang0128\/geoip/Loyalsoldier\/geoip/g' main.go
|
|
go run -v .
|
|
|
|
- name: Move and zip files
|
|
run: |
|
|
mkdir -p ./publish/
|
|
wget https://raw.githubusercontent.com/xishang0128/geoip/release/Country.mmdb -O ./publish/cn.mmdb
|
|
wget https://raw.githubusercontent.com/Loyalsoldier/geoip/release/Country.mmdb -O ./publish/country.mmdb
|
|
install -Dp ./cn.dat ./publish/
|
|
install -Dp ./geoip.dat ./publish/
|
|
install -Dp ./custom/publish/geosite.dat ./publish/
|
|
install -Dp ./sing-geosite/geosite.db ./publish/
|
|
install -Dp ./community/geosite-lite.dat ./publish/
|
|
install -Dp ./sing-geosite/geosite-lite.db ./publish/
|
|
install -Dp ./sing-geoip/geoip.db ./publish/
|
|
install -Dp ./sing-geoip/cn.db ./publish/
|
|
curl -sSL https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/rule/Clash/ChinaMax/ChinaMax_Domain.yaml | sed '/^\s*#/d' > ./publish/cn_domain.yaml
|
|
curl -sSL https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/rule/Clash/Proxy/Proxy_Domain.yaml | sed '/^\s*#/d' > ./publish/proxy.yaml
|
|
cd ./publish || exit 1
|
|
|
|
|
|
- name: Delete current release assets
|
|
uses: andreaswilli/delete-release-assets-action@v2.0.0
|
|
with:
|
|
github_token: ${{ secrets.GITHUB_TOKEN }}
|
|
tag: latest
|
|
deleteOnlyFromDrafts: false
|
|
|
|
|
|
- name: Release and upload assets
|
|
uses: softprops/action-gh-release@v0.1.6
|
|
with:
|
|
name: latest
|
|
tag_name: latest
|
|
draft: false
|
|
prerelease: false
|
|
files: |
|
|
./publish/*
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Git push assets to "release" branch
|
|
run: |
|
|
cd publish || exit 1
|
|
git init
|
|
git config --local user.name "github-actions[bot]"
|
|
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
|
git checkout -b release
|
|
git add .
|
|
git commit -m "${{ env.RELEASE_NAME }}"
|
|
git remote add origin "https://${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}"
|
|
git push -f -u origin release
|
|
|
|
- name: Purge jsdelivr CDN
|
|
run: |
|
|
cd publish || exit 1
|
|
for file in $(ls); do
|
|
curl -i "https://purge.jsdelivr.net/gh/${{ github.repository }}@release/${file}"
|
|
done
|