2020-01-27 20:45:39 +08:00
name : Build V2Ray rules dat files
2019-12-13 15:23:54 +08:00
on :
2020-10-27 09:46:53 +08:00
workflow_dispatch :
2019-12-13 15:23:54 +08:00
schedule :
2019-12-22 22:09:23 +08:00
- cron : "0 22 * * *"
2019-12-13 23:26:24 +08:00
push :
branches :
2019-12-15 18:14:44 +08:00
- master
2020-07-07 10:38:09 +08:00
paths-ignore :
- "**/README.md"
2019-12-10 15:40:58 +08:00
jobs :
build :
2019-12-10 17:17:09 +08:00
runs-on : ubuntu-latest
2019-12-10 15:40:58 +08:00
steps :
2020-10-27 09:04:23 +08:00
- name : Setup Go 1.x.y
2020-06-06 10:21:12 +08:00
uses : actions/setup-go@v2
2019-12-10 15:40:58 +08:00
with :
2020-10-27 09:04:23 +08:00
go-version : "^1.15"
2019-12-10 15:40:58 +08:00
2020-10-27 09:04:23 +08:00
- name : Set variables
2019-12-13 23:26:24 +08:00
run : |
2020-10-06 15:02:20 +08:00
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/felixonmars/dnsmasq-china-list/master/accelerated-domains.china.conf" >> $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 "GFWLIST_DOMAINS_URL=https://cokebar.github.io/gfwlist2dnsmasq/gfwlist_domain.txt" >> $GITHUB_ENV
echo "GFWLIST_EXTRAS_DOMAINS_URL=https://raw.githubusercontent.com/pexcn/gfwlist-extras/master/gfwlist-extras.txt" >> $GITHUB_ENV
echo "GREATFIRE_DOMAINS_URL=https://raw.githubusercontent.com/Loyalsoldier/cn-blocked-domain/release/domains.txt" >> $GITHUB_ENV
echo "GEQ1AN_RULES_GLOBAL_MEDIA_URL=https://raw.githubusercontent.com/GeQ1an/Rules/master/QuantumultX/Filter/GMedia.list" >> $GITHUB_ENV
echo "LHIE1_RULES_PROXY_URL=https://raw.githubusercontent.com/lhie1/Rules/master/Surge/Surge%203/Provider/Proxy.list" >> $GITHUB_ENV
echo "EASYLISTCHINA_EASYLIST_REJECT_URL=https://easylist-downloads.adblockplus.org/easylistchina+easylist.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
2020-10-27 09:04:23 +08:00
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
2019-12-13 23:26:24 +08:00
shell : bash
2019-12-11 02:56:31 +08:00
2020-10-27 09:04:23 +08:00
- name : Checkout the "hidden" branch of this repo
2020-11-04 07:03:27 +08:00
uses : actions/checkout@v2.3.4
2019-12-23 20:42:11 +08:00
with :
ref : hidden
2020-10-27 09:04:23 +08:00
- name : Checkout Loyalsoldier/geoip
2020-11-04 07:03:27 +08:00
uses : actions/checkout@v2.3.4
2020-10-27 09:04:23 +08:00
with :
repository : Loyalsoldier/geoip
path : geoip
- name : Checkout Loyalsoldier/domain-list-custom
2020-11-04 07:03:27 +08:00
uses : actions/checkout@v2.3.4
2020-10-27 09:04:23 +08:00
with :
repository : Loyalsoldier/domain-list-custom
path : custom
- name : Checkout v2fly/domain-list-community
2020-11-04 07:03:27 +08:00
uses : actions/checkout@v2.3.4
2020-10-27 09:04:23 +08:00
with :
repository : v2fly/domain-list-community
path : community
2020-01-27 20:45:39 +08:00
- name : Get GeoLite2 zip file
2020-10-03 10:35:34 +08:00
env :
LICENSE_KEY : ${{ secrets.MAXMIND_GEOLITE2_LICENSE }}
2019-12-31 22:39:50 +08:00
run : |
2020-10-03 10:35:34 +08:00
curl -L -o GeoLite2-Country-CSV.zip "https://download.maxmind.com/app/geoip_download?edition_id=GeoLite2-Country-CSV&license_key=${LICENSE_KEY}&suffix=zip"
2019-12-31 22:39:50 +08:00
unzip GeoLite2-Country-CSV.zip
rm -f GeoLite2-Country-CSV.zip
2020-10-27 09:04:23 +08:00
mv GeoLite2* geolite2
2019-12-10 17:28:39 +08:00
2019-12-31 22:39:50 +08:00
- name : Generate geoip.dat file
2019-12-13 23:26:24 +08:00
run : |
2020-10-27 09:04:23 +08:00
cd geoip || exit 1
go run ./ --country=../geolite2/GeoLite2-Country-Locations-en.csv --ipv4=../geolite2/GeoLite2-Country-Blocks-IPv4.csv --ipv6=../geolite2/GeoLite2-Country-Blocks-IPv6.csv --ipv4CN=https://raw.githubusercontent.com/pexcn/daily/gh-pages/chnroute/chnroute.txt
2020-01-27 20:45:39 +08:00
2020-01-10 14:15:44 +08:00
- name : Get and add direct domains into temp-direct.txt file
run : |
2020-01-27 22:29:56 +08:00
curl -sSL $CHINA_DOMAINS_URL | perl -ne '/^server=\/([^\/]+)\// && print "$1\n"' > temp-direct.txt
2020-10-27 09:04:23 +08:00
curl -sSL ${CUSTOM_DIRECT} | perl -ne '/^(domain|full):([^:]+)(\n$|:@.+)/ && print "$2\n"' >> temp-direct.txt
2020-01-10 14:15:44 +08:00
2020-01-10 13:22:40 +08:00
- name : Get and add proxy domains into temp-proxy.txt file
2019-12-13 23:26:24 +08:00
run : |
2020-01-27 22:47:32 +08:00
curl -sSL $GFWLIST_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-proxy.txt
2020-05-30 17:28:53 +08:00
curl -sSL $GFWLIST_EXTRAS_DOMAINS_URL | perl -ne 'print if not /^(#|\s)/' >> temp-proxy.txt
2020-07-08 16:35:31 +08:00
curl -sSL $GREATFIRE_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-proxy.txt
2020-01-27 22:29:56 +08:00
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
2020-01-10 14:15:44 +08:00
curl -sSL $GEQ1AN_RULES_GLOBAL_MEDIA_URL | awk -F ',' '/^(HOST|DOMAIN)(,|\-SUFFIX,).+GMedia/ {print $2}' >> temp-proxy.txt
2020-03-01 01:30:33 +08:00
curl -sSL $LHIE1_RULES_PROXY_URL | awk -F ',' '/^(HOST|DOMAIN)(,|\-SUFFIX,).+/ {print $2}' >> temp-proxy.txt
2020-10-27 09:04:23 +08:00
curl -sSL ${CUSTOM_PROXY} | grep -Ev ":@cn" | perl -ne '/^(domain|full):([^:]+)(\n$|:@.+)/ && print "$2\n"' >> temp-proxy.txt
2020-01-27 20:45:39 +08:00
2020-01-10 13:22:40 +08:00
- name : Get and add reject domains into temp-reject.txt file
2019-12-14 01:33:23 +08:00
run : |
2020-08-13 16:44:17 +08:00
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 $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
2020-08-07 05:59:47 +08:00
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
2020-08-11 21:04:14 +08:00
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
2020-08-03 19:14:25 +08:00
2020-10-27 09:04:23 +08:00
- name : Reserve `regexp` and `keyword` type of rules from custom lists to "reserve" files
2020-08-03 19:14:25 +08:00
run : |
2020-10-27 09:04:23 +08:00
curl -sSL ${CUSTOM_DIRECT} | perl -ne '/^((regexp|keyword):[^:]+)(\n$|:@.+)/ && print "$1\n"' > direct-reserve.txt
curl -sSL ${CUSTOM_PROXY} | grep -Ev ":@cn" | perl -ne '/^((regexp|keyword):[^:]+)(\n$|:@.+)/ && print "$1\n"' > proxy-reserve.txt
2019-12-14 01:33:23 +08:00
2020-03-10 10:47:42 +08:00
- name : Add proxy, direct and reject domains from "hidden" branch to appropriate temp files
2019-12-23 20:42:11 +08:00
run : |
cat proxy.txt >> temp-proxy.txt
cat direct.txt >> temp-direct.txt
2020-03-10 10:47:42 +08:00
cat reject.txt >> temp-reject.txt
2019-12-23 20:42:11 +08:00
2020-03-02 01:05:01 +08:00
- name : Sort and generate redundant lists
2019-12-15 18:14:44 +08:00
run : |
2020-08-03 19:14:25 +08:00
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
2019-12-15 18:14:44 +08:00
2020-03-02 01:05:01 +08:00
- 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
2020-03-05 13:05:43 +08:00
[ ! -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
2020-03-02 01:05:01 +08:00
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
2020-03-10 10:57:50 +08:00
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
2020-08-03 19:14:25 +08:00
- name : Remove domains from "need-to-remove" lists in "hidden" branch
2020-03-10 10:57:50 +08:00
run : |
2020-08-03 19:14:25 +08:00
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
2020-03-02 01:05:01 +08:00
2020-08-03 19:14:25 +08:00
- name : Remove domains end with ".cn" in "temp-geolocation-!cn.txt" and write lists to data directory
run : |
2020-10-27 09:04:23 +08:00
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
2020-08-03 19:14:25 +08:00
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
2020-10-27 09:04:23 +08:00
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
2020-08-03 19:14:25 +08:00
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
2020-10-27 09:04:23 +08:00
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
2020-08-03 19:14:25 +08:00
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
2020-08-19 20:51:41 +08:00
- name : Add `regexp` and `keyword` type of rules back into "cn", "geolocation-!cn" and "category-ads-all" list
2019-12-15 18:14:44 +08:00
run : |
2020-10-27 09:04:23 +08:00
[ -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
2019-12-15 18:14:44 +08:00
2020-10-29 03:25:52 +08:00
- name : Create `google-cn`、`apple-cn`、`gfw`、`greatfire` lists
2020-06-10 15:13:52 +08:00
run : |
2020-10-27 09:04:23 +08:00
curl -sSL $GOOGLE_DOMAINS_URL | perl -ne '/^server=\/([^\/]+)\// && print "$1\n"' > ./community/data/google-cn
2020-08-13 14:34:45 +08:00
curl -sSL $GOOGLE_DOMAINS_URL | perl -ne '/^server=\/([^\/]+)\// && print "$1\n"' > google-cn.txt
2020-10-27 09:04:23 +08:00
curl -sSL $APPLE_DOMAINS_URL | perl -ne '/^server=\/([^\/]+)\// && print "$1\n"' > ./community/data/apple-cn
2020-08-13 14:34:45 +08:00
curl -sSL $APPLE_DOMAINS_URL | perl -ne '/^server=\/([^\/]+)\// && print "$1\n"' > apple-cn.txt
2020-10-29 03:25:52 +08:00
curl -sSL $GFWLIST_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"' >> ./community/data/gfw
curl -sSL $GFWLIST_EXTRAS_DOMAINS_URL | perl -ne 'print if not /^(#|\s)/' >> ./community/data/gfw
cat ./community/data/gfw | sort --ignore-case -u > gfw.txt
curl -sSL $GREATFIRE_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"' >> ./community/data/greatfire
cat ./community/data/greatfire | sort --ignore-case -u > greatfire.txt
2020-06-10 15:13:52 +08:00
2019-12-13 23:26:24 +08:00
- name : Build geosite.dat file
run : |
2020-10-27 09:04:23 +08:00
cd custom || exit 1
go run ./ --datapath=../community/data
2019-12-13 23:26:24 +08:00
2020-06-06 10:21:12 +08:00
- name : Move and zip files and generate sha256 hash
2020-02-24 15:49:06 +08:00
run : |
2020-10-27 09:04:23 +08:00
install -Dp ./geoip/geoip.dat ./publish/geoip.dat
install -Dp ./custom/publish/dlc.dat ./publish/geosite.dat
2020-08-03 19:14:25 +08:00
install -p {proxy,direct,reject}-tld-list.txt ./publish/
install -p {proxy,direct,reject}-list.txt ./publish/
2020-10-29 03:25:52 +08:00
install -p {apple-cn,google-cn,gfw,greatfire}.txt ./publish/
2020-10-27 09:04:23 +08:00
cd ./publish || exit 1
2020-06-06 10:21:12 +08:00
zip rules.zip {proxy,direct,reject}-list.txt geoip.dat geosite.dat
2020-07-03 15:02:06 +08:00
sha256sum geoip.dat > geoip.dat.sha256sum
sha256sum geosite.dat > geosite.dat.sha256sum
sha256sum rules.zip > rules.zip.sha256sum
2020-02-24 15:49:06 +08:00
2020-03-01 13:04:29 +08:00
- name : Release and upload assets
uses : softprops/action-gh-release@v1
2020-02-28 02:36:52 +08:00
with :
2020-03-01 13:04:29 +08:00
name : ${{ env.RELEASE_NAME }}
2020-02-28 02:36:52 +08:00
tag_name : ${{ env.TAG_NAME }}
draft : false
prerelease : false
2020-03-01 13:04:29 +08:00
files : |
./publish/*
2020-02-28 02:36:52 +08:00
env :
GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
2020-03-01 16:15:45 +08:00
- name : Git push assets to "release" branch
run : |
cd publish
git init
2020-06-22 17:58:55 +08:00
git config --local user.name "actions"
git config --local user.email "action@github.com"
2020-03-01 16:15:45 +08:00
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 }}"
2020-03-01 16:49:00 +08:00
git push -f -u origin release