2020-01-27 20:45:39 +08:00
|
|
|
name: Build V2Ray rules dat files
|
2019-12-13 15:23:54 +08:00
|
|
|
on:
|
|
|
|
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-04-21 13:56:25 +08:00
|
|
|
- hidden
|
2019-12-10 15:40:58 +08:00
|
|
|
jobs:
|
|
|
|
build:
|
|
|
|
name: Build
|
2019-12-10 17:17:09 +08:00
|
|
|
runs-on: ubuntu-latest
|
2019-12-10 15:40:58 +08:00
|
|
|
steps:
|
2020-02-26 22:02:08 +08:00
|
|
|
- name: Setup Go 1.14
|
2020-06-06 10:21:12 +08:00
|
|
|
uses: actions/setup-go@v2
|
2019-12-10 15:40:58 +08:00
|
|
|
with:
|
2020-02-26 22:02:08 +08:00
|
|
|
go-version: 1.14
|
2019-12-10 15:40:58 +08:00
|
|
|
|
2019-12-23 20:42:11 +08:00
|
|
|
- name: Set $GOPATH and more variables
|
2019-12-13 23:26:24 +08:00
|
|
|
run: |
|
2020-02-28 02:36:52 +08:00
|
|
|
echo "::set-env name=RELEASE_NAME::Released on $(date +%Y%m%d%H%M)"
|
2019-12-23 20:42:11 +08:00
|
|
|
echo "::set-env name=TAG_NAME::$(date +%Y%m%d%H%M)"
|
2020-04-02 23:22:17 +08:00
|
|
|
echo "::set-env name=GEOIP_REPO::github.com/Loyalsoldier/geoip"
|
2019-12-13 23:26:24 +08:00
|
|
|
echo "::set-env name=GEOSITE_REPO::github.com/v2ray/domain-list-community"
|
2020-01-10 14:15:44 +08:00
|
|
|
echo "::set-env name=CHINA_DOMAINS_URL::https://raw.githubusercontent.com/felixonmars/dnsmasq-china-list/master/accelerated-domains.china.conf"
|
2020-01-09 19:00:24 +08:00
|
|
|
echo "::set-env name=GOOGLE_DOMAINS_URL::https://raw.githubusercontent.com/felixonmars/dnsmasq-china-list/master/google.china.conf"
|
|
|
|
echo "::set-env name=APPLE_DOMAINS_URL::https://raw.githubusercontent.com/felixonmars/dnsmasq-china-list/master/apple.china.conf"
|
|
|
|
echo "::set-env name=GFWLIST_DOMAINS_URL::https://cokebar.github.io/gfwlist2dnsmasq/gfwlist_domain.txt"
|
2020-05-30 17:28:53 +08:00
|
|
|
echo "::set-env name=GFWLIST_EXTRAS_DOMAINS_URL::https://raw.githubusercontent.com/pexcn/gfwlist-extras/master/gfwlist-extras.txt"
|
2020-01-09 19:00:24 +08:00
|
|
|
echo "::set-env name=GREATFIRE_DOMAINS_URL::https://raw.githubusercontent.com/wongsyrone/domain-block-list/master/domains.txt"
|
2020-05-09 21:51:58 +08:00
|
|
|
echo "::set-env name=GREATFIRE_DOMAINS_MINE_URL::https://raw.githubusercontent.com/Loyalsoldier/cn-blocked-domain/release/domains.txt"
|
2020-01-10 16:10:06 +08:00
|
|
|
echo "::set-env name=PROFILES_URL::https://raw.githubusercontent.com/ConnersHua/Profiles/master/Shadow/Pro.conf"
|
2020-01-10 14:15:44 +08:00
|
|
|
echo "::set-env name=GEQ1AN_RULES_APPLE_URL::https://raw.githubusercontent.com/GeQ1an/Rules/master/QuantumultX/Filter/Apple.list"
|
2020-03-08 11:37:10 +08:00
|
|
|
echo "::set-env name=GEQ1AN_RULES_MICROSOFT_URL::https://raw.githubusercontent.com/GeQ1an/Rules/master/QuantumultX/Filter/Optional/Microsoft.list"
|
2020-01-10 14:15:44 +08:00
|
|
|
echo "::set-env name=GEQ1AN_RULES_GLOBAL_MEDIA_URL::https://raw.githubusercontent.com/GeQ1an/Rules/master/QuantumultX/Filter/GMedia.list"
|
|
|
|
echo "::set-env name=GEQ1AN_RULES_OUTSIDE_URL::https://raw.githubusercontent.com/GeQ1an/Rules/master/QuantumultX/Filter/Outside.list"
|
|
|
|
echo "::set-env name=GEQ1AN_RULES_REJECT_URL::https://raw.githubusercontent.com/GeQ1an/Rules/master/QuantumultX/Filter/AdBlock.list"
|
2020-03-01 01:30:33 +08:00
|
|
|
echo "::set-env name=LHIE1_RULES_PROXY_URL::https://raw.githubusercontent.com/lhie1/Rules/master/Surge/Surge%203/Provider/Proxy.list"
|
|
|
|
echo "::set-env name=LHIE1_RULES_REJECT_URL::https://raw.githubusercontent.com/lhie1/Rules/master/Surge/Surge%203/Provider/Reject.list"
|
2020-05-30 20:01:37 +08:00
|
|
|
echo "::set-env name=ADAWAY_REJECT_URL::https://raw.githubusercontent.com/AdAway/adaway.github.io/master/hosts.txt"
|
2019-12-31 02:27:18 +08:00
|
|
|
echo "::set-env name=GOPATH::$(dirname $GITHUB_WORKSPACE)"
|
2019-12-13 23:26:24 +08:00
|
|
|
echo "::add-path::$(dirname $GITHUB_WORKSPACE)/bin"
|
|
|
|
shell: bash
|
2019-12-11 02:56:31 +08:00
|
|
|
|
2020-01-27 20:45:39 +08:00
|
|
|
- name: Checkout the "hidden" branch
|
2020-06-19 13:50:03 +08:00
|
|
|
uses: actions/checkout@v2.3.1
|
2019-12-23 20:42:11 +08:00
|
|
|
with:
|
|
|
|
ref: hidden
|
|
|
|
|
2020-01-27 20:45:39 +08:00
|
|
|
- name: Get GeoLite2 zip file
|
2019-12-31 22:39:50 +08:00
|
|
|
run: |
|
2019-12-31 23:40:04 +08:00
|
|
|
curl -L -o GeoLite2-Country-CSV.zip "https://download.maxmind.com/app/geoip_download?edition_id=GeoLite2-Country-CSV&license_key=JvbzLLx7qBZT&suffix=zip"
|
2019-12-31 22:39:50 +08:00
|
|
|
unzip GeoLite2-Country-CSV.zip
|
|
|
|
rm -f GeoLite2-Country-CSV.zip
|
|
|
|
mv GeoLite2* geoip
|
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: |
|
2019-12-31 22:39:50 +08:00
|
|
|
go get -u -v -insecure $GEOIP_REPO
|
2020-06-13 10:13:54 +08:00
|
|
|
geoip --country=./geoip/GeoLite2-Country-Locations-en.csv --ipv4=./geoip/GeoLite2-Country-Blocks-IPv4.csv --ipv6=./geoip/GeoLite2-Country-Blocks-IPv6.csv --ipv4CN=https://raw.githubusercontent.com/pexcn/daily/gh-pages/chnroute/chnroute.txt
|
2019-12-13 23:26:24 +08:00
|
|
|
|
|
|
|
- name: Download geosite project
|
|
|
|
run: |
|
2019-12-13 23:36:57 +08:00
|
|
|
go get -u -v -insecure $GEOSITE_REPO
|
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-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-01-27 22:47:32 +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-05-09 21:51:58 +08:00
|
|
|
curl -sSL $GREATFIRE_DOMAINS_MINE_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 16:10:06 +08:00
|
|
|
curl -sSL $PROFILES_URL | awk -F ',' '/^DOMAIN(,|\-SUFFIX,).+PROXY/ {print $2}' >> temp-proxy.txt
|
2020-01-10 14:15:44 +08:00
|
|
|
curl -sSL $GEQ1AN_RULES_APPLE_URL | awk -F ',' '/^(HOST|DOMAIN)(,|\-SUFFIX,).+Apple/ {print $2}' >> temp-proxy.txt
|
|
|
|
curl -sSL $GEQ1AN_RULES_MICROSOFT_URL | awk -F ',' '/^(HOST|DOMAIN)(,|\-SUFFIX,).+Microsoft/ {print $2}' >> temp-proxy.txt
|
|
|
|
curl -sSL $GEQ1AN_RULES_GLOBAL_MEDIA_URL | awk -F ',' '/^(HOST|DOMAIN)(,|\-SUFFIX,).+GMedia/ {print $2}' >> temp-proxy.txt
|
|
|
|
curl -sSL $GEQ1AN_RULES_OUTSIDE_URL | awk -F ',' '/^(HOST|DOMAIN)(,|\-SUFFIX,).+Outside/ {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-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-01-10 16:10:06 +08:00
|
|
|
curl -sSL $PROFILES_URL | awk -F ',' '/^DOMAIN(,|\-SUFFIX,).+REJECT/ {print $2}' > temp-reject.txt
|
2020-01-10 14:15:44 +08:00
|
|
|
curl -sSL $GEQ1AN_RULES_REJECT_URL | awk -F ',' '/^(HOST|DOMAIN)(,|\-SUFFIX,).+AdBlock/ {print $2}' >> temp-reject.txt
|
2020-03-01 01:30:33 +08:00
|
|
|
curl -sSL $LHIE1_RULES_REJECT_URL | awk -F ',' '/^DOMAIN(,|\-SUFFIX,).+/ {print $2}' >> temp-reject.txt
|
2020-05-30 20:01:37 +08:00
|
|
|
curl -sSL $ADAWAY_REJECT_URL | grep "127.0.0.1" | sed '1d' | awk '{print $2}' >> temp-reject.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-03-02 01:05:01 +08:00
|
|
|
cat temp-proxy.txt | sort --ignore-case -u | 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"' > proxy-list-with-redundant
|
2020-06-06 10:21:12 +08:00
|
|
|
cat temp-proxy.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-excluse-list.txt
|
2020-03-02 01:05:01 +08:00
|
|
|
cat temp-direct.txt | sort --ignore-case -u | 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"' > direct-list-with-redundant
|
2020-06-06 10:21:12 +08:00
|
|
|
cat temp-direct.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-excluse-list.txt
|
2020-03-02 01:05:01 +08:00
|
|
|
cat temp-reject.txt | sort --ignore-case -u | 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"' > reject-list-with-redundant
|
2020-06-06 10:21:12 +08:00
|
|
|
cat temp-reject.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-excluse-list.txt
|
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-03-14 12:12:07 +08:00
|
|
|
- name: Remove domains from "need-to-remove" lists in "hidden" branch and remove domains end with ".cn" in proxy-list
|
2020-03-10 10:57:50 +08:00
|
|
|
run: |
|
2020-06-06 10:21:12 +08:00
|
|
|
diff ./direct-need-to-remove.txt ./direct-list-without-redundant | awk '/^>/{print $2}' > $GOPATH/src/$GEOSITE_REPO/data/direct-list.txt
|
|
|
|
diff ./proxy-need-to-remove.txt ./proxy-list-without-redundant | awk '/^>/{print $2}' | perl -ne 'print if not /\.cn$/' > $GOPATH/src/$GEOSITE_REPO/data/proxy-list.txt
|
|
|
|
diff ./reject-need-to-remove.txt ./reject-list-without-redundant | awk '/^>/{print $2}' > $GOPATH/src/$GEOSITE_REPO/data/reject-list.txt
|
2020-03-02 01:05:01 +08:00
|
|
|
|
2020-01-10 13:22:40 +08:00
|
|
|
- name: Add list into appropriate category file
|
2019-12-15 18:14:44 +08:00
|
|
|
run: |
|
2019-12-15 18:25:24 +08:00
|
|
|
cd $GOPATH/src/$GEOSITE_REPO/data
|
2020-06-06 10:21:12 +08:00
|
|
|
echo "include:proxy-list.txt" >> geolocation-\!cn
|
|
|
|
echo "include:direct-list.txt" >> cn
|
|
|
|
echo "include:reject-list.txt" >> category-ads-all
|
2019-12-15 18:14:44 +08:00
|
|
|
|
2020-06-10 15:13:52 +08:00
|
|
|
- name: Add `google-cn` and `apple-cn` sub-lists for custom routing settings for third-party users due to accessibility in China mainland
|
|
|
|
run: |
|
|
|
|
curl -sSL $GOOGLE_DOMAINS_URL | perl -ne '/^server=\/([^\/]+)\// && print "$1\n"' > $GOPATH/src/$GEOSITE_REPO/data/google-cn
|
|
|
|
curl -sSL $APPLE_DOMAINS_URL | perl -ne '/^server=\/([^\/]+)\// && print "$1\n"' > $GOPATH/src/$GEOSITE_REPO/data/apple-cn
|
|
|
|
|
2019-12-13 23:26:24 +08:00
|
|
|
- name: Build geosite.dat file
|
|
|
|
run: |
|
2020-06-03 18:37:56 +08:00
|
|
|
domain-list-community --datapath=${{ env.GOPATH }}/src/${{ env.GEOSITE_REPO }}/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-06-06 10:21:12 +08:00
|
|
|
install -Dp geoip.dat ./publish/geoip.dat
|
|
|
|
install -Dp dlc.dat ./publish/geosite.dat
|
|
|
|
install -p {proxy,direct,reject}-excluse-list.txt ./publish/
|
|
|
|
install -p $GOPATH/src/$GEOSITE_REPO/data/{proxy,direct,reject}-list.txt ./publish/
|
2020-02-24 15:54:01 +08:00
|
|
|
cd ./publish
|
2020-06-06 10:21:12 +08:00
|
|
|
zip rules.zip {proxy,direct,reject}-list.txt geoip.dat geosite.dat
|
2020-06-08 03:17:03 +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
|
|
|
|
git config --local user.name "${{ github.actor }}"
|
|
|
|
git config --local user.email "${{ github.actor }}@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 }}"
|
2020-03-01 16:49:00 +08:00
|
|
|
git push -f -u origin release
|